Compare commits
5 Commits
4fe7d9cb81
...
db68ca0a87
| Author | SHA1 | Date | |
|---|---|---|---|
| db68ca0a87 | |||
| a0744e9059 | |||
| 91bdf7a7ad | |||
| 2613a099a7 | |||
| 87509eb5f1 |
@ -43,13 +43,13 @@ const bool DOT7[][7][1] = {
|
|||||||
{XX},
|
{XX},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{__},
|
|
||||||
{XX},
|
|
||||||
{__},
|
|
||||||
{__},
|
{__},
|
||||||
{__},
|
{__},
|
||||||
{XX},
|
{XX},
|
||||||
{__},
|
{__},
|
||||||
|
{XX},
|
||||||
|
{__},
|
||||||
|
{__},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{__},
|
{__},
|
||||||
@ -94,13 +94,13 @@ const bool NUM7[][7][4] = {
|
|||||||
{__, XX, XX, __},
|
{__, XX, XX, __},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
{__, __, __, XX},
|
||||||
{__, __, XX, XX},
|
{__, __, XX, XX},
|
||||||
{__, XX, __, XX},
|
{__, XX, __, XX},
|
||||||
{XX, __, __, XX},
|
{XX, __, __, XX},
|
||||||
{__, __, __, XX},
|
{__, __, __, XX},
|
||||||
{__, __, __, XX},
|
{__, __, __, XX},
|
||||||
{__, __, __, XX},
|
{__, __, __, XX},
|
||||||
{__, __, __, XX},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{__, XX, XX, __},
|
{__, XX, XX, __},
|
||||||
|
|||||||
@ -54,7 +54,6 @@ class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Display(): leds(8 * 32, GPIO_NUM_13,NEO_GRB + NEO_KHZ800) {
|
explicit Display(): leds(8 * 32, GPIO_NUM_13,NEO_GRB + NEO_KHZ800) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
@ -74,7 +73,7 @@ public:
|
|||||||
pixels[mapPixel(x, y)] = false;
|
pixels[mapPixel(x, y)] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setBrightness(32);
|
setBrightness(64);
|
||||||
clear();
|
clear();
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
@ -86,11 +85,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setPixel(const int x, const int y, const Color &color) {
|
void setPixel(const int x, const int y, const Color &color) {
|
||||||
const auto index = mapPixel(x, y);
|
if (x >= 32 || y >= 8) {
|
||||||
if (index >= 8 * 32) {
|
Serial.printf("[ERROR] No pixel at (%d, %d) >= %d\n", x, y, 8 * 32);
|
||||||
Serial.printf("[ERROR] No pixel at (%d, %d) = %d >= %d\n", x, y, index, 8 * 32);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const auto index = mapPixel(x, y);
|
||||||
#if LEDS_ENABLED
|
#if LEDS_ENABLED
|
||||||
leds.setPixelColor(index, color.r, color.g, color.b);
|
leds.setPixelColor(index, color.r, color.g, color.b);
|
||||||
#endif
|
#endif
|
||||||
@ -155,7 +154,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<int symbolHeight, int symbolWidth>
|
template<int symbolHeight, int symbolWidth>
|
||||||
int printSymbol(const int x, const int y, const int index, const Color &color, const bool symbols[][symbolHeight][symbolWidth]) {
|
int printSymbol(const int x, const int y, const int index, const Color &color,
|
||||||
|
const bool symbols[][symbolHeight][symbolWidth]) {
|
||||||
for (int innerY = 0; innerY < symbolHeight; innerY++) {
|
for (int innerY = 0; innerY < symbolHeight; innerY++) {
|
||||||
for (int innerX = 0; innerX < symbolWidth; innerX++) {
|
for (int innerX = 0; innerX < symbolWidth; innerX++) {
|
||||||
if (symbols[index][innerY][innerX]) {
|
if (symbols[index][innerY][innerX]) {
|
||||||
|
|||||||
@ -8,6 +8,14 @@
|
|||||||
#include "Rest.h"
|
#include "Rest.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
|
#define DEC_MIL ( 100 )
|
||||||
|
#define SEC_MIL ( 1000 )
|
||||||
|
#define MIN_MIL ( 60 * SEC_MIL )
|
||||||
|
#define HOU_MIL ( 60 * MIN_MIL )
|
||||||
|
#define DAY_MIL ( 24 * HOU_MIL )
|
||||||
|
|
||||||
|
#define ENABLE_DECIS false
|
||||||
|
|
||||||
enum Stage {
|
enum Stage {
|
||||||
FIRST_HALF, SECOND_HALF, LAST_MINUTE, FINALE
|
FIRST_HALF, SECOND_HALF, LAST_MINUTE, FINALE
|
||||||
};
|
};
|
||||||
@ -69,7 +77,6 @@ class ModeTimer final : public Mode {
|
|||||||
Rest last{0};
|
Rest last{0};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit ModeTimer()
|
explicit ModeTimer()
|
||||||
: Mode("Timer"),
|
: Mode("Timer"),
|
||||||
countdown("countdown", [this]() {
|
countdown("countdown", [this]() {
|
||||||
@ -127,6 +134,7 @@ public:
|
|||||||
}
|
}
|
||||||
if (!countdown.isRunning()) {
|
if (!countdown.isRunning()) {
|
||||||
init();
|
init();
|
||||||
|
doBeep(1);
|
||||||
countdown.start();
|
countdown.start();
|
||||||
} else {
|
} else {
|
||||||
pause.toggle();
|
pause.toggle();
|
||||||
@ -140,7 +148,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void draw(Display &display) override {
|
void draw(Display &display) override {
|
||||||
rest = Rest(countdown.getRestMillis());
|
if (countdown.getRestMillis() >= DAY_MIL) {
|
||||||
|
rest = Rest(intCeilDiv(countdown.getRestMillis(), HOU_MIL) * HOU_MIL);
|
||||||
|
} else if (countdown.getRestMillis() >= MIN_MIL) {
|
||||||
|
rest = Rest(intCeilDiv(countdown.getRestMillis(), SEC_MIL) * SEC_MIL);
|
||||||
|
} else {
|
||||||
|
#if ENABLE_DECIS
|
||||||
|
rest = Rest(intCeilDiv(countdown.getRestMillis(), DEC_MIL) * DEC_MIL);
|
||||||
|
#else
|
||||||
|
rest = Rest(intCeilDiv(countdown.getRestMillis(), SEC_MIL) * SEC_MIL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
display.clear();
|
display.clear();
|
||||||
if (flash.isRunning()) {
|
if (flash.isRunning()) {
|
||||||
@ -174,7 +192,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void doBeep(const uint32_t count) {
|
void doBeep(const uint32_t count) {
|
||||||
beepSet(true);
|
beepSet(true);
|
||||||
beep.startCount(count * 2 - 1);
|
beep.startCount(count * 2 - 1);
|
||||||
@ -215,7 +232,8 @@ private:
|
|||||||
dirty |= rest.hourChanged(last);
|
dirty |= rest.hourChanged(last);
|
||||||
dirtyPrint = true;
|
dirtyPrint = true;
|
||||||
} else if (rest.hoursTotal > 0) {
|
} else if (rest.hoursTotal > 0) {
|
||||||
display.print(16, 0, ALIGN_CENTER, FONT7, color, "%d:%02d:%02d", rest.hoursPart, rest.minutesPart, rest.secondsPart);
|
display.print(16, 0, ALIGN_CENTER, FONT7, color, "%d:%02d:%02d", rest.hoursPart, rest.minutesPart,
|
||||||
|
rest.secondsPart);
|
||||||
dirty |= rest.secondChanged(last);
|
dirty |= rest.secondChanged(last);
|
||||||
dirtyPrint = true;
|
dirtyPrint = true;
|
||||||
} else if (rest.minutesTotal > 0) {
|
} else if (rest.minutesTotal > 0) {
|
||||||
@ -223,7 +241,15 @@ private:
|
|||||||
dirty |= rest.secondChanged(last);
|
dirty |= rest.secondChanged(last);
|
||||||
dirtyPrint = true;
|
dirtyPrint = true;
|
||||||
} else {
|
} else {
|
||||||
|
#if ENABLE_DECIS
|
||||||
display.print(16, 0, ALIGN_CENTER, FONT7, color, "%d.%d", rest.secondsPart, rest.decisPart);
|
display.print(16, 0, ALIGN_CENTER, FONT7, color, "%d.%d", rest.secondsPart, rest.decisPart);
|
||||||
|
#else
|
||||||
|
if (rest.secondsTotal > 9) {
|
||||||
|
display.print(16, 0, ALIGN_CENTER, FONT7, color, "%d", rest.secondsPart, rest.secondsPart);
|
||||||
|
} else {
|
||||||
|
display.print(16, 0, ALIGN_CENTER, FONT7, color, "%d %d %d", rest.secondsPart, rest.secondsPart, rest.secondsPart);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
dirty |= rest.deciChanged(last);
|
dirty |= rest.deciChanged(last);
|
||||||
dirtyPrint |= rest.secondChanged(last);
|
dirtyPrint |= rest.secondChanged(last);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,13 @@
|
|||||||
#ifndef REST_H
|
#ifndef REST_H
|
||||||
#define REST_H
|
#define REST_H
|
||||||
|
|
||||||
|
inline uint32_t intCeilDiv(const uint32_t dividend, const uint32_t divisor) {
|
||||||
|
if (dividend == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (dividend + divisor - 1) / divisor;
|
||||||
|
}
|
||||||
|
|
||||||
struct Rest {
|
struct Rest {
|
||||||
|
|
||||||
uint64_t millisTotal;
|
uint64_t millisTotal;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user