Setup LCD class to use global config instead of local reference
This commit is contained in:
parent
7f60a42f9b
commit
b8dd067ecb
|
@ -22,7 +22,7 @@ UI::UI() {
|
||||||
cancelButton = new UIButton(cancelButtonPin, cancelButtonLed);
|
cancelButton = new UIButton(cancelButtonPin, cancelButtonLed);
|
||||||
pspJoystick = new UIJoystickPSP(pspXPin, pspYPin);
|
pspJoystick = new UIJoystickPSP(pspXPin, pspYPin);
|
||||||
|
|
||||||
lcd = new UILCD(config);
|
lcd = new UILCD();
|
||||||
|
|
||||||
uiTimeout = new Metro(config->getTimeoutMilis());
|
uiTimeout = new Metro(config->getTimeoutMilis());
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,12 @@
|
||||||
#include "UILCD.h"
|
#include "UILCD.h"
|
||||||
#include "UIJoystickPSP.h"
|
#include "UIJoystickPSP.h"
|
||||||
|
|
||||||
UILCD::UILCD(Config* config) {
|
UILCD::UILCD() {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Serial.println("UILCD::UILCD()");
|
Serial.println("UILCD::UILCD()");
|
||||||
}
|
}
|
||||||
pinMode(LCD_LITE, OUTPUT);
|
pinMode(LCD_LITE, OUTPUT);
|
||||||
|
|
||||||
this->config = config;
|
|
||||||
|
|
||||||
tft = new Adafruit_ST7735(LCD_CS, LCD_DC, LCD_RST);
|
tft = new Adafruit_ST7735(LCD_CS, LCD_DC, LCD_RST);
|
||||||
tft->initR(INITR_BLACKTAB);
|
tft->initR(INITR_BLACKTAB);
|
||||||
tft->setRotation(3);
|
tft->setRotation(3);
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
// Forward declaration of Config
|
// Forward declaration of Config
|
||||||
class Config;
|
class Config;
|
||||||
|
|
||||||
|
// Use global config and ui objects defined / initialized in main ino file
|
||||||
|
extern Config* config;
|
||||||
|
|
||||||
#define BUFFPIXEL 20
|
#define BUFFPIXEL 20
|
||||||
|
|
||||||
enum screen {
|
enum screen {
|
||||||
|
@ -39,7 +42,6 @@ enum screen {
|
||||||
class UILCD {
|
class UILCD {
|
||||||
private:
|
private:
|
||||||
Adafruit_ST7735* tft;
|
Adafruit_ST7735* tft;
|
||||||
Config* config;
|
|
||||||
|
|
||||||
int currentLine;
|
int currentLine;
|
||||||
screen currentScreen;
|
screen currentScreen;
|
||||||
|
@ -61,7 +63,7 @@ private:
|
||||||
void mainScreenCancelButton();
|
void mainScreenCancelButton();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UILCD(Config* config);
|
UILCD();
|
||||||
void bmpDraw(char *filename, uint8_t x, uint8_t y);
|
void bmpDraw(char *filename, uint8_t x, uint8_t y);
|
||||||
void handleJoystickEvent(joyDirection aDirection);
|
void handleJoystickEvent(joyDirection aDirection);
|
||||||
void handleOkButtonEvent();
|
void handleOkButtonEvent();
|
||||||
|
|
Reference in a new issue