Handle sun times ahead of wallclock

master
Kenny Levinsen 2020-09-20 03:49:27 +02:00
parent ef117f0a1f
commit c7e004c65b
1 changed files with 7 additions and 1 deletions

8
main.c
View File

@ -244,6 +244,9 @@ static void update_temperature(struct context *ctx) {
} }
ctx->state = ANIMATING_TO_LOW; ctx->state = ANIMATING_TO_LOW;
ctx->animation_start = ctx->stop_time; ctx->animation_start = ctx->stop_time;
if (ctx->animation_start > now) {
ctx->animation_start -= 86400;
}
// fallthrough // fallthrough
case ANIMATING_TO_LOW: case ANIMATING_TO_LOW:
if (now > ctx->animation_start + ctx->duration) { if (now > ctx->animation_start + ctx->duration) {
@ -259,7 +262,10 @@ static void update_temperature(struct context *ctx) {
break; break;
} }
ctx->state = ANIMATING_TO_HIGH; ctx->state = ANIMATING_TO_HIGH;
ctx->animation_start = now; ctx->animation_start = ctx->start_time;
if (ctx->animation_start > now) {
ctx->animation_start -= 86400;
}
// fallthrough // fallthrough
case ANIMATING_TO_HIGH: case ANIMATING_TO_HIGH:
if (now > ctx->animation_start + ctx->duration) { if (now > ctx->animation_start + ctx->duration) {