2019-09-25 04:24:24 +00:00
|
|
|
#include "effect_analogclock.h"
|
|
|
|
#include "my_fastled.h"
|
|
|
|
#include "ntp.h"
|
2020-03-29 16:08:54 +00:00
|
|
|
#include <time.h>
|
2019-09-25 04:24:24 +00:00
|
|
|
|
2019-10-01 04:29:32 +00:00
|
|
|
void AnalogClockEffect::loop(uint16_t ms) {
|
2019-09-25 04:24:24 +00:00
|
|
|
window->clear();
|
|
|
|
CRGB white(0xFFFFFF);
|
|
|
|
CRGB red(0xFF0000);
|
|
|
|
window->circle(8, 8, 7, &white);
|
|
|
|
|
2020-03-29 16:08:54 +00:00
|
|
|
time_t now;
|
|
|
|
tm timeinfo;
|
|
|
|
time(&now);
|
|
|
|
localtime_r(&now, &timeinfo);
|
|
|
|
uint16_t seconds = timeinfo.tm_sec * 1000 + (millis()%1000);
|
|
|
|
uint16_t angle = seconds * 0x10000 / 60000;
|
|
|
|
window->lineWithAngle(8, 8, angle, 12, &red);
|
|
|
|
//window->line(0<<8, 0<<8, 7<<8, 7<<8, &white);
|
|
|
|
//window->line(15<<8, 0<<8, 8<<8, 7<<8, &red);
|
|
|
|
//window->line(0<<8, 15<<8, 7<<8, 8<<8, &blue);
|
|
|
|
//window->line(15<<8, 15<<8, 8<<8, 8<<8, &green);
|
|
|
|
|
2019-09-25 04:24:24 +00:00
|
|
|
/*for (uint8_t i=0; i<=12; i++) {
|
|
|
|
window->lineWithAngle(8, 8, 255/12*i, 5, 2, &white);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t minutes = ntpClient.getMinutes();
|
|
|
|
uint8_t hours = ntpClient.getHours();
|
|
|
|
|
|
|
|
window->lineWithAngle(8, 8, 255/60*minutes, 6, &white);
|
|
|
|
window->lineWithAngle(8, 8, 255/12*(hours % 12), 4, &white);*/
|
|
|
|
}
|