mirror of
https://github.com/gunner47/GyverLamp.git
synced 2025-08-09 01:40:59 +03:00
32 lines
1.3 KiB
C++
32 lines
1.3 KiB
C++
void timeTick() {
|
|
timeClient.update();
|
|
if (timeTimer.isReady()) {
|
|
byte thisDay = timeClient.getDay();
|
|
if (thisDay == 0) thisDay = 7; // воскресенье это 0
|
|
thisDay--;
|
|
thisTime = timeClient.getHours() * 60 + timeClient.getMinutes();
|
|
|
|
// проверка рассвета
|
|
if (alarm[thisDay].state && // день будильника
|
|
thisTime >= alarm[thisDay].time - dawnOffsets[dawnMode] && // позже начала
|
|
thisTime < alarm[thisDay].time) { // раньше конца
|
|
if (!manualOff) {
|
|
// величина рассвета 0-255
|
|
int dawnPosition = 255 * ((float)(thisTime - (alarm[thisDay].time - dawnOffsets[dawnMode])) / dawnOffsets[dawnMode]);
|
|
CHSV dawnColor = CHSV(map(dawnPosition, 0, 255, 10, 35),
|
|
map(dawnPosition, 0, 255, 255, 170),
|
|
map(dawnPosition, 0, 255, 10, DAWN_BRIGHT));
|
|
fill_solid(leds, NUM_LEDS, dawnColor);
|
|
FastLED.setBrightness(255);
|
|
FastLED.show();
|
|
dawnFlag = true;
|
|
}
|
|
} else {
|
|
dawnFlag = false;
|
|
manualOff = false;
|
|
FastLED.setBrightness(modes[currentMode].brightness);
|
|
}
|
|
|
|
}
|
|
}
|