2026-09-23 10:23:58 +02:00
|
|
|
#include "display_ui.h"
|
|
|
|
|
#include <Wire.h>
|
|
|
|
|
#include <U8g2lib.h>
|
|
|
|
|
|
2026-09-23 23:03:07 +02:00
|
|
|
// Bitmaps & Animation-Dateien aus Lopaka
|
|
|
|
|
//#include "Clock.h"
|
|
|
|
|
//#include "Clock.h"
|
|
|
|
|
//#include "fire_flames.h"
|
|
|
|
|
|
|
|
|
|
uint32_t lastDispTime = 0;
|
|
|
|
|
|
|
|
|
|
// Statische Bitmap aus Lopaka
|
|
|
|
|
static const unsigned char image_paint_27_bits[] U8X8_PROGMEM = {
|
|
|
|
|
0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
|
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
|
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
|
|
|
|
|
0x00,0x00,0x01,0x00
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Animations-Zähler
|
|
|
|
|
//static uint8_t fire_flames_frame = 0;
|
|
|
|
|
//static uint8_t Clock_frame = 0;
|
|
|
|
|
|
|
|
|
|
// U8g2-Display-Objekt
|
2026-09-23 10:23:58 +02:00
|
|
|
static U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
|
|
|
|
|
|
|
|
|
|
void initDisplay() {
|
|
|
|
|
Wire.begin(I2C_SDA, I2C_SCL); // SDA, SCL für XIAO ESP32-C6
|
|
|
|
|
Wire.setClock(400000); // 400 kHz Fast Mode
|
|
|
|
|
u8g2.begin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #############################################################
|
2026-09-23 23:03:07 +02:00
|
|
|
// ANIMATIONEN BERECHNEN & ZEICHNEN
|
2026-09-23 10:23:58 +02:00
|
|
|
// #############################################################
|
2026-09-23 23:03:07 +02:00
|
|
|
static void updateAnimations() {
|
|
|
|
|
//fire_flames_frame = (millis() / 77) % 8;
|
|
|
|
|
//Clock_frame = (millis() / 200) % 143;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawAnimation_fire_flames() {
|
|
|
|
|
//u8g2.setDrawColor(1);
|
|
|
|
|
// u8g2.drawXBMP(80, 30, 21, 32, fire_flames_frames[fire_flames_frame]);
|
|
|
|
|
}
|
2026-09-23 10:23:58 +02:00
|
|
|
|
2026-09-23 23:03:07 +02:00
|
|
|
static void drawAnimation_Clock() {
|
|
|
|
|
//u8g2.setDrawColor(1);
|
|
|
|
|
// u8g2.drawXBMP(104, 40, 21, 21, Clock_frames[Clock_frame]);
|
2026-09-23 10:23:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #############################################################
|
2026-09-23 23:03:07 +02:00
|
|
|
// HAUPTANZEIGE
|
2026-09-23 10:23:58 +02:00
|
|
|
// #############################################################
|
2026-09-23 23:03:07 +02:00
|
|
|
static void drawHomeScreen(int currentSpeed, int curH, int curM, bool timeValid, bool timerActive, SystemSettings settings, int curTemp) {
|
|
|
|
|
u8g2.setFontMode(1);
|
|
|
|
|
u8g2.setBitmapMode(1);
|
|
|
|
|
u8g2.setDrawColor(1); // 1 = Weiß (an)
|
2026-09-23 10:23:58 +02:00
|
|
|
|
2026-09-23 23:03:07 +02:00
|
|
|
// 1. Feste Beschriftungen
|
|
|
|
|
u8g2.setFont(u8g2_font_5x7_tr);
|
|
|
|
|
u8g2.drawStr(7, 8, "Geschw");
|
|
|
|
|
u8g2.drawStr(7, 19, "Zeituhr");
|
|
|
|
|
u8g2.drawStr(7, 30, "Temp");
|
|
|
|
|
|
|
|
|
|
// 2. Dynamischer Wert: Geschwindigkeit
|
|
|
|
|
char speedBuf[10];
|
|
|
|
|
snprintf(speedBuf, sizeof(speedBuf), "%d", currentSpeed);
|
|
|
|
|
u8g2.drawStr(51, 8, speedBuf);
|
|
|
|
|
|
|
|
|
|
// 3. Dynamische Zeitschaltuhr: Start- und Endzeit
|
|
|
|
|
char startBuf[8];
|
|
|
|
|
char endBuf[8];
|
|
|
|
|
snprintf(startBuf, sizeof(startBuf), "%02d:%02d", settings.startHour, settings.startMin);
|
|
|
|
|
snprintf(endBuf, sizeof(endBuf), "%02d:%02d", settings.endHour, settings.endMin);
|
|
|
|
|
|
|
|
|
|
u8g2.drawStr(51, 19, startBuf);
|
|
|
|
|
u8g2.drawLine(79, 16, 83, 16); // Bindestrich zwischen Zeiten
|
|
|
|
|
u8g2.drawStr(89, 19, endBuf);
|
|
|
|
|
|
|
|
|
|
// 4. Dynamische Temperatur (Ist & Soll/Max)
|
|
|
|
|
// Hinweis: Hier kannst du später deine reale Sensortemperatur übergeben
|
|
|
|
|
char curTempBuf[10];
|
|
|
|
|
snprintf(curTempBuf, sizeof(curTempBuf), "%d", curTemp);
|
|
|
|
|
u8g2.drawStr(52, 30, curTempBuf);
|
|
|
|
|
u8g2.drawLine(67, 24, 67, 29); // Trennstrich
|
|
|
|
|
|
|
|
|
|
char maxTempBuf[8];
|
|
|
|
|
snprintf(maxTempBuf, sizeof(maxTempBuf), "%d", settings.maxTemp);
|
|
|
|
|
u8g2.drawStr(74, 30, maxTempBuf);
|
|
|
|
|
|
|
|
|
|
// 5. Große aktuelle Uhrzeit unten links
|
|
|
|
|
u8g2.setFont(u8g2_font_6x10_tr);
|
|
|
|
|
char timeBuf[10];
|
|
|
|
|
if (timeValid) {
|
|
|
|
|
snprintf(timeBuf, sizeof(timeBuf), "%02d:%02d", curH, curM);
|
|
|
|
|
} else {
|
|
|
|
|
snprintf(timeBuf, sizeof(timeBuf), "--:--");
|
|
|
|
|
}
|
|
|
|
|
u8g2.drawStr(4, 60, timeBuf);
|
|
|
|
|
|
|
|
|
|
// 6. Lopaka Deko-Bitmap
|
|
|
|
|
u8g2.drawXBMP(28, 4, 16, 26, image_paint_27_bits);
|
|
|
|
|
|
|
|
|
|
// 7. Lopaka Animationen abspielen
|
|
|
|
|
//drawAnimation_fire_flames();
|
|
|
|
|
//drawAnimation_Clock();
|
2026-09-23 10:23:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #############################################################
|
|
|
|
|
// Zeitschaltuhr
|
|
|
|
|
// #############################################################
|
2026-09-23 23:03:07 +02:00
|
|
|
static void drawTimerScreen(TimeEditStep timeEditStep, uint8_t settingIdx, const SystemSettings& settings){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #############################################################
|
|
|
|
|
// EINSTELLUNGSMENÜ
|
|
|
|
|
// #############################################################
|
|
|
|
|
static void drawSettingsScreen(uint8_t settingIdx, TimeEditStep timeEditStep, const SystemSettings& s) {
|
2026-09-23 10:23:58 +02:00
|
|
|
|
2026-09-23 23:03:07 +02:00
|
|
|
if(timeEditStep != EDIT_NONE){
|
|
|
|
|
drawTimerScreen(timeEditStep, settingIdx, s);
|
|
|
|
|
}
|
2026-09-23 10:23:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #############################################################
|
|
|
|
|
// Main Funktion
|
|
|
|
|
// #############################################################
|
|
|
|
|
void updateDisplay(bool inSettings,
|
|
|
|
|
uint8_t settingIdx,
|
|
|
|
|
TimeEditStep editStep,
|
|
|
|
|
const SystemSettings& settings,
|
|
|
|
|
int currentSpeed,
|
2026-09-23 23:03:07 +02:00
|
|
|
int curH, int curM, bool timeValid, int curTemp) {
|
|
|
|
|
if (millis() - lastDispTime >= 50) {
|
|
|
|
|
lastDispTime = millis();
|
2026-09-23 10:23:58 +02:00
|
|
|
|
2026-09-23 23:03:07 +02:00
|
|
|
u8g2.clearBuffer();
|
2026-09-23 10:23:58 +02:00
|
|
|
|
2026-09-23 23:03:07 +02:00
|
|
|
if (inSettings) {
|
|
|
|
|
drawSettingsScreen(settingIdx, editStep, settings);
|
|
|
|
|
}else{
|
|
|
|
|
drawHomeScreen(currentSpeed, curH, curM, timeValid, settings.timerEnabled, settings, curTemp);
|
|
|
|
|
}
|
2026-09-23 10:23:58 +02:00
|
|
|
|
2026-09-23 23:03:07 +02:00
|
|
|
u8g2.sendBuffer();
|
|
|
|
|
}
|
2026-09-23 10:23:58 +02:00
|
|
|
}
|