diff --git a/fs/animations.cfg b/fs/animations.cfg index 025d3fa..8d76cd7 100644 --- a/fs/animations.cfg +++ b/fs/animations.cfg @@ -1,16 +1,16 @@ [ - {"led": 0, "mode": "on", "ticks": 10}, - {"led": 0, "mode": "off", "ticks": 10}, - {"led": 1, "mode": "on", "ticks": 20}, - {"led": 1, "mode": "off", "ticks": 20}, - {"led": 2, "mode": "on", "ticks": 40}, - {"led": 2, "mode": "off", "ticks": 40}, - {"led": 3, "mode": "on", "ticks": 80}, - {"led": 3, "mode": "off", "ticks": 80}, - {"led": 4, "mode": "on", "ticks": 160}, - {"led": 4, "mode": "off", "ticks": 160}, - {"led": 5, "mode": "on", "ticks": 320}, - {"led": 5, "mode": "off", "ticks": 320}, - {"led": 6, "mode": "on", "ticks": 640}, - {"led": 6, "mode": "off", "ticks": 640} + {"led": 0, "mode": "on", "ticks": 2}, + {"led": 0, "mode": "off", "ticks": 2}, + {"led": 1, "mode": "on", "ticks": 4}, + {"led": 1, "mode": "off", "ticks": 4}, + {"led": 2, "mode": "on", "ticks": 8}, + {"led": 2, "mode": "off", "ticks": 8}, + {"led": 3, "mode": "on", "ticks": 16}, + {"led": 3, "mode": "off", "ticks": 16}, + {"led": 4, "mode": "on", "ticks": 32}, + {"led": 4, "mode": "off", "ticks": 32}, + {"led": 5, "mode": "on", "ticks": 64}, + {"led": 5, "mode": "off", "ticks": 64}, + {"led": 6, "mode": "on", "ticks": 128}, + {"led": 6, "mode": "off", "ticks": 128} ] diff --git a/fs/colors.cfg b/fs/colors.cfg index d4567c0..b5e4991 100644 --- a/fs/colors.cfg +++ b/fs/colors.cfg @@ -1,10 +1,12 @@ [ {"name": "off", "red": 0, "green": 0, "blue": 0}, - {"name": "candle", "red": 50, "green": 40, "blue": 10}, + {"name": "candle", "red": 30, "green": 15, "blue": 4}, {"name": "red", "red": 50, "green": 5, "blue": 5}, {"name": "green", "red": 5, "green": 50, "blue": 5}, - {"name": "blue", "red": 5, "green": 5, "blue": 50}, - {"name": "warmWhite", "red": 80, "green": 80, "blue": 40}, + {"name": "blue", "red": 5, "green": 5, "blue": 80}, + {"name": "yellow", "red": 50, "green": 50, "blue": 5}, + {"name": "violet", "red": 50, "green": 5, "blue": 80}, + {"name": "warmWhite", "red": 90, "green": 90, "blue": 30}, {"name": "coldWhite", "red": 80, "green": 80, "blue": 100}, {"name": "brightWhite", "red": 255, "green": 255, "blue": 255} -] \ No newline at end of file +] diff --git a/fs/lamps.cfg b/fs/lamps.cfg index ff299b4..5d641d7 100644 --- a/fs/lamps.cfg +++ b/fs/lamps.cfg @@ -4,6 +4,6 @@ {"level": "EG", "room": "Bad", "id": "eg-bad", "onColor": "red"}, {"level": "EG", "room": "Kueche", "id": "eg-kueche", "onColor": "green"}, {"level": "EG", "room": "Flur", "id": "eg-flur", "onColor": "blue"}, - {"level": "OG", "room": "Wohnzimmer", "id": "og-wozi", "onColor": "candle"}, - {"level": "OG", "room": "Buero", "id": "og-office", "onColor": "coldWhite"} + {"level": "OG", "room": "Wohnzimmer", "id": "og-wozi", "onColor": "yellow"}, + {"level": "OG", "room": "Buero", "id": "og-office", "onColor": "violet"} ] diff --git a/src/NeoPixel.c b/src/NeoPixel.c new file mode 100644 index 0000000..9b29980 --- /dev/null +++ b/src/NeoPixel.c @@ -0,0 +1,81 @@ +#include "mgos_bitbang.h" +#include "mgos_gpio.h" +#include "mgos_system.h" + +enum NeoPixel_ColorOrder { + RGB = 0, + GRB = 1, + BGR = 2, +}; + +#define MAX_LEDS 100 +static uint8_t NeoPixel_pin = 0; +static uint8_t NeoPixel_numPixels = 0; +static uint8_t NeoPixel_leds[3 * MAX_LEDS]; +static NeoPixel_ColorOrder NeoPixel_colorOrder = RGB; + +// ## **`NeoPixel_create(pin, numPixels, order)`** +// Create and return a NeoPixel strip object. Example: +// ```javascript +// 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(); +// ``` +void NeoPixel_create(uint8_t, pin, uint8_t numPixels, enum NeoPixel_ColorOrder order) { + mgos_gpio_init(); + NeoPixel_pin = pin; + NeoPixel_numPixels = numPixels; + NeoPixel_colorOrder = order; + // GPIO.set_mode(pin, GPIO.MODE_OUTPUT); + mgos_gpio_set_mode(pin, MGOS_GPIO_MODE_OUTPUT); + // GPIO.write(pin, 0); // Keep in reset. + mgos_gpio_write(pin, false); + NeoPixel_clear(); +} + +// ## **`NeoPixel_clear()`** +// Clear in-memory values of the pixels. +void NeoPixel_clear() { + for (int i=0; i