Skip to content

Commit

Permalink
Add static LEDs support to be connected to the NeoPixel
Browse files Browse the repository at this point in the history
  • Loading branch information
mzanetti committed Feb 15, 2023
1 parent f16ece2 commit 8f31d50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
static uint8_t Led_NightBrightness = LED_INITIAL_NIGHT_BRIGHTNESS;
constexpr uint8_t Led_IdleDotDistance = NUM_LEDS / NUM_LEDS_IDLE_DOTS;

static CRGBArray<NUM_LEDS> leds;
static CRGBArray<NUM_LEDS + STATIC_LEDS> leds;
static CRGBSet indicator(leds(0, NUM_LEDS - 1));
static CRGBSet staticLeds(leds(NUM_LEDS, NUM_LEDS + STATIC_LEDS - 1));

static void Led_Task(void *parameter);
static uint8_t Led_Address(uint8_t number);
Expand Down Expand Up @@ -199,6 +200,13 @@ void Led_SetButtonLedsEnabled(boolean value) {
}
return powerAnimation;
}

static void Led_AddStatic() {
static CRGB::HTMLColorCode staticLedColors[STATIC_LEDS] = STATIC_LEDS_COLOR;
for (uint8_t staticLed = 0; staticLed < STATIC_LEDS; staticLed++) {
staticLeds[staticLed] = staticLedColors[staticLed];
}
}
#endif

#ifdef NEOPIXEL_ENABLE
Expand Down Expand Up @@ -227,7 +235,6 @@ void Led_SetButtonLedsEnabled(boolean value) {
static uint32_t staticLastTrack;
static float staticBatteryLevel;


for (;;) {
// special handling
if (Led_Pause) { // Workaround to prevent exceptions while NVS-writes take place
Expand All @@ -243,6 +250,8 @@ void Led_SetButtonLedsEnabled(boolean value) {
continue;
}

Led_AddStatic();

uint32_t taskDelay = 20;
bool updateLedRequest = false;

Expand Down
2 changes: 2 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@
#define PROGRESS_HUE_END -1
#define DIMMABLE_STATES 50 // Number of dimmed values between two full LEDs (https://forum.espuino.de/t/led-verbesserungen-rework/1739)
//#define LED_OFFSET 0 // shifts the starting LED in the original direction of the neopixel ring
#define STATIC_LEDS 5 // Add static LEDs at the end of the Neopixel, for example to use for other artwork
#define STATIC_LEDS_COLOR {CRGB::Red, CRGB::Yellow, CRGB::Blue, CRGB::Blue, CRGB::Green} // The color of the static leds
#endif

#if defined(MEASURE_BATTERY_VOLTAGE) || defined(MEASURE_BATTERY_MAX17055)
Expand Down

0 comments on commit 8f31d50

Please sign in to comment.