Skip to content

Commit 258a388

Browse files
committed
Clean up
1 parent 9d846bb commit 258a388

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

src/Config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ class ConfigClass
5050

5151
/// Initialize config object by mounting file system and
5252
/// reading the config file.
53-
/// @return True if successfull
53+
/// @return True if successful
5454
bool initialize();
5555

5656
/// Save config to file system
57-
/// @return True if successfull
57+
/// @return True if successful
5858
bool save();
5959

6060
/// Parse a JSON char array and apply its values to the
6161
/// config state.
6262
/// @param input JSON char array
63-
/// @return True if successfull
63+
/// @return True if successful
6464
bool parseJson(const char *input);
6565

6666
/// Get config state contained in a DynamicJsonDocument

src/Fade.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "Fade.h"
2-
32
#include "FastLEDHub.h"
43
#include "SerialOut.h"
54

@@ -14,7 +13,6 @@ namespace Fade
1413
{
1514

1615
FadeMode mode = FadeMode::NONE;
17-
uint16_t fadeBrightness = 0;
1816
uint16_t targetBrightness = 0;
1917
Ticker fadeTicker;
2018
Ticker 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

4745
void 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

103101
void 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

src/Fade.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ namespace Fade
1212

1313
enum class FadeMode
1414
{
15-
NONE = 0,
15+
NONE,
1616
ALARM,
1717
SUNSET
1818
};
1919

2020
extern FadeMode mode;
2121

22+
void tick();
2223
void handle();
2324
void begin(FadeMode fadeMode);
2425
void stop();
25-
void tick();
2626
void initialize();
2727
void getSunsetTime();
28-
bool getTime(int8_t *hour, int8_t *minute);
28+
bool getCurrentTime(int8_t *hour, int8_t *minute);
2929

3030
} // namespace Fade

src/FastLEDHub.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
#include "FastLEDHub.h"
2-
31
#include "Animation.h"
42
#include "ColorUtils.h"
53
#include "Config.h"
64
#include "Fade.h"
5+
#include "FastLEDHub.h"
76
#include "SerialOut.h"
87
#include "Webserver.h"
98
#include "WebSocket.h"

0 commit comments

Comments
 (0)