Compare commits

..

No commits in common. "db68ca0a873b76ae3671bcd514ae7ae76a4001e5" and "4fe7d9cb81e1fa2baf5134ed3770e5fb70c6a61a" have entirely different histories.

4 changed files with 13 additions and 46 deletions

View File

@ -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, __},

View File

@ -54,6 +54,7 @@ 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) {
// //
} }
@ -73,7 +74,7 @@ public:
pixels[mapPixel(x, y)] = false; pixels[mapPixel(x, y)] = false;
} }
} }
setBrightness(64); setBrightness(32);
clear(); clear();
show(); show();
} }
@ -85,11 +86,11 @@ public:
} }
void setPixel(const int x, const int y, const Color &color) { void setPixel(const int x, const int y, const Color &color) {
if (x >= 32 || y >= 8) { const auto index = mapPixel(x, y);
Serial.printf("[ERROR] No pixel at (%d, %d) >= %d\n", x, y, 8 * 32); if (index >= 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
@ -154,8 +155,7 @@ 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, int printSymbol(const int x, const int y, const int index, const Color &color, const bool symbols[][symbolHeight][symbolWidth]) {
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]) {

View File

@ -8,14 +8,6 @@
#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
}; };
@ -77,6 +69,7 @@ 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]() {
@ -134,7 +127,6 @@ public:
} }
if (!countdown.isRunning()) { if (!countdown.isRunning()) {
init(); init();
doBeep(1);
countdown.start(); countdown.start();
} else { } else {
pause.toggle(); pause.toggle();
@ -148,17 +140,7 @@ public:
} }
void draw(Display &display) override { void draw(Display &display) override {
if (countdown.getRestMillis() >= DAY_MIL) { rest = Rest(countdown.getRestMillis());
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()) {
@ -192,6 +174,7 @@ 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);
@ -232,8 +215,7 @@ 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, display.print(16, 0, ALIGN_CENTER, FONT7, color, "%d:%02d:%02d", rest.hoursPart, rest.minutesPart, rest.secondsPart);
rest.secondsPart);
dirty |= rest.secondChanged(last); dirty |= rest.secondChanged(last);
dirtyPrint = true; dirtyPrint = true;
} else if (rest.minutesTotal > 0) { } else if (rest.minutesTotal > 0) {
@ -241,15 +223,7 @@ 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);
} }

View File

@ -1,13 +1,6 @@
#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;