11#include " Fade.h"
2-
32#include " FastLEDHub.h"
43#include " SerialOut.h"
54
@@ -14,7 +13,6 @@ namespace Fade
1413{
1514
1615FadeMode mode = FadeMode::NONE;
17- uint16_t fadeBrightness = 0 ;
1816uint16_t targetBrightness = 0 ;
1917Ticker fadeTicker;
2018Ticker debounce;
@@ -31,35 +29,35 @@ void handle()
3129 return ;
3230
3331 int8_t hour, minute;
34- if (!getTime (&hour, &minute))
32+ if (!getCurrentTime (&hour, &minute))
3533 return ;
3634
3735 if (Config.alarmEnabled && hour == Config.alarmHour && minute == Config.alarmMinute )
3836 {
39- Fade::begin (Fade:: FadeMode::ALARM);
37+ Fade::begin (FadeMode::ALARM);
4038 }
4139 else if (Config.sunsetEnabled && hour == Config.sunsetHour && minute == Config.sunsetMinute && FastLEDHub.isDim ())
4240 {
43- Fade::begin (Fade:: FadeMode::SUNSET);
41+ Fade::begin (FadeMode::SUNSET);
4442 }
4543}
4644
4745void begin (FadeMode fadeMode)
4846{
4947 mode = fadeMode;
5048 targetBrightness = FastLEDHub.brightness10 ;
51- fadeBrightness = 0 ;
52- FastLEDHub.show (fadeBrightness );
49+ FastLEDHub. brightness10 = 0 ;
50+ FastLEDHub.show ();
5351
5452 debounce.once (61 , [&](){ debounce.detach (); });
5553
56- if (fadeMode == Fade:: FadeMode::ALARM)
54+ if (fadeMode == FadeMode::ALARM)
5755 {
5856 FastLEDHub.begin (FastLEDHub.getAnimation (Config.alarmAnimation ));
5957 fadeTicker.attach_ms (Config.alarmDuration * 60 * 1000 / 1024 , tick);
6058 PRINTLN (" [FastLEDHub] Start fade 'Alarm'" );
6159 }
62- else if (fadeMode == Fade:: FadeMode::SUNSET)
60+ else if (fadeMode == FadeMode::SUNSET)
6361 {
6462 FastLEDHub.begin (FastLEDHub.getAnimation (Config.sunsetAnimation ));
6563 fadeTicker.attach_ms (Config.sunsetDuration * 60 * 1000 / targetBrightness, tick);
@@ -78,26 +76,26 @@ void tick()
7876 if (FastLEDHub.status == PAUSED)
7977 return ;
8078
81- if (mode == Fade:: FadeMode::ALARM && fadeBrightness == 1023 )
79+ if (mode == FadeMode::ALARM && FastLEDHub. brightness10 == 1023 )
8280 {
8381 if (Config.postAlarmAnimation != Config.alarmAnimation )
8482 FastLEDHub.begin (FastLEDHub.getAnimation (Config.postAlarmAnimation ));
8583
8684 stop ();
8785 PRINTLN (" [FastLEDHub] End fade 'Alarm'" );
8886 }
89- else if (mode == Fade:: FadeMode::SUNSET && fadeBrightness == targetBrightness)
87+ else if (mode == FadeMode::SUNSET && FastLEDHub. brightness10 == targetBrightness)
9088 {
9189 stop ();
9290 PRINTLN (" [FastLEDHub] End fade 'Sunset'" );
9391 }
9492 else
9593 {
96- fadeBrightness ++;
97- PRINTLN (" [FastLEDHub] Fade brightness: " + String (fadeBrightness ));
94+ FastLEDHub. brightness10 ++;
95+ PRINTLN (" [FastLEDHub] Fade brightness: " + String (FastLEDHub. brightness10 ));
9896 }
9997
100- FastLEDHub.brightness10 = fadeBrightness ;
98+ FastLEDHub.brightness10 = FastLEDHub. brightness10 ;
10199}
102100
103101void getSunsetTime ()
@@ -133,7 +131,7 @@ void getSunsetTime()
133131 }
134132}
135133
136- bool getTime (int8_t *hour, int8_t *minute)
134+ bool getCurrentTime (int8_t *hour, int8_t *minute)
137135{
138136 time_t n = time (nullptr );
139137
0 commit comments