CountDownBars non-tick-pixels darker
This commit is contained in:
parent
07a41a34cf
commit
9a01e99eec
@ -114,24 +114,33 @@ private:
|
||||
}
|
||||
|
||||
void drawCountdownBars(Display &display, uint8_t hours, uint8_t minutes, uint8_t seconds) {
|
||||
drawBar(display, 0, 0, 24, 1, 0, 24, hours, RED);
|
||||
drawBar(display, 0, 2, 30, 2, 0, 60, minutes, BLUE);
|
||||
drawBar(display, 0, 5, 30, 2, 0, 60, seconds, GREEN);
|
||||
drawBar(display, 0, 0, 24, 1, 0, 24, hours, RED, 6);
|
||||
drawBar(display, 0, 2, 30, 2, 0, 60, minutes, BLUE, 5);
|
||||
drawBar(display, 0, 5, 30, 2, 0, 60, seconds, GREEN, 10);
|
||||
}
|
||||
|
||||
void drawBar(Display &display, uint8_t _x, uint8_t _y, uint8_t _w, uint8_t _h, uint8_t min, uint8_t max, uint8_t value, const Color &color) {
|
||||
auto onCount = (uint8_t) round(((double) value - min) / (max - min) * _w * _h);
|
||||
void drawBar(Display &display, uint8_t _x, uint8_t _y, uint8_t _w, uint8_t _h, uint8_t min, uint8_t max, uint8_t value, const Color &color, uint8_t ticks) {
|
||||
auto totalOnCount = (uint8_t) round(((double) value - min) / (max - min) * _w * _h);
|
||||
uint8_t doneOnCount = 0;
|
||||
for (uint8_t y = 0; y < _h; y++) {
|
||||
for (uint8_t x = 0; x < _w; x++) {
|
||||
if (onCount <= 0) {
|
||||
if (doneOnCount >= totalOnCount) {
|
||||
return;
|
||||
}
|
||||
onCount--;
|
||||
display.set(_x + x, _y + y, color);
|
||||
doneOnCount++;
|
||||
display.set(_x + x, _y + y, (doneOnCount % ticks) == 0 ? color : factor(color, 0.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Color factor(Color color, double factor) {
|
||||
return {
|
||||
(uint8_t) round(color.r * factor),
|
||||
(uint8_t) round(color.g * factor),
|
||||
(uint8_t) round(color.b * factor),
|
||||
};
|
||||
}
|
||||
|
||||
void drawCountdownNumbers(Display &display, uint8_t hours, uint8_t minutes, uint8_t seconds) const {
|
||||
uint8_t x = 0;
|
||||
if (days > 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user