mirror of
https://github.com/gunner47/GyverLamp.git
synced 2025-08-09 09:49:11 +03:00
add
This commit is contained in:
31
firmware/GyverLamp_v1.0/time.ino
Normal file
31
firmware/GyverLamp_v1.0/time.ino
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user