This commit is contained in:
Alex
2019-06-30 22:51:40 +03:00
parent bbf423bde6
commit 7d35d00952
10 changed files with 1196 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
void timeTick() {
if (ESP_MODE == 1) {
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 + DAWN_TIMEOUT) ) { // раньше конца + минута
if (!manualOff) {
// величина рассвета 0-255
int dawnPosition = 255 * ((float)(thisTime - (alarm[thisDay].time - dawnOffsets[dawnMode])) / dawnOffsets[dawnMode]);
dawnPosition = constrain(dawnPosition, 0, 255);
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 {
if (dawnFlag) {
dawnFlag = false;
manualOff = false;
FastLED.setBrightness(modes[currentMode].brightness);
}
}
}
}
}