diff --git a/Firmware/OpeNITHM/Config.h b/Firmware/OpeNITHM/Config.h index 56e243b..71483c7 100644 --- a/Firmware/OpeNITHM/Config.h +++ b/Firmware/OpeNITHM/Config.h @@ -7,7 +7,7 @@ // *** USER EDITABLE CONFIG OPTIONS *** // Select which board you're using (ignore if not using Teensy) -//#define TEESNY_V1_0 // Version 1.0 (No version number on board) +#define TEESNY_V1_0 // Version 1.0 (No version number on board) //#define TEENSY_V1_1 // Version 1.1 (v1.1 on board under logo) // Uncomment this line to force the processor to use Serial Output @@ -21,7 +21,7 @@ // Comment this line for default Seaurchin air sensor bindings // Uncomment this line if your IR sensors will each be mapped to separate keyboard key -//#define IR_SENSOR_KEY +#define IR_SENSOR_KEY // Uncomment this line if your LED lights are mirrored //#define LED_REVERSE diff --git a/Firmware/OpeNITHM/OpeNITHM.ino b/Firmware/OpeNITHM/OpeNITHM.ino index f84a1f1..f6e9d8a 100644 --- a/Firmware/OpeNITHM/OpeNITHM.ino +++ b/Firmware/OpeNITHM/OpeNITHM.ino @@ -19,7 +19,7 @@ CRGB leds[16]; byte serialBuffer[100]; bool updateLeds = false; bool useSerialLeds = false; -long lastSerialLights; +int serialLightsCounter; CRGB led_on = CRGB::Purple; CRGB led_off = CRGB::Yellow; @@ -77,7 +77,7 @@ void setup() { FastLED.show(); delay(3000); - lastSerialLights = millis(); + serialLightsCounter = 0; // Initialize relevant output method / USB or serial #ifdef USB @@ -94,17 +94,17 @@ void loop() { Serial.readBytes(serialBuffer, 100); serialProcessor.processBulk(serialBuffer); } + else + { + serialLightsCounter++; + } // If currently paused through a config command, do not execute main loop if (!activated) return; - // If we're not using serial LEDs, just update the lights every loop - if (!useSerialLeds) - updateLeds = true; - // If we haven't received any serial light updates in 5 seconds, just fallback to reactive lighting - if (millis() - lastSerialLights > 5000) + if (serialLightsCounter > 300) useSerialLeds = false; // Scan touch keyboard and update lights @@ -138,6 +138,8 @@ void loop() { // If not, make it the off color leds[index].setRGB(led_off.r / 2, led_off.g / 2, led_off.b / 2); } + + updateLeds = true; } // handle changing key colors for serial LED updates else diff --git a/Firmware/OpeNITHM/SerialProcessor.cpp b/Firmware/OpeNITHM/SerialProcessor.cpp index 8d15d8e..83d93fc 100644 --- a/Firmware/OpeNITHM/SerialProcessor.cpp +++ b/Firmware/OpeNITHM/SerialProcessor.cpp @@ -54,7 +54,7 @@ void SerialProcessor::processBulk(uint8_t *buf) { serialLeds->processBulk(buf); useSerialLeds = true; - lastSerialLights = millis(); + serialLightsCounter = 0; } else if (buf[0] == CONFIG_FLAG && buf[1] == CONFIG_FLAG) { diff --git a/Firmware/OpeNITHM/SerialProcessor.h b/Firmware/OpeNITHM/SerialProcessor.h index 028ca9f..fa079ac 100644 --- a/Firmware/OpeNITHM/SerialProcessor.h +++ b/Firmware/OpeNITHM/SerialProcessor.h @@ -32,7 +32,7 @@ extern bool useSerialLeds; extern CRGB leds[16]; extern CRGB led_on; extern CRGB led_off; -extern long lastSerialLights; +extern int serialLightsCounter; class SerialProcessor {