Skip to content

Commit

Permalink
feat: set and reset LED brightness globally before and after progress…
Browse files Browse the repository at this point in the history
… indication
  • Loading branch information
SenMorgan committed Dec 8, 2024
1 parent aa673c6 commit c816a73
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ void startProgressIndication()
// Pause the task to prevent concurrent access
vTaskSuspend(ledsTaskHandle);

// Set brightness
FastLED.setBrightness(PROGRESS_INDICATOR_BRIGHTNESS);

// Reset all LEDs
resetLedsStates();
}
Expand All @@ -86,6 +89,9 @@ void startProgressIndication()
*/
void stopProgressIndication()
{
// Reset brightness
FastLED.setBrightness(255);

// Reset all LEDs
resetLedsStates();

Expand All @@ -111,9 +117,6 @@ void progressIndicator(uint8_t progress, CRGB color)
uint8_t totalLeds = sizeof(CIRCLE_LEDS_ARRAY) / sizeof(CIRCLE_LEDS_ARRAY[0]);
uint8_t ledsToLight = (progress * totalLeds) / 100;

// Update brightness based on PROGRESS_INDICATOR_BRIGHTNESS
color.nscale8_video(PROGRESS_INDICATOR_BRIGHTNESS);

// Light up LEDs based on progress
for (uint8_t i = 0; i < ledsToLight; i++)
leds[CIRCLE_LEDS_ARRAY[i]] = color;
Expand Down

0 comments on commit c816a73

Please sign in to comment.