Added White Timeout

This commit is contained in:
admin 2025-03-23 23:33:24 -07:00
parent 58f311d738
commit 5a34353a32
3 changed files with 59 additions and 47 deletions

View File

@ -8,6 +8,8 @@
#define SOLID_COLOR_INDEX -2 #define SOLID_COLOR_INDEX -2
#define OFF_INDEX -1 #define OFF_INDEX -1
extern uint32_t whiteTimeout;
typedef struct { typedef struct {
int AnimationIndex; int AnimationIndex;
union { union {

View File

@ -13,6 +13,8 @@
#define FASTLED_CORE 0 #define FASTLED_CORE 0
static const char* tag = "strips"; static const char* tag = "strips";
uint32_t whiteTimeout = 0;
TaskHandle_t Animation_Task_Handle; TaskHandle_t Animation_Task_Handle;
LEDSTRIP_SETTINGS ledSettings[2]; LEDSTRIP_SETTINGS ledSettings[2];
volatile bool AnimationLooping = false; volatile bool AnimationLooping = false;

View File

@ -171,23 +171,23 @@ void setup()
Init_BLE_LightStick_Client(); Init_BLE_LightStick_Client();
} }
#if OLED_ENABLED #if OLED_ENABLED
// Init OLED // 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); 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 #endif
#if STRIPS_ENABLED #if STRIPS_ENABLED
Init_Lights_Task(); Init_Lights_Task();
#endif #endif
Buzzer_Play_Tune(TUNE_BOOT, true, true); Buzzer_Play_Tune(TUNE_BOOT, true, true);
// TODO... Test if this is still necessary need to configure pin 0 for some reason // TODO... Test if this is still necessary need to configure pin 0 for some reason
// pinMode(0, INPUT); // button0/boot pin // pinMode(0, INPUT); // button0/boot pin
#if LUMASTIK_ENABLED #if LUMASTIK_ENABLED
Init_Luma_Master(); Init_Luma_Master();
#endif #endif
vTaskDelay(100); vTaskDelay(100);
Lights_Control_Task_Resume(); Lights_Control_Task_Resume();
@ -195,7 +195,6 @@ void setup()
void loop() void loop()
{ {
// Button Scanning // Button Scanning
ON_EVERY_N_MILLISECONDS(10) ON_EVERY_N_MILLISECONDS(10)
{ {
@ -238,41 +237,41 @@ void loop()
anyrtttl::nonblocking::play(); anyrtttl::nonblocking::play();
} }
// Animation TestMode Timeout // Animation TestMode Timeout
#if LEDS_ENABLED #if LEDS_ENABLED
if (animStatus.EventTestCountdown) if (animStatus.EventTestCountdown)
{
if (--animStatus.EventTestCountdown == 0)
{ {
ESP_LOGD(tag, "Test Timeout trigger"); if (--animStatus.EventTestCountdown == 0)
PostLastNormalEvent();
if (Strip1_Task_Handle)
{ {
xTaskNotifyGive(Strip1_Task_Handle); ESP_LOGD(tag, "Test Timeout trigger");
} // trigger exit of animation loop PostLastNormalEvent();
} if (Strip1_Task_Handle)
}; {
#endif xTaskNotifyGive(Strip1_Task_Handle);
} // trigger exit of animation loop
// Reboot requested }
#if WIFI_ENABLED };
if (RebootSystem) #endif
{
if (--RebootSystem == 0) // Reboot requested
{ #if WIFI_ENABLED
for (int i = 0; i < 3; i++) if (RebootSystem)
{ {
#if BUZZER_ENABLED if (--RebootSystem == 0)
Buzzer_Play_Tune(TUNE_BEEP, false); // blocking {
#endif for (int i = 0; i < 3; i++)
vTaskDelay(200); {
#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 // Toggle Status LED L2
ON_EVERY_N_MILLISECONDS(500) ON_EVERY_N_MILLISECONDS(500)
@ -285,12 +284,21 @@ void loop()
} }
} }
#if FREERTOs_DIAGNOSTICS #if FREERTOs_DIAGNOSTICS
ON_EVERY_N_MILLISECONDS(60000) ON_EVERY_N_MILLISECONDS(60000)
{ {
print_task_watermarks(); 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) void setupLogLevels(esp_log_level_t logLevel)