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

+75
View File
@@ -0,0 +1,75 @@
// Graustufen-Demo: 4 Stufen (weiß, hellgrau, dunkelgrau, schwarz) mit GxEPD2_4G.
// Hardware: XIAO ESP32-C3 + Waveshare 2.9" e-Paper Module Rev2.1 (Panel GDEM029T94, SSD1680).
// Verkabelung: VCC+PWR→3V3, GND→GND, DIN→D10, CLK→D8, CS→D1, DC→D2, RST→D5, BUSY→D4.
// Graustufen gehen auf diesem Panel nur per Voll-Refresh. GxEPD2_4G nicht zusammen mit
// GxEPD2 im selben Sketch einbinden, beide definieren gleichnamige Treiberklassen.
#include <SPI.h>
#include <GxEPD2_4G_4G.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSansBold9pt7b.h>
GxEPD2_4G_4G<GxEPD2_290_T94, GxEPD2_290_T94::HEIGHT> display(
GxEPD2_290_T94(/*CS=*/D1, /*DC=*/D2, /*RST=*/D5, /*BUSY=*/D4));
struct Shade {
uint16_t color;
uint16_t textColor;
const char* name;
};
const Shade SHADES[] = {
{GxEPD_WHITE, GxEPD_BLACK, "weiss"},
{GxEPD_LIGHTGREY, GxEPD_BLACK, "hell"},
{GxEPD_DARKGREY, GxEPD_WHITE, "dunkel"},
{GxEPD_BLACK, GxEPD_WHITE, "schwarz"},
};
void printCentered(const char* text, int16_t centerX, int16_t baselineY) {
int16_t x, y;
uint16_t w, h;
display.getTextBounds(text, 0, 0, &x, &y, &w, &h);
display.setCursor(centerX - w / 2 - x, baselineY);
display.print(text);
}
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
const int16_t boxW = display.width() / 4;
const int16_t boxH = 64;
display.setFullWindow();
display.firstPage();
do {
display.fillScreen(GxEPD_WHITE);
// obere Hälfte: vier Farbfelder
display.setFont(&FreeSans9pt7b);
for (int i = 0; i < 4; i++) {
display.fillRect(i * boxW, 0, boxW, boxH, SHADES[i].color);
display.setTextColor(SHADES[i].textColor);
printCentered(SHADES[i].name, i * boxW + boxW / 2, boxH / 2 + 6);
}
display.drawRect(0, 0, display.width(), boxH, GxEPD_BLACK); // Rahmen, damit das weiße Feld sichtbar ist
// untere Hälfte: Text in den drei dunklen Stufen
display.setFont(&FreeSansBold9pt7b);
display.setTextColor(GxEPD_BLACK);
display.setCursor(8, 84);
display.print("Schwarzer Text");
display.setTextColor(GxEPD_DARKGREY);
display.setCursor(8, 104);
display.print("Dunkelgrauer Text");
display.setTextColor(GxEPD_LIGHTGREY);
display.setCursor(8, 124);
display.print("Hellgrauer Text");
} while (display.nextPage());
display.hibernate();
Serial.println("Graustufen-Demo angezeigt, Display im Ruhezustand.");
}
void loop() {}