2023-01-18 21:25:30 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
#pragma once
|
2023-01-17 23:51:53 +01:00
|
|
|
|
2023-12-19 17:26:24 +01:00
|
|
|
#include "Display_Graphic_Diagram.h"
|
2023-03-15 20:20:14 +01:00
|
|
|
#include "defaults.h"
|
2023-11-20 22:02:44 +01:00
|
|
|
#include <TaskSchedulerDeclarations.h>
|
2023-01-17 23:51:53 +01:00
|
|
|
#include <U8g2lib.h>
|
|
|
|
|
|
2024-01-13 11:31:12 +01:00
|
|
|
#define CHART_HEIGHT 20 // chart area hight in pixels
|
|
|
|
|
#define CHART_WIDTH 47 // chart area width in pixels
|
|
|
|
|
|
|
|
|
|
// Left-Upper position of diagram is drawn
|
|
|
|
|
// (text of Y-axis is display left of that pos)
|
|
|
|
|
#define CHART_POSX 80
|
|
|
|
|
#define CHART_POSY 0
|
|
|
|
|
|
2023-01-19 20:12:16 +01:00
|
|
|
enum DisplayType_t {
|
|
|
|
|
None,
|
|
|
|
|
PCD8544,
|
|
|
|
|
SSD1306,
|
|
|
|
|
SH1106,
|
2023-12-30 12:42:42 +01:00
|
|
|
SSD1309,
|
2024-01-26 16:05:56 +01:00
|
|
|
ST7567_GM12864I_59N,
|
2023-12-30 12:42:42 +01:00
|
|
|
DisplayType_Max,
|
2023-01-19 20:12:16 +01:00
|
|
|
};
|
|
|
|
|
|
2024-01-08 14:19:26 +01:00
|
|
|
enum DiagramMode_t {
|
|
|
|
|
Off,
|
|
|
|
|
Small,
|
2024-01-13 11:31:12 +01:00
|
|
|
Fullscreen,
|
2024-01-08 14:19:26 +01:00
|
|
|
DisplayMode_Max,
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-17 23:51:53 +01:00
|
|
|
class DisplayGraphicClass {
|
|
|
|
|
public:
|
|
|
|
|
DisplayGraphicClass();
|
|
|
|
|
~DisplayGraphicClass();
|
|
|
|
|
|
2025-02-08 00:41:16 +01:00
|
|
|
void init(Scheduler& scheduler);
|
2023-12-12 00:21:14 +01:00
|
|
|
void setContrast(const uint8_t contrast);
|
|
|
|
|
void setStatus(const bool turnOn);
|
|
|
|
|
void setOrientation(const uint8_t rotation = DISPLAY_ROTATION);
|
2024-10-25 21:29:15 +02:00
|
|
|
void setLocale(const String& locale);
|
2024-01-08 14:19:26 +01:00
|
|
|
void setDiagramMode(DiagramMode_t mode);
|
2023-03-15 20:20:14 +01:00
|
|
|
void setStartupDisplay();
|
2023-01-17 23:51:53 +01:00
|
|
|
|
2023-12-19 17:26:24 +01:00
|
|
|
DisplayGraphicDiagramClass& Diagram();
|
|
|
|
|
|
2023-01-19 22:43:36 +01:00
|
|
|
bool enablePowerSafe = true;
|
2023-01-19 23:10:41 +01:00
|
|
|
bool enableScreensaver = true;
|
2023-01-17 23:51:53 +01:00
|
|
|
|
|
|
|
|
private:
|
2023-11-20 22:02:44 +01:00
|
|
|
void loop();
|
2023-12-12 00:21:14 +01:00
|
|
|
void printText(const char* text, const uint8_t line);
|
2023-03-15 20:20:14 +01:00
|
|
|
void calcLineHeights();
|
2023-12-12 00:21:14 +01:00
|
|
|
void setFont(const uint8_t line);
|
2023-12-30 12:42:42 +01:00
|
|
|
bool isValidDisplay();
|
2023-01-17 23:51:53 +01:00
|
|
|
|
2023-11-20 22:02:44 +01:00
|
|
|
Task _loopTask;
|
|
|
|
|
|
2023-01-17 23:51:53 +01:00
|
|
|
U8G2* _display;
|
2023-12-19 17:26:24 +01:00
|
|
|
DisplayGraphicDiagramClass _diagram;
|
2023-01-17 23:51:53 +01:00
|
|
|
|
2023-08-25 16:57:24 +02:00
|
|
|
bool _displayTurnedOn;
|
|
|
|
|
|
2023-01-19 20:12:16 +01:00
|
|
|
DisplayType_t _display_type = DisplayType_t::None;
|
2024-01-08 14:19:26 +01:00
|
|
|
DiagramMode_t _diagram_mode = DiagramMode_t::Off;
|
2024-10-25 21:29:15 +02:00
|
|
|
String _display_language = DISPLAY_LOCALE;
|
2023-01-17 23:51:53 +01:00
|
|
|
uint8_t _mExtra;
|
2024-01-13 11:31:12 +01:00
|
|
|
const uint16_t _period = 1000;
|
|
|
|
|
const uint16_t _interval = 60000; // interval at which to power save (milliseconds)
|
2023-01-17 23:51:53 +01:00
|
|
|
uint32_t _previousMillis = 0;
|
|
|
|
|
char _fmtText[32];
|
2023-03-15 20:20:14 +01:00
|
|
|
bool _isLarge = false;
|
|
|
|
|
uint8_t _lineOffsets[5];
|
2024-10-25 21:29:15 +02:00
|
|
|
|
|
|
|
|
String _i18n_offline;
|
|
|
|
|
String _i18n_yield_today_kwh;
|
|
|
|
|
String _i18n_yield_today_wh;
|
|
|
|
|
String _i18n_date_format;
|
|
|
|
|
String _i18n_current_power_kw;
|
|
|
|
|
String _i18n_current_power_w;
|
|
|
|
|
String _i18n_yield_total_mwh;
|
|
|
|
|
String _i18n_yield_total_kwh;
|
2023-01-17 23:51:53 +01:00
|
|
|
};
|
|
|
|
|
|
2024-01-08 14:19:26 +01:00
|
|
|
extern DisplayGraphicClass Display;
|