LoRa_APRS_iGate/lib/Display/Display.h

81 wiersze
1.5 KiB
C
Czysty Zwykły widok Historia

2021-01-19 22:12:55 +00:00
#ifndef DISPLAY_H_
#define DISPLAY_H_
#include <Arduino.h>
#include <BoardFinder.h>
#include <SSD1306.h>
#include <TimeLib.h>
2021-03-12 19:04:51 +00:00
#include <Timer.h>
#include <Wire.h>
#include <list>
#include <map>
#include <memory>
2021-01-19 22:12:55 +00:00
2021-03-12 19:04:51 +00:00
class Timer;
class StatusFrame;
class DisplayFrame {
public:
DisplayFrame() {
}
virtual ~DisplayFrame() {
}
virtual void drawStatusPage(Bitmap &bitmap) = 0;
};
class Display {
2021-01-19 22:12:55 +00:00
public:
static Display &instance() {
static Display _instance;
return _instance;
}
2021-01-19 22:12:55 +00:00
~Display() {
}
2021-01-19 22:12:55 +00:00
void setup(std::shared_ptr<BoardConfig> boardConfig);
void turn180();
2021-03-13 21:45:43 +00:00
void activateDisplaySaveMode();
void setDisplayTimeout(time_t timeout);
void update();
2021-01-19 22:12:55 +00:00
void addFrame(std::shared_ptr<DisplayFrame> frame);
2021-01-19 22:12:55 +00:00
void setStatusFrame(std::shared_ptr<StatusFrame> frame);
void showSpashScreen(String firmwareTitle, String version);
2021-01-19 22:12:55 +00:00
private:
std::shared_ptr<OLEDDisplay> _disp;
2021-01-19 22:12:55 +00:00
std::list<std::shared_ptr<DisplayFrame>> _frames;
std::shared_ptr<StatusFrame> _statusFrame;
Timer _frameTimeout;
2021-01-19 22:12:55 +00:00
Timer _displayTimeout;
bool _displayOff;
2021-03-13 21:45:43 +00:00
bool _displaySaveMode;
2021-01-19 22:12:55 +00:00
Display();
Display(const Display &);
Display &operator=(const Display &);
2021-03-12 19:04:51 +00:00
void activateDisplay();
void deactivateDisplay();
2021-01-19 22:12:55 +00:00
};
class TextFrame : public DisplayFrame {
public:
TextFrame(String header, String text) : _header(header), _text(text) {
}
virtual ~TextFrame() {
}
void drawStatusPage(Bitmap &bitmap) override;
private:
String _header;
String _text;
};
2021-01-19 22:12:55 +00:00
#endif