npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blinkt-kit

v2.2.1

Published

Pimoroni Blinkt! NodeJS bindings. Based on node-blinkt. Updated for Node > 8.

Downloads

49

Readme

blinkt-kit

Pimoroni Blinkt! NodeJS bindings. Based on node-blinkt. Updated for Node > 8.

npm install blinkt-kit --save

Basic example


const { Blinkt } = require("blinkt-kit");

const blinkt = new Blinkt();

blinkt.setAll({ r: 128, g: 0, b: 128, brightness: 0.2 });
blinkt.setPixel({ pixel: 0, r: 255 });
blinkt.setPixel({ pixel: 1, g: 255 });
blinkt.setPixel({ pixel: 2, b: 255 });

// Send update applies your changes to the Blinkt!
blinkt.show();

// Switch everything off after two seconds.
setTimeout(() => {
	blinkt.clear();
}, 2000);

Other examples


const { Blinkt, COLOURS, PI_RAINBOW } = require("blinkt-kit");

const blinkt = new Blinkt({ clearOnExit: true });
const TEST_DELAY = 1000;

const showInitialAnimation = colour =>
	new Promise(resolve => {
		blinkt.showInitialAnimation({ ...colour });
		setTimeout(() => resolve(), TEST_DELAY);
	})

const showFinalAnimation = colour =>
	new Promise(resolve => {
		blinkt.showFinalAnimation({ ...colour });
		setTimeout(() => resolve(), TEST_DELAY);
	})

const flashPixel = (ix, colour) =>
	new Promise(resolve => {
		blinkt.flashPixel({ pixel: ix, times: 2, intervalms: 500, brightness: 0.5, ...colour });
		setTimeout(() => resolve(), TEST_DELAY);
	})

const turnAllOnWithColour = colour =>
	new Promise(resolve => {
		blinkt.setAll({ ...colour });
		blinkt.show();
		setTimeout(() => resolve(), TEST_DELAY);
	});

const turnOnWithColour = (ix, colour) =>
	new Promise(resolve => {
		blinkt.setPixel({ pixel: ix, ...colour });
		blinkt.show();
		setTimeout(() => resolve(), TEST_DELAY);
	});

const runThrough = async () => {
	await showInitialAnimation(COLOURS.GREEN);
	await flashPixel(2, COLOURS.GREEN);
	await turnAllOnWithColour(COLOURS.RED);
	await turnAllOnWithColour(COLOURS.GREEN);
	await turnAllOnWithColour(COLOURS.BLUE);
	await showFinalAnimation(COLOURS.RED);
};

const basicColours = async () => {
	for (let ix = 0, length = PI_RAINBOW.length; ix < length; ix++) {
		await turnOnWithColour(ix, PI_RAINBOW[ix]);
	}
};

runThrough().then(async () => {
	await setTimeout(() => basicColours(), TEST_DELAY);
});

API

setPixel({ pixel = 0, r, g, b, brightness = DEFAULT_BRIGHTNESS })

Set an individual Blinkt! pixel to the a specific value.

setAll({ r, g, b, brightness })

Set all of the Blinkt! pixels to the same values.

getAll()

Return the current state of the Blinkt! pixels.

flashPixel({pixel, times, intervalms, r, g, b, brightness})
setBrightness({ pixel, brightness = DEFAULT_BRIGHTNESS })

Set the brightness of all the Blinkt! pixels if no pixel specified, or the brightness for all of them if no PixelNumber specified.

showInitialAnimation({r, g, b})

Show an animation that starts with two pixels in the center fading up, extends outwards at full brightness and then turns off.

showFinalAnimation({r, g, b})
clear()

Unsets all of the Blinkt! Pixels

setClearOnExit(true|false)

Will undo all Blinkt! configuration and reset LEDs if the process ends or is interrupted with CTRL C.

Importantly!

show()

Commits all the 'set' operations to the Blinkt! (Nothing will show without this!)

Acknowledgements

  • Original python code: http://docs.pimoroni.com/blinkt/

  • Updated to use rpio for Node 12+ compatibility by Chris Kinsman