Public Access
Restructure ESP32 firmware into modules, fix bugs, add tests
Structure (src/esp32/): - logic/: DisplayController, schedule, power timer, LED pattern; pure C++ - display/: FlipdotFrames and bitmaps - nano_link/: NanoLink (relay, serial, READY, bootloader) and flash bridge - net/: WiFi/OTA/panic window, Home Assistant - config.h with all settings; libs.h (globals in a header) removed Bug fixes: - Home Assistant switches now report their state back and start as ON - loop() no longer blocks: WiFi.waitForConnectResult() (up to 60 s without WiFi) and getLocalTime() (5 s before NTP sync) were called every iteration - Power switch off now powers off after 1 s even when a 30 s countdown is already running - millis() overflow safe power-off timer; no frame catch-up bursts - No garbage time string before NTP sync; 'Connecting...' stays instead - Frames are only sent when the screen changes instead of every second - Reset reasons are logged once instead of every 100 ms - Removed dead code (unused fonts, WiFiMulti, rotated bitmap, ...) Tests: new test_esp32 environment (26 tests); native renamed to test_nano Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cefb76c1ad
commit
683a47c055
29 files changed
+1289
-755
No files matched your search
@@ -0,0 +1,89 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
// 'Nintendo logo', 84x19px
|
||||
const unsigned char nintendo_bitmap_Nintendo_new[] PROGMEM = {
|
||||
0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x67, 0x8e, 0x70, 0x00,
|
||||
0x70, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x60, 0x67, 0x8e, 0x70, 0x00, 0x70, 0x00, 0x00, 0x00, 0x1c,
|
||||
0x00, 0x60, 0xc7, 0x8e, 0x07, 0x39, 0xfc, 0xfc, 0x73, 0x83, 0xdc, 0x7c, 0x30, 0xc7, 0x4e, 0x77,
|
||||
0xfc, 0x71, 0xee, 0x7f, 0xc7, 0xfc, 0xfe, 0x30, 0xc7, 0x6e, 0x77, 0x8e, 0x73, 0xc7, 0x78, 0xef,
|
||||
0x3d, 0xc7, 0x30, 0xc7, 0x2e, 0x77, 0x0e, 0x73, 0xff, 0x70, 0xef, 0x3d, 0xc7, 0x30, 0xc7, 0x3e,
|
||||
0x77, 0x0e, 0x73, 0xc0, 0x70, 0xef, 0x3d, 0xc7, 0x30, 0xc7, 0x1e, 0x77, 0x0e, 0x73, 0xc7, 0x70,
|
||||
0xef, 0x3d, 0xc7, 0x30, 0xc7, 0x0e, 0x77, 0x0e, 0x71, 0xee, 0x70, 0xe7, 0xfc, 0xfe, 0x30, 0x67,
|
||||
0x0e, 0x77, 0x0e, 0x70, 0xfc, 0x70, 0xe3, 0xdc, 0x7c, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
|
||||
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
|
||||
0x00};
|
||||
|
||||
// 'nintendo border', 84x19px
|
||||
const unsigned char nintendo_bitmap_nintendo_border[] PROGMEM = {
|
||||
0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
|
||||
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
|
||||
0x00};
|
||||
|
||||
// 'panda', 17x18px
|
||||
const unsigned char nintendo_bitmap_panda_inverted[] PROGMEM = {
|
||||
0xfe, 0x7f, 0x80, 0xfc, 0x3c, 0x80, 0xfc, 0x38, 0x00, 0xdd, 0xfe, 0x00, 0xbb, 0xff, 0x80, 0x73,
|
||||
0xff, 0x80, 0x77, 0x3f, 0x80, 0x76, 0x33, 0x00, 0x76, 0x73, 0x00, 0x33, 0xfb, 0x00, 0x31, 0x8e,
|
||||
0x00, 0x90, 0xdc, 0x00, 0x80, 0xf0, 0x00, 0x80, 0x00, 0x00, 0xc4, 0x78, 0x80, 0xe4, 0x70, 0x80,
|
||||
0xfe, 0x11, 0x80, 0xff, 0x1f, 0x80};
|
||||
const unsigned char nintendo_bitmap_panda[] PROGMEM = {
|
||||
0x01, 0x80, 0x00, 0x03, 0xc3, 0x00, 0x03, 0xc7, 0x80, 0x22, 0x01, 0x80, 0x44, 0x00, 0x00, 0x8c,
|
||||
0x00, 0x00, 0x88, 0xc0, 0x00, 0x89, 0xcc, 0x80, 0x89, 0x8c, 0x80, 0xcc, 0x04, 0x80, 0xce, 0x71,
|
||||
0x80, 0x6f, 0x23, 0x80, 0x7f, 0x0f, 0x80, 0x7f, 0xff, 0x80, 0x3b, 0x87, 0x00, 0x1b, 0x8f, 0x00,
|
||||
0x01, 0xee, 0x00, 0x00, 0xe0, 0x00};
|
||||
|
||||
// 'yawning_pikachu', 35x19px
|
||||
const unsigned char yawning_pikachu_bitmap_yawning_pikachu [] PROGMEM = {
|
||||
0xff, 0xfc, 0x07, 0xff, 0xe0, 0xff, 0xe3, 0xf8, 0xff, 0xe0, 0xfe, 0x1f, 0xff, 0x0f, 0xe0, 0xf9,
|
||||
0xff, 0xff, 0xf3, 0xe0, 0xe7, 0xff, 0xff, 0xfc, 0xe0, 0xdf, 0x7f, 0xff, 0xdf, 0x60, 0x9f, 0x73,
|
||||
0xf9, 0xdf, 0x20, 0x0c, 0xcf, 0xbe, 0x66, 0x00, 0x02, 0xff, 0xff, 0xe8, 0x00, 0xfe, 0xff, 0x1f,
|
||||
0xef, 0xe0, 0xfd, 0x9e, 0x0f, 0x37, 0xe0, 0xfd, 0x0e, 0xee, 0x17, 0xe0, 0xfd, 0x0e, 0xee, 0x17,
|
||||
0xe0, 0xfd, 0x9e, 0xe3, 0x37, 0xe0, 0xfd, 0xff, 0x0d, 0xf7, 0xe0, 0xfe, 0xff, 0xee, 0xef, 0xe0,
|
||||
0xfe, 0xff, 0xf7, 0x6f, 0xe0, 0xfe, 0x7f, 0xfb, 0x8f, 0xe0, 0xfe, 0xfe, 0x0b, 0xaf, 0xe0
|
||||
};
|
||||
|
||||
// 'yawning_pikachu_black_border', 35x19px
|
||||
const unsigned char yawning_pikachu_bitmap_yawning_pikachu_black_border [] PROGMEM = {
|
||||
0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x01, 0xff, 0xff, 0xf0, 0x00, 0x07,
|
||||
0xff, 0xff, 0xfc, 0x00, 0x1f, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x7f, 0xff, 0xdf, 0x80, 0x7f, 0x73,
|
||||
0xf9, 0xdf, 0xc0, 0xfe, 0xcf, 0xbe, 0x6f, 0xe0, 0xfd, 0xff, 0xff, 0xf7, 0xe0, 0x01, 0xff, 0x1f,
|
||||
0xf0, 0x00, 0x03, 0x9e, 0x0f, 0x38, 0x00, 0x03, 0x0e, 0xee, 0x18, 0x00, 0x03, 0x0e, 0xee, 0x18,
|
||||
0x00, 0x03, 0x9e, 0xe3, 0x38, 0x00, 0x03, 0xff, 0x0d, 0xf8, 0x00, 0x01, 0xff, 0xee, 0xf0, 0x00,
|
||||
0x01, 0xff, 0xf7, 0x70, 0x00, 0x00, 0x7f, 0xfb, 0x80, 0x00, 0x01, 0xfe, 0x0b, 0xb0, 0x00
|
||||
};
|
||||
|
||||
// 'clock thought bubble', 46x19px
|
||||
const unsigned char clock_thought_bubble_bitmap_clock_thought_bubble [] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00,
|
||||
0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40,
|
||||
0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00,
|
||||
0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08, 0x3f,
|
||||
0xff, 0xff, 0xff, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x21, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||
0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00
|
||||
};
|
||||
|
||||
// 'pikachu_black_border', 35x19px
|
||||
const unsigned char pikachu_bitmap_pikachu_black_border [] PROGMEM = {
|
||||
0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x01, 0xff, 0xff, 0xf0, 0x00, 0x07,
|
||||
0xff, 0xff, 0xfc, 0x00, 0x1f, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x73, 0xf9, 0xdf, 0x80, 0x7f, 0x69,
|
||||
0xf4, 0xdf, 0xc0, 0xfe, 0xe1, 0xf0, 0xef, 0xe0, 0xfd, 0xf3, 0xf9, 0xf7, 0xe0, 0x01, 0xff, 0xbf,
|
||||
0xf0, 0x00, 0x03, 0x9f, 0xff, 0x38, 0x00, 0x03, 0x0f, 0xfe, 0x18, 0x00, 0x03, 0x0f, 0xfe, 0x18,
|
||||
0x00, 0x03, 0x9d, 0xb7, 0x38, 0x00, 0x03, 0xfe, 0x4f, 0xf8, 0x00, 0x01, 0xff, 0xff, 0xf0, 0x00,
|
||||
0x01, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xff, 0x80, 0x00, 0x01, 0xfe, 0x0f, 0xf0, 0x00
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "display/frames.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "display/bitmaps.h"
|
||||
#include "logic/schedule.h"
|
||||
|
||||
// Horizontal offset that centers the 81 pixel wide clock on the 84 pixel display
|
||||
static const int CLOCK_X = 3;
|
||||
|
||||
FlipdotFrames::FlipdotFrames(BROSE9323 &display) : _display(display)
|
||||
{
|
||||
}
|
||||
|
||||
void FlipdotFrames::clock(int hour, int minute)
|
||||
{
|
||||
char time[6];
|
||||
snprintf(time, sizeof(time), "%02d:%02d", hour, minute);
|
||||
|
||||
_display.fillScreen(0);
|
||||
if (isEvening(hour))
|
||||
_display.drawBitmap(CLOCK_X, 0, yawning_pikachu_bitmap_yawning_pikachu_black_border, 35, 19, 1);
|
||||
else
|
||||
_display.drawBitmap(CLOCK_X, 0, pikachu_bitmap_pikachu_black_border, 35, 19, 1);
|
||||
_display.drawBitmap(CLOCK_X + 35, 0, clock_thought_bubble_bitmap_clock_thought_bubble, 46, 19, 1);
|
||||
|
||||
_display.setTextSize(1);
|
||||
_display.setTextWrap(false);
|
||||
_display.setCursor(CLOCK_X + 43, 4);
|
||||
_display.print(time);
|
||||
_display.display();
|
||||
}
|
||||
|
||||
void FlipdotFrames::logo()
|
||||
{
|
||||
_display.fillScreen(0);
|
||||
_display.drawBitmap(0, 0, nintendo_bitmap_Nintendo_new, 84, 19, 1);
|
||||
_display.display();
|
||||
}
|
||||
|
||||
void FlipdotFrames::blank()
|
||||
{
|
||||
_display.fillScreen(0);
|
||||
_display.display();
|
||||
}
|
||||
|
||||
void FlipdotFrames::message(const char *text)
|
||||
{
|
||||
_display.fillScreen(0);
|
||||
_display.setTextSize(1);
|
||||
_display.setTextWrap(true);
|
||||
_display.setCursor(0, 0);
|
||||
_display.print(text);
|
||||
_display.display();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "BROSE9323.h"
|
||||
#include "logic/display_controller.h"
|
||||
|
||||
// Draws the screens on the flipdot display. Each method sends one complete frame.
|
||||
class FlipdotFrames : public Frames
|
||||
{
|
||||
public:
|
||||
explicit FlipdotFrames(BROSE9323 &display);
|
||||
|
||||
// Pikachu with a thought bubble showing HH:MM (yawning in the evening)
|
||||
void clock(int hour, int minute) override;
|
||||
// Nintendo logo
|
||||
void logo() override;
|
||||
void blank() override;
|
||||
// A line of text, e.g. while connecting
|
||||
void message(const char *text);
|
||||
|
||||
private:
|
||||
BROSE9323 &_display;
|
||||
};
|
||||
Reference in new issue
Block a user