Github Repo | C Header | C source | JS source |
---|---|---|---|
mongoose-os-libs/neopixel | mgos_neopixel.h | api_neopixel.js |
struct mgos_neopixel *mgos_neopixel_create(int pin, int num_pixels,
enum mgos_neopixel_order order);
Create and return a NeoPixel strip object. Example:
struct mgos_neopixel *mystrip = mgos_neopixel_create( 5, 16, MGOS_NEOPIXEL_ORDER_GRB); mgos_neopixel_set(mystrip, 0, 12, 34, 56); mgos_neopixel_show(mystrip); mgos_neopixel_clear(mystrip); mgos_neopixel_set(mystrip, 1, 12, 34, 56); mgos_neopixel_show(mystrip);
void mgos_neopixel_set(struct mgos_neopixel *np, int i, int r, int g, int b);
Set i-th pixel's RGB value. Each color (
r
,g
,b
) should be an integer from 0 to 255; they are ints and notuint8_t
s just for the FFI.Note that this only affects in-memory value of the pixel; you'll need to call
mgos_neopixel_show()
to apply changes.
void mgos_neopixel_clear(struct mgos_neopixel *np);
Clear in-memory values of the pixels.
void mgos_neopixel_show(struct mgos_neopixel *np);
Output values of the pixels.
void mgos_neopixel_free(struct mgos_neopixel *np);
Free neopixel instance.
NeoPixel.create(pin, numPixels, order)
Create and return a NeoPixel strip object. Example:
let pin = 5, numPixels = 16, colorOrder = NeoPixel.GRB;
let strip = NeoPixel.create(pin, numPixels, colorOrder);
strip.setPixel(0 /* pixel */, 12, 34, 56);
strip.show();
strip.clear();
strip.setPixel(1 /* pixel */, 12, 34, 56);
strip.show();
strip.setPixel(i, r, g, b)
Set i-th's pixel's RGB value. Note that this only affects in-memory value of the pixel.
strip.clear()
Clear in-memory values of the pixels.
strip.show()
Output values of the pixels.
edit this doc