This commit is contained in:
Alex
2019-06-10 18:33:59 +03:00
parent 6e25ac7d47
commit 53b74e6db4
9 changed files with 927 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
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);
}
}
}