2021-01-19 22:12:55 +00:00
|
|
|
#ifndef DISPLAY_H_
|
|
|
|
#define DISPLAY_H_
|
|
|
|
|
2021-01-30 21:47:24 +00:00
|
|
|
#include <list>
|
2021-01-19 22:12:55 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <map>
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <Wire.h>
|
2021-01-30 21:47:24 +00:00
|
|
|
#include <TimeLib.h>
|
2021-01-19 22:12:55 +00:00
|
|
|
#include <SSD1306.h>
|
|
|
|
#include <BoardFinder.h>
|
2021-03-12 19:04:51 +00:00
|
|
|
#include <Timer.h>
|
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;
|
|
|
|
|
|
|
|
class DisplayFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DisplayFrame() {}
|
|
|
|
virtual ~DisplayFrame() {}
|
|
|
|
virtual void drawStatusPage(Bitmap & bitmap) = 0;
|
|
|
|
};
|
|
|
|
|
2021-01-19 22:12:55 +00:00
|
|
|
class Display
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static Display & instance()
|
|
|
|
{
|
|
|
|
static Display _instance;
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
~Display() {}
|
|
|
|
|
|
|
|
void setup(std::shared_ptr<BoardConfig> boardConfig);
|
2021-02-10 21:37:18 +00:00
|
|
|
void turn180();
|
2021-01-30 21:47:24 +00:00
|
|
|
void update();
|
2021-01-19 22:12:55 +00:00
|
|
|
|
2021-01-30 21:47:24 +00:00
|
|
|
void addFrame(std::shared_ptr<DisplayFrame> frame);
|
2021-01-19 22:12:55 +00:00
|
|
|
|
2021-01-30 21:47:24 +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-30 21:47:24 +00:00
|
|
|
std::list<std::shared_ptr<DisplayFrame>> _frames;
|
|
|
|
std::shared_ptr<StatusFrame> _statusFrame;
|
2021-03-12 19:04:51 +00:00
|
|
|
Timer _frameTimeout;
|
2021-01-19 22:12:55 +00:00
|
|
|
|
2021-03-12 19:04:51 +00:00
|
|
|
Timer _displayTimeout;
|
|
|
|
bool _displayOff;
|
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
|
|
|
};
|
|
|
|
|
2021-01-30 21:47:24 +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
|