Attempted to make the border of big_clock use subpixel rendering. This is still work in progress.
This commit is contained in:
parent
0a7334e448
commit
7cbb156b66
@ -8,7 +8,7 @@ private:
|
|||||||
CRGB _color_seconds = CRGB(0xFF0000);
|
CRGB _color_seconds = CRGB(0xFF0000);
|
||||||
|
|
||||||
void _draw_seconds();
|
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:
|
public:
|
||||||
void loop();
|
void loop();
|
||||||
|
@ -25,32 +25,33 @@ void BigClockEffect::loop() {
|
|||||||
void BigClockEffect::_draw_seconds() {
|
void BigClockEffect::_draw_seconds() {
|
||||||
uint8_t seconds = ntpClient.getSeconds();
|
uint8_t seconds = ntpClient.getSeconds();
|
||||||
for (int i=1; i<=seconds; i++) {
|
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;
|
uint16_t millis = ntpClient.getEpochMillis() % 1000;
|
||||||
if (millis > 0) {
|
if (millis > 0) {
|
||||||
uint8_t part = 60 - ((60 - seconds) * millis / 1000);
|
uint16_t position = ((60 - (60 - seconds) * millis) << 8) / 1000;
|
||||||
_draw_border_pixel(part, &_color_seconds);
|
//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) {
|
void BigClockEffect::_draw_border_pixel(uint8_t i, uint8_t part, CRGB* color) {
|
||||||
uint8_t x, y;
|
accum88 x, y;
|
||||||
if (i<=8) {
|
if (i<=8) {
|
||||||
x = 7 + i;
|
x = (7 + i)<<8 | part;
|
||||||
y = 0;
|
y = 0;
|
||||||
} else if (i<=23) {
|
} else if (i<=23) {
|
||||||
x = 15;
|
x = 15 << 8;
|
||||||
y = i - 8;
|
y = (i - 8) << 8 | (255 - part);
|
||||||
} else if (i<= 38) {
|
} else if (i<= 38) {
|
||||||
x = 15 - i + 23;
|
x = (15 - i + 23) << 8 | (255 - part);
|
||||||
y = 15;
|
y = 15 << 8;
|
||||||
} else if (i <= 53) {
|
} else if (i <= 53) {
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 15 - i + 38;
|
y = (15 - i + 38) << 8 | part;
|
||||||
} else {
|
} else {
|
||||||
x = i - 53;
|
x = (i - 53) << 8 | part;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
window->setPixel(x, y, color);
|
window->setSubPixel(x, y, color);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user