pitrix/src/effect_analogclock.cpp

34 lines
959 B
C++
Raw Normal View History

#include "effect_analogclock.h"
#include "my_fastled.h"
#include "ntp.h"
#include <time.h>
void AnalogClockEffect::loop(uint16_t ms) {
window->clear();
CRGB white(0xFFFFFF);
CRGB red(0xFF0000);
window->circle(8, 8, 7, &white);
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);
/*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);*/
}