As noticed, this reverts big_clock to the pre-subsampling state.

This commit is contained in:
Fabian Schlenz 2019-09-25 20:04:48 +02:00
parent 2395e51e88
commit c1024b3423
2 changed files with 14 additions and 18 deletions

View File

@ -8,10 +8,9 @@ private:
CRGB _color_seconds = CRGB(0xFF0000);
void _draw_seconds();
void _draw_border_pixel(uint8_t second, uint8_t part, CRGB* color);
void _draw_border_pixel(uint8_t second, CRGB* color);
public:
void loop();
String get_name() override { return "big_clock"; }
};

View File

@ -25,35 +25,32 @@ void BigClockEffect::loop() {
void BigClockEffect::_draw_seconds() {
uint8_t seconds = ntpClient.getSeconds();
for (int i=1; i<=seconds; i++) {
_draw_border_pixel(i, 0, &_color_seconds);
_draw_border_pixel(i, &_color_seconds);
}
uint16_t millis = ntpClient.getEpochMillis() % 1000;
if (millis > 0) {
//uint16_t position = ((60 - (60 - seconds) * millis) << 8) / 1000;
//uint8_t position = 60 - ((60 - seconds) * millis / 1000);
//percent = seconds00 - (59-seconds)ff
uint16_t position = ((seconds<<8) + (((60 - seconds)<<8) * millis / 1000));
_draw_border_pixel(position>>8, position&0xFF, &_color_seconds);
uint8_t part = 60 - ((60 - seconds) * millis / 1000);
_draw_border_pixel(part, &_color_seconds);
}
}
void BigClockEffect::_draw_border_pixel(uint8_t i, uint8_t part, CRGB* color) {
accum88 x, y;
void BigClockEffect::_draw_border_pixel(uint8_t i, CRGB* color) {
uint8_t x, y;
if (i<=8) {
x = (7 + i)<<8 | part;
x = 7 + i;
y = 0;
} else if (i<=23) {
x = 15 << 8;
y = (i - 10) << 8 | (255 - part);
x = 15;
y = i - 8;
} else if (i<= 38) {
x = (15 - 1 - i + 23) << 8 | (255 - part);
y = 15 << 8;
x = 15 - i + 23;
y = 15;
} else if (i <= 53) {
x = 0;
y = (15 - i + 38) << 8 | part;
y = 15 - i + 38;
} else {
x = (i - 53) << 8 | part;
x = i - 53;
y = 0;
}
window->setSubPixel(x, y, color);
window->setPixel(x, y, color);
}