Skip to content

Commit ce70792

Browse files
committed
lgfx_display: better handle display class construction
1 parent 45ab0e8 commit ce70792

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/helpers/ui/LGFXDisplay.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
2-
/*
3-
* Base class for LovyanGFX supported display (works on ESP32 mainly)
4-
* You can extend this class to support your display, providing your own LGFX
5-
*/
6-
71
#pragma once
82

93
#include <helpers/ui/DisplayDriver.h>
@@ -20,11 +14,12 @@ class LGFXDisplay : public DisplayDriver {
2014
LGFX_Device* display;
2115
LGFX_Sprite buffer;
2216

23-
bool _isOn;
17+
bool _isOn = false;
2418
int _color = TFT_WHITE;
2519

2620
public:
27-
LGFXDisplay(int w, int h):DisplayDriver(w/UI_ZOOM, h/UI_ZOOM) {_isOn = false;}
21+
LGFXDisplay(int w, int h, LGFX_Device &disp)
22+
: DisplayDriver(w/UI_ZOOM, h/UI_ZOOM), display(&disp) {}
2823
bool begin();
2924
bool isOn() override { return _isOn; }
3025
void turnOn() override;

variants/sensecap_indicator-espnow/SCIndicatorDisplay.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,5 @@ class LGFX : public lgfx::LGFX_Device
124124
class SCIndicatorDisplay : public LGFXDisplay {
125125
LGFX disp;
126126
public:
127-
SCIndicatorDisplay() : LGFXDisplay(480, 480)
128-
{ display=&disp; }
127+
SCIndicatorDisplay() : LGFXDisplay(480, 480, disp) {}
129128
};

0 commit comments

Comments
 (0)