diff --git a/USBNova.ino b/USBNova.ino index cd174e0..3ac8fac 100644 --- a/USBNova.ino +++ b/USBNova.ino @@ -24,7 +24,7 @@ void setup() { // Initialize memory and check for problems if (!msc::init()) { - led::startBlink(255, 0, 0, 200); + led::setColor(255, 0, 0, 200); return; } diff --git a/src/attack/attack.cpp b/src/attack/attack.cpp index 57b37a1..d3b3c77 100644 --- a/src/attack/attack.cpp +++ b/src/attack/attack.cpp @@ -91,9 +91,6 @@ namespace attack { msc::open(path.c_str()); } - // Stop blinking if no script is running - led::stopBlink(); - debugln("OK"); } } diff --git a/src/duckparser/duckparser.cpp b/src/duckparser/duckparser.cpp index 0473e08..0b1227a 100644 --- a/src/duckparser/duckparser.cpp +++ b/src/duckparser/duckparser.cpp @@ -309,13 +309,13 @@ namespace duckparser { led::setMode(color, mode); } - // i.e. LED 128 23 42 + // i.e. LED 128 23 42 0 (r,g,b, blink) else { word_node* w = cmd->next; - int c[3]; + int c[4]; - for (uint8_t i = 0; i<3; ++i) { + for (uint8_t i = 0; i<4; ++i) { if (w) { c[i] = toInt(w->str, w->len); w = w->next; @@ -324,7 +324,7 @@ namespace duckparser { } } - led::setColor(c[0], c[1], c[2]); + led::setColor(c[0], c[1], c[2], c[3]); } ignore_delay = true; diff --git a/src/led/led.cpp b/src/led/led.cpp index fb78a1f..b08c71c 100644 --- a/src/led/led.cpp +++ b/src/led/led.cpp @@ -11,10 +11,18 @@ namespace led { // ========== PRIVATE ========= // Adafruit_NeoPixel led { 1, LED_PIN, NEO_GRB + NEO_KHZ800 }; - uint8_t blink_color[3] { 0, 0, 0 }; + int blink_color[3] { 0, 0, 0 }; unsigned long blink_intv { 0 }; - bool blink_flag { false }; unsigned long last_blink { 0 }; + bool blink_flag { false }; + + void change_color(int r, int g, int b) { + for (size_t i = 0; i(); - read_array(config_doc, "attack_color", attack_color, 3); - read_array(config_doc, "setup_color", setup_color, 3); - read_array(config_doc, "idle_color", idle_color, 3); + read_array(config_doc, "attack_color", attack_color, 4); + read_array(config_doc, "setup_color", setup_color, 4); + read_array(config_doc, "idle_color", idle_color, 4); // Format Flash (Drive name/Disk label max 11 characters) format = config_doc.containsKey("format");