pitrix/src/effect_analogclock.cpp

25 lines
693 B
C++
Raw Normal View History

#include "effect_analogclock.h"
#include "my_fastled.h"
#include "ntp.h"
void AnalogClockEffect::loop(uint16_t ms) {
window->clear();
CRGB white(0xFFFFFF);
CRGB red(0xFF0000);
window->circle(8, 8, 7, &white);
uint8_t seconds = ntpClient.getSeconds();
uint8_t angle = seconds * 256 / 60;
window->lineWithAngle(8, 8, angle, 10, &red);
window->line(1<<8, 1<<8, 12<<8, 4<<8, &white);
/*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);*/
}