diff --git a/include/ATALights.h b/include/ATALights.h index 1004ca3..9ecf6d3 100644 --- a/include/ATALights.h +++ b/include/ATALights.h @@ -8,6 +8,8 @@ #define SOLID_COLOR_INDEX -2 #define OFF_INDEX -1 +extern uint32_t whiteTimeout; + typedef struct { int AnimationIndex; union { diff --git a/src/ATALights.cpp b/src/ATALights.cpp index a0276f8..cac870d 100644 --- a/src/ATALights.cpp +++ b/src/ATALights.cpp @@ -13,6 +13,8 @@ #define FASTLED_CORE 0 static const char* tag = "strips"; +uint32_t whiteTimeout = 0; + TaskHandle_t Animation_Task_Handle; LEDSTRIP_SETTINGS ledSettings[2]; volatile bool AnimationLooping = false; diff --git a/src/main.cpp b/src/main.cpp index b476706..3e63a62 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -171,23 +171,23 @@ void setup() Init_BLE_LightStick_Client(); } -#if OLED_ENABLED - // Init OLED - Init_OLED(sys_settings.oledSettings.width, sys_settings.oledSettings.height, sys_settings.boardPins.oled_mosi, sys_settings.boardPins.oled_sck, sys_settings.boardPins.oled_dc, sys_settings.boardPins.oled_rst, sys_settings.boardPins.oled_cs); -#endif + #if OLED_ENABLED + // Init OLED + Init_OLED(sys_settings.oledSettings.width, sys_settings.oledSettings.height, sys_settings.boardPins.oled_mosi, sys_settings.boardPins.oled_sck, sys_settings.boardPins.oled_dc, sys_settings.boardPins.oled_rst, sys_settings.boardPins.oled_cs); + #endif -#if STRIPS_ENABLED - Init_Lights_Task(); -#endif + #if STRIPS_ENABLED + Init_Lights_Task(); + #endif Buzzer_Play_Tune(TUNE_BOOT, true, true); // TODO... Test if this is still necessary need to configure pin 0 for some reason // pinMode(0, INPUT); // button0/boot pin -#if LUMASTIK_ENABLED - Init_Luma_Master(); -#endif + #if LUMASTIK_ENABLED + Init_Luma_Master(); + #endif vTaskDelay(100); Lights_Control_Task_Resume(); @@ -195,7 +195,6 @@ void setup() void loop() { - // Button Scanning ON_EVERY_N_MILLISECONDS(10) { @@ -238,41 +237,41 @@ void loop() anyrtttl::nonblocking::play(); } -// Animation TestMode Timeout -#if LEDS_ENABLED - if (animStatus.EventTestCountdown) - { - if (--animStatus.EventTestCountdown == 0) + // Animation TestMode Timeout + #if LEDS_ENABLED + if (animStatus.EventTestCountdown) { - ESP_LOGD(tag, "Test Timeout trigger"); - PostLastNormalEvent(); - if (Strip1_Task_Handle) + if (--animStatus.EventTestCountdown == 0) { - xTaskNotifyGive(Strip1_Task_Handle); - } // trigger exit of animation loop - } - }; -#endif - -// Reboot requested -#if WIFI_ENABLED - if (RebootSystem) - { - if (--RebootSystem == 0) - { - for (int i = 0; i < 3; i++) - { -#if BUZZER_ENABLED - Buzzer_Play_Tune(TUNE_BEEP, false); // blocking -#endif - vTaskDelay(200); + ESP_LOGD(tag, "Test Timeout trigger"); + PostLastNormalEvent(); + if (Strip1_Task_Handle) + { + xTaskNotifyGive(Strip1_Task_Handle); + } // trigger exit of animation loop + } + }; + #endif + + // Reboot requested + #if WIFI_ENABLED + if (RebootSystem) + { + if (--RebootSystem == 0) + { + for (int i = 0; i < 3; i++) + { + #if BUZZER_ENABLED + Buzzer_Play_Tune(TUNE_BEEP, false); // blocking + #endif + vTaskDelay(200); + } + ESP_LOGW(tag, "Restarting..."); + vTaskDelay(200); + ESP.restart(); } - ESP_LOGW(tag, "Restarting..."); - vTaskDelay(200); - ESP.restart(); } - } -#endif + #endif // Toggle Status LED L2 ON_EVERY_N_MILLISECONDS(500) @@ -285,12 +284,21 @@ void loop() } } -#if FREERTOs_DIAGNOSTICS - ON_EVERY_N_MILLISECONDS(60000) - { - print_task_watermarks(); + #if FREERTOs_DIAGNOSTICS + ON_EVERY_N_MILLISECONDS(60000) + { + print_task_watermarks(); + } + #endif + + // Turn off white light after timeout + if(whiteTimeout > 0){ + whiteTimeout--; + if(whiteTimeout == 0){ + Lights_Set_White(0); + } } -#endif + } void setupLogLevels(esp_log_level_t logLevel)