Skip to content

Commit

Permalink
party time
Browse files Browse the repository at this point in the history
  • Loading branch information
pdxlocations committed Nov 7, 2023
1 parent 600541a commit 2928a18
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/modules/ExternalNotificationModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 2928a18

Please sign in to comment.