67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
#include "info_view.h"
|
|
|
|
#include <Arduino.h>
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <GxEPD2_4G.h> // nur für die Farbwerte GxEPD_WHITE … GxEPD_BLACK
|
|
|
|
namespace {
|
|
|
|
// __DATE__ ("Oct 4 2026") als "04.10.2026"
|
|
void buildDate(char* buffer, size_t size) {
|
|
static const char MONTHS[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
|
const char* date = __DATE__;
|
|
char month[4] = {date[0], date[1], date[2], '\0'};
|
|
int monthNumber = (strstr(MONTHS, month) - MONTHS) / 3 + 1;
|
|
snprintf(buffer, size, "%02d.%02d.%s", atoi(date + 4), monthNumber, date + 7);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void drawInfo(Adafruit_GFX& gfx, const StatusInfo& status) {
|
|
U8G2_FOR_ADAFRUIT_GFX fonts;
|
|
fonts.begin(gfx);
|
|
char text[40];
|
|
|
|
gfx.fillScreen(GxEPD_WHITE);
|
|
|
|
fonts.setForegroundColor(GxEPD_BLACK);
|
|
useFont(fonts, u8g2_font_helvB14_tf);
|
|
fonts.drawUTF8(6, 24, "esticky");
|
|
|
|
fonts.setForegroundColor(GxEPD_DARKGREY);
|
|
useFont(fonts, u8g2_font_helvR08_tf);
|
|
char date[12];
|
|
buildDate(date, sizeof(date));
|
|
snprintf(text, sizeof(text), "Firmware vom %s", date);
|
|
fonts.drawUTF8(gfx.width() - 6 - fonts.getUTF8Width(text), 24, text);
|
|
|
|
fonts.setForegroundColor(GxEPD_BLACK);
|
|
useFont(fonts, u8g2_font_helvR10_tf);
|
|
fonts.drawUTF8(6, 52, "Taste kurz: nächste App");
|
|
fonts.drawUTF8(6, 72, "Taste lang (2 s): Neustart");
|
|
|
|
if (!isnan(status.batteryVoltage)) {
|
|
snprintf(text, sizeof(text), "Akku %.2f V", status.batteryVoltage);
|
|
*strchr(text, '.') = ',';
|
|
fonts.drawUTF8(6, 98, text);
|
|
}
|
|
|
|
drawStatusBar(gfx, fonts, "Info", status);
|
|
}
|
|
|
|
void drawMessage(Adafruit_GFX& gfx, const char* title, const char* text, const StatusInfo& status) {
|
|
U8G2_FOR_ADAFRUIT_GFX fonts;
|
|
fonts.begin(gfx);
|
|
|
|
gfx.fillScreen(GxEPD_WHITE);
|
|
fonts.setForegroundColor(GxEPD_BLACK);
|
|
useFont(fonts, u8g2_font_helvB14_tf);
|
|
fonts.drawUTF8(6, 40, title);
|
|
useFont(fonts, u8g2_font_helvR10_tf);
|
|
fonts.drawUTF8(6, 70, text);
|
|
|
|
drawStatusBar(gfx, fonts, title, status);
|
|
}
|