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