From fc3200134d943eef4d112b17a47d2ccb9e326158 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Mon, 6 Nov 2023 21:43:30 -0800 Subject: [PATCH 1/2] party time --- src/modules/ExternalNotificationModule.cpp | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 05105c05c..47ee94dd5 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -31,6 +31,10 @@ uint8_t red = 0; uint8_t green = 0; uint8_t blue = 0; +uint8_t colorState = 1; +uint8_t brightnessIndex = 0; +uint8_t brightnessValues[] = {0, 10, 20, 30, 50, 90, 160, 170}; // blue gets multiplied by 1.5 +bool ascending = true; #endif #ifndef PIN_BUZZER @@ -100,11 +104,26 @@ int32_t ExternalNotificationModule::runOnce() } #ifdef HAS_NCP5623 if (rgb_found.type == ScanI2C::NCP5623) { - green = (green + 50) % 255; - red = abs(red - green) % 255; - blue = abs(blue / red) % 255; - + red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 + green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 + blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 rgb.setColor(red, green, blue); + + if (ascending) { // fade in + brightnessIndex++; + if (brightnessIndex > sizeof(brightnessValues - 1)) { + ascending = false; + } + } else { + brightnessIndex--; // fade out + } + if (brightnessIndex == 0) { + ascending = true; + colorState++; // next color + if (colorState > 7) { + colorState = 1; + } + } } #endif From 9f93b9ab9d15f4a996fb7940428db5b0d63edf72 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Tue, 7 Nov 2023 21:46:18 -0800 Subject: [PATCH 2/2] fix sizeof error --- src/modules/ExternalNotificationModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 47ee94dd5..6a7641b04 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -111,7 +111,7 @@ int32_t ExternalNotificationModule::runOnce() if (ascending) { // fade in brightnessIndex++; - if (brightnessIndex > sizeof(brightnessValues - 1)) { + if (brightnessIndex == (sizeof(brightnessValues) - 1)) { ascending = false; } } else {