initial commit [141.14.129.234,mike]

This commit is contained in:
mike committed 2026-10-13 19:55:01 +02:00
commit 80dedb840f
22 files changed
+1723

No files matched your search

+101
View File
@@ -0,0 +1,101 @@
// Blätter-Test: Notizen mit der BOOT-Taste durchschalten, Display per Teil-Refresh (ohne Flackern).
// Teil-Refresh hinterlässt Reste und blassere Schrift, daher folgt nach kurzer Pause ein Voll-Refresh.
// Hardware wie display_test: XIAO ESP32-C3 + Waveshare 2.9" e-Paper Module Rev2.1.
// Verkabelung: VCC+PWR→3V3, GND→GND, DIN→D10, CLK→D8, CS→D1, DC→D2, RST→D5, BUSY→D4.
#include <SPI.h>
#include <GxEPD2_BW.h>
#include <Fonts/FreeSansBold12pt7b.h>
#include <Fonts/FreeSans9pt7b.h>
GxEPD2_BW<GxEPD2_290_T94_V2, GxEPD2_290_T94_V2::HEIGHT> display(
GxEPD2_290_T94_V2(/*CS=*/D1, /*DC=*/D2, /*RST=*/D5, /*BUSY=*/D4));
const int BOOT_BUTTON_PIN = 9; // BOOT-Taste auf der Platine, gedrückt = LOW
const unsigned long CLEANUP_DELAY_MS = 3000; // Pause nach dem letzten Umblättern bis zum Voll-Refresh
struct Note {
const char* title;
const char* lines[3];
};
const Note NOTES[] = {
{"Einkaufen", {"Milch, Brot, Kaffee", "Tomaten, Basilikum", "Batterien AAA"}},
{"Termine", {"Di 10:30 Zahnarzt", "Do 18:00 Sport", "Sa Geburtstag Anna"}},
{"Idee", {"Notizen per WLAN", "aufs Display schicken", ""}},
{"Bedienung", {"BOOT-Taste: weiter", "Teil-Refresh ohne", "Flackern"}},
};
const int NOTE_COUNT = sizeof(NOTES) / sizeof(NOTES[0]);
int currentNote = 0;
void drawNote(int index) {
const Note& note = NOTES[index];
display.firstPage();
do {
display.fillScreen(GxEPD_WHITE);
display.setFont(&FreeSansBold12pt7b);
display.setCursor(10, 26);
display.print(note.title);
char page[8];
snprintf(page, sizeof(page), "%d/%d", index + 1, NOTE_COUNT);
display.setFont(&FreeSans9pt7b);
int16_t x, y;
uint16_t w, h;
display.getTextBounds(page, 0, 0, &x, &y, &w, &h);
display.setCursor(display.width() - w - 10, 24);
display.print(page);
display.drawFastHLine(10, 34, display.width() - 20, GxEPD_BLACK);
for (int i = 0; i < 3; i++) {
display.setCursor(10, 60 + i * 24);
display.print(note.lines[i]);
}
} while (display.nextPage());
}
void showNote(bool fullRefresh) {
if (fullRefresh) {
display.setFullWindow();
} else {
display.setPartialWindow(0, 0, display.width(), display.height());
}
unsigned long start = millis();
drawNote(currentNote);
display.powerOff();
Serial.printf("Notiz %d/%d (%s, %lu ms)\n", currentNote + 1, NOTE_COUNT,
fullRefresh ? "Voll-Refresh" : "Teil-Refresh", millis() - start);
}
void setup() {
SPI.begin(SCK, -1, MOSI, -1); // ohne MISO, damit GPIO9 für die BOOT-Taste frei bleibt
display.init(115200, true, 2, false);
display.setRotation(1); // Querformat 296x128
display.setTextColor(GxEPD_BLACK);
pinMode(BOOT_BUTTON_PIN, INPUT_PULLUP);
showNote(true);
}
void loop() {
static bool wasPressed = false;
static bool needsCleanup = false;
static unsigned long lastFlip = 0;
bool pressed = digitalRead(BOOT_BUTTON_PIN) == LOW;
if (pressed && !wasPressed) {
currentNote = (currentNote + 1) % NOTE_COUNT;
showNote(false);
needsCleanup = true;
lastFlip = millis();
}
if (needsCleanup && millis() - lastFlip > CLEANUP_DELAY_MS) {
showNote(true);
needsCleanup = false;
}
wasPressed = pressed;
delay(20); // einfache Entprellung
}