|
| 1 | + 888888b. 888 d8b 888 888 888 |
| 2 | + 888 "88b 888 Y8P 888 888 888 |
| 3 | + 888 .88P 888 888 888 888 |
| 4 | + 8888888K. 888 888 88888b. 888 888 888888 888 |
| 5 | + 888 "Y88b 888 888 888 "88b 888 .88P 888 888 |
| 6 | + 888 888 888 888 888 888 888888K 888 Y8P |
| 7 | + 888 d88P 888 888 888 888 888 "88b Y88b. " |
| 8 | + 8888888P" 888 888 888 888 888 888 "Y888 888 |
| 9 | + |
| 10 | +[Blinkt](https://github.com/NotNinja/node-blinkt) is Node.js library that allows you to interact with your Blinkt |
| 11 | +hardware: |
| 12 | + |
| 13 | +https://shop.pimoroni.com/products/blinkt |
| 14 | + |
| 15 | +[](https://david-dm.org/NotNinja/node-blinkt) |
| 16 | +[](https://github.com/NotNinja/blinkt/blob/master/LICENSE.md) |
| 17 | +[](https://www.npmjs.com/package/blinkt) |
| 18 | + |
| 19 | +* [Install](#install) |
| 20 | +* [API](#api) |
| 21 | +* [Bugs](#bugs) |
| 22 | +* [Contributors](#contributors) |
| 23 | +* [License](#license) |
| 24 | + |
| 25 | +## Install |
| 26 | + |
| 27 | +Install using `npm`: |
| 28 | + |
| 29 | +``` bash |
| 30 | +$ npm install --save blinkt |
| 31 | +``` |
| 32 | + |
| 33 | +## API |
| 34 | + |
| 35 | +### Set A Single Pixel |
| 36 | + |
| 37 | +The bread and butter of Blintk! is setting pixels. You can set any of the 8 pixels on your Blinkt! to one of around 16 |
| 38 | +million colors! |
| 39 | + |
| 40 | +The `brightness` argument is completely optional. Omit it to keep the last brightness value set for that particular |
| 41 | +pixel. |
| 42 | + |
| 43 | +``` javascript |
| 44 | +blinkt.setPixel(index, red, green, blue, brightness) |
| 45 | +``` |
| 46 | + |
| 47 | +| Parameter | Description | Required | |
| 48 | +| ---------- | ------------------------------------------------------------------ | -------- | |
| 49 | +| index | The horizontal position of the pixel (between 0 and 7 - inclusive) | Yes | |
| 50 | +| red | The amount of red to be set (between 0 and 255 - inclusive) | Yes | |
| 51 | +| green | The amount of green to be set (between 0 and 255 - inclusive) | Yes | |
| 52 | +| blue | The amount of blue to be set (between 0 and 255 - inclusive) | Yes | |
| 53 | +| brightness | The brightness to be set (between 0 and 1 - inclusive) | No | |
| 54 | + |
| 55 | +### Set All Pixels |
| 56 | + |
| 57 | +Sometimes you need to set all the pixels to the same color. This convenience method does just that! |
| 58 | + |
| 59 | +The `brightness` argument is completely optional. Omit it to keep the last brightness values set for each pixel. |
| 60 | + |
| 61 | +``` javascript |
| 62 | +blinkt.setPixels(red, green, blue, brightness) |
| 63 | +``` |
| 64 | + |
| 65 | +| Parameter | Description | Required | |
| 66 | +| ---------- | ------------------------------------------------------------- | -------- | |
| 67 | +| red | The amount of red to be set (between 0 and 255 - inclusive) | Yes | |
| 68 | +| green | The amount of green to be set (between 0 and 255 - inclusive) | Yes | |
| 69 | +| blue | The amount of blue to be set (between 0 and 255 - inclusive) | Yes | |
| 70 | +| brightness | The brightness to be set (between 0 and 1 - inclusive) | No | |
| 71 | + |
| 72 | +### Show |
| 73 | + |
| 74 | +None of your pixels will appear on Blinkt! until you `show()` them. This method writes all the pixel data out to your |
| 75 | +device. |
| 76 | + |
| 77 | +``` javascript |
| 78 | +blinkt.show() |
| 79 | +``` |
| 80 | + |
| 81 | +### Clear |
| 82 | + |
| 83 | +Exactly the same as calling `setAll(0,0,0)`, clear sets all the pixels to black. |
| 84 | + |
| 85 | +You must also call `show()` if you want to turn Blinkt! off. |
| 86 | + |
| 87 | +``` javascript |
| 88 | +blinkt.clear() |
| 89 | +``` |
| 90 | + |
| 91 | +### Enable/Disable Clear On Exit |
| 92 | + |
| 93 | +Sometimes you want a script that runs and quits, leaving a pattern up on Blinkt! |
| 94 | + |
| 95 | +``` javascript |
| 96 | +blinkt.setClearOnExit(value) |
| 97 | +``` |
| 98 | + |
| 99 | +| Parameter | Description | Required | |
| 100 | +| --------- | ------------------------------------------------- | -------- | |
| 101 | +| value | `true` to clear pixels on exit; otherwise `false` | No | |
| 102 | + |
| 103 | +### Get A Single Pixel |
| 104 | + |
| 105 | +Returns the colors and brightness for a particular pixel. |
| 106 | + |
| 107 | +``` javascript |
| 108 | +blinkt.getPixel(index) |
| 109 | +``` |
| 110 | + |
| 111 | +| Parameter | Description | Required | |
| 112 | +| --------- | ------------------------------------------------------------------ | -------- | |
| 113 | +| index | The horizontal position of the pixel (between 0 and 7 - inclusive) | Yes | |
| 114 | + |
| 115 | +### Constants |
| 116 | + |
| 117 | +Blinkt! has 8 pixels. Simple. Use the constant `NUM_PIXELS` when you’re iterating over pixels, so you can avoid a *magic |
| 118 | +number* in your code. |
| 119 | + |
| 120 | +``` javascript |
| 121 | +blinkt.NUM_PIXELS |
| 122 | +``` |
| 123 | + |
| 124 | +## Bugs |
| 125 | + |
| 126 | +If you have any problems with using this library or would like to see changes currently in development you can do so |
| 127 | +[here](https://github.com/NotNinja/node-blinkt/issues). |
| 128 | + |
| 129 | +If you believe that you are experiencing issues with your Blinkt hardware, then you |
| 130 | +[get help](http://forums.pimoroni.com/c/support). |
| 131 | + |
| 132 | +## Contributors |
| 133 | + |
| 134 | +If you want to contribute, you're a legend! Information on how you can do so can be found in |
| 135 | +[CONTRIBUTING.md](https://github.com/NotNinja/node-blinkt/blob/master/CONTRIBUTING.md). We want your suggestions and |
| 136 | +pull requests! |
| 137 | + |
| 138 | +A list of Blinkt contributors can be found in |
| 139 | +[AUTHORS.md](https://github.com/NotNinja/node-blinkt/blob/master/AUTHORS.md). |
| 140 | + |
| 141 | +## License |
| 142 | + |
| 143 | +See [LICENSE.md](https://github.com/NotNinja/node-blinkt/raw/master/LICENSE.md) for more information on our MIT license. |
| 144 | + |
| 145 | +[](https://not.ninja) |
0 commit comments