Attempted to make the border of big_clock use subpixel rendering. This is still work in progress.

This commit is contained in:
Fabian Schlenz 2019-09-25 18:13:11 +02:00
parent 0a7334e448
commit 7cbb156b66
2 changed files with 15 additions and 14 deletions

View File

@ -8,7 +8,7 @@ private:
CRGB _color_seconds = CRGB(0xFF0000);
void _draw_seconds();
void _draw_border_pixel(uint8_t second, CRGB* color);
void _draw_border_pixel(uint8_t second, uint8_t part, CRGB* color);
public:
void loop();

View File

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