Rename from Display Interface to abstract
This commit is contained in:
parent
5731148bf6
commit
305541bc52
6 changed files with 16 additions and 16 deletions
|
@ -1,8 +1,8 @@
|
|||
#include "DisplayInterface.h"
|
||||
|
||||
std::shared_ptr<DisplayInterface> DisplayInterface::mInstance = nullptr;
|
||||
std::shared_ptr<DisplayAbstract> DisplayAbstract::mInstance = nullptr;
|
||||
|
||||
DisplayInterface::DisplayInterface(){
|
||||
DisplayAbstract::DisplayAbstract(){
|
||||
lv_init();
|
||||
|
||||
lv_disp_draw_buf_init(&mdraw_buf, mbufA, mbufB,
|
||||
|
@ -13,7 +13,7 @@ DisplayInterface::DisplayInterface(){
|
|||
lv_disp_drv_init(&disp_drv);
|
||||
disp_drv.hor_res = SCREEN_WIDTH;
|
||||
disp_drv.ver_res = SCREEN_HEIGHT;
|
||||
disp_drv.flush_cb = &DisplayInterface::flushDisplayImpl;
|
||||
disp_drv.flush_cb = &DisplayAbstract::flushDisplayImpl;
|
||||
disp_drv.draw_buf = &mdraw_buf;
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
|
@ -21,15 +21,15 @@ DisplayInterface::DisplayInterface(){
|
|||
static lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = &DisplayInterface::screenInputImpl;
|
||||
indev_drv.read_cb = &DisplayAbstract::screenInputImpl;
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
|
||||
}
|
||||
|
||||
void DisplayInterface::flushDisplayImpl(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) {
|
||||
void DisplayAbstract::flushDisplayImpl(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) {
|
||||
mInstance->flushDisplay(disp, area, color_p);
|
||||
}
|
||||
|
||||
void DisplayInterface::screenInputImpl(lv_indev_drv_t *indev_driver, lv_indev_data_t *data) {
|
||||
void DisplayAbstract::screenInputImpl(lv_indev_drv_t *indev_driver, lv_indev_data_t *data) {
|
||||
mInstance->screenInput(indev_driver, data);
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
HardwareAbstract::HardwareAbstract(
|
||||
std::shared_ptr<BatteryInterface> aBattery,
|
||||
std::shared_ptr<wifiHandlerInterface> aWifiHandler,
|
||||
std::shared_ptr<DisplayInterface> aDisplay
|
||||
std::shared_ptr<DisplayAbstract> aDisplay
|
||||
)
|
||||
: mBattery(std::move(aBattery)),
|
||||
mWifiHandler(std::move(aWifiHandler)),
|
||||
|
|
|
@ -17,7 +17,7 @@ class HardwareAbstract {
|
|||
public:
|
||||
HardwareAbstract(std::shared_ptr<BatteryInterface> aBattery = nullptr,
|
||||
std::shared_ptr<wifiHandlerInterface> aWifiHandler = nullptr,
|
||||
std::shared_ptr<DisplayInterface> aDisplay = nullptr
|
||||
std::shared_ptr<DisplayAbstract> aDisplay = nullptr
|
||||
);
|
||||
|
||||
struct batteryStatus {
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
private:
|
||||
std::shared_ptr<BatteryInterface> mBattery;
|
||||
std::shared_ptr<wifiHandlerInterface> mWifiHandler;
|
||||
std::shared_ptr<DisplayInterface> mDisplay;
|
||||
std::shared_ptr<DisplayAbstract> mDisplay;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#pragma once
|
||||
#include <memory>
|
||||
#include "lvgl.h"
|
||||
class DisplayInterface
|
||||
class DisplayAbstract
|
||||
{
|
||||
public:
|
||||
DisplayInterface();
|
||||
DisplayAbstract();
|
||||
virtual void setBrightness(uint8_t brightness) = 0;
|
||||
virtual void turnOff() = 0;
|
||||
|
||||
protected:
|
||||
// Set this with a getInstance method in the Child Class
|
||||
static std::shared_ptr<DisplayInterface> mInstance;
|
||||
static std::shared_ptr<DisplayAbstract> mInstance;
|
||||
|
||||
virtual void flushDisplay(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) = 0;
|
||||
virtual void screenInput(lv_indev_drv_t *indev_driver, lv_indev_data_t *data) = 0;
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
std::shared_ptr<Display> Display::getInstance(int& standby_timer)
|
||||
{
|
||||
if (DisplayInterface::mInstance == nullptr)
|
||||
if (DisplayAbstract::mInstance == nullptr)
|
||||
{
|
||||
DisplayInterface::mInstance = std::shared_ptr<Display>(new Display(LCD_EN, LCD_BL, standby_timer));
|
||||
DisplayAbstract::mInstance = std::shared_ptr<Display>(new Display(LCD_EN, LCD_BL, standby_timer));
|
||||
}
|
||||
return std::static_pointer_cast<Display>(mInstance);
|
||||
}
|
||||
|
||||
Display::Display(int backlight_pin, int enable_pin, int& standby_timer): DisplayInterface(),
|
||||
Display::Display(int backlight_pin, int enable_pin, int& standby_timer): DisplayAbstract(),
|
||||
mBacklightPin(backlight_pin),
|
||||
mEnablePin(enable_pin),
|
||||
tft(TFT_eSPI()),
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define DEFAULT_BACKLIGHT_BRIGHTNESS 128
|
||||
|
||||
|
||||
class Display: public DisplayInterface
|
||||
class Display: public DisplayAbstract
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Display> getInstance(int& standby_timer);
|
||||
|
|
Loading…
Add table
Reference in a new issue