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,
|
|
|
|
|
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();
|
|
|
|
|
|
2023-12-12 13:26:07 +01:00
|
|
|
void init(Scheduler& scheduler, const DisplayType_t type, const uint8_t data, const uint8_t clk, const uint8_t cs, const uint8_t reset);
|
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);
|
|
|
|
|
void setLanguage(const uint8_t language);
|
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;
|
2023-05-23 18:25:12 +02:00
|
|
|
uint8_t _display_language = DISPLAY_LANGUAGE;
|
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];
|
2023-01-17 23:51:53 +01:00
|
|
|
};
|
|
|
|
|
|
2024-01-08 14:19:26 +01:00
|
|
|
extern DisplayGraphicClass Display;
|