Code improvements: commonData, config and logger in page class
This commit is contained in:
parent
15ca3614ba
commit
1ada6e5a82
|
@ -19,8 +19,6 @@
|
|||
class PageAIS : public Page
|
||||
{
|
||||
private:
|
||||
GwConfigHandler *config;
|
||||
GwLog *logger;
|
||||
bool simulation = false;
|
||||
bool holdvalues = false;
|
||||
String flashLED;
|
||||
|
@ -84,11 +82,8 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
PageAIS(CommonData &common)
|
||||
PageAIS(CommonData &common) : Page(common)
|
||||
{
|
||||
commonData = &common;
|
||||
config = commonData->config;
|
||||
logger = commonData->logger;
|
||||
logger->logDebug(GwLog::LOG,"Instantiate PageAIS");
|
||||
|
||||
// preload configuration data
|
||||
|
|
|
@ -51,8 +51,6 @@ static unsigned char anchor_bits[] = {
|
|||
class PageAnchor : public Page
|
||||
{
|
||||
private:
|
||||
GwConfigHandler *config;
|
||||
GwLog *logger;
|
||||
bool simulation = false;
|
||||
bool holdvalues = false;
|
||||
String flashLED;
|
||||
|
@ -244,11 +242,8 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
PageAnchor(CommonData &common)
|
||||
PageAnchor(CommonData &common) : Page(common)
|
||||
{
|
||||
commonData = &common;
|
||||
config = commonData->config;
|
||||
logger = commonData->logger;
|
||||
logger->logDebug(GwLog::LOG,"Instantiate PageAnchor");
|
||||
|
||||
// preload configuration data
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
class PageAutopilot : public Page
|
||||
{
|
||||
private:
|
||||
GwConfigHandler *config;
|
||||
GwLog *logger;
|
||||
bool simulation = false;
|
||||
bool holdvalues = false;
|
||||
String flashLED;
|
||||
|
@ -48,11 +46,8 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
PageAutopilot(CommonData &common)
|
||||
PageAutopilot(CommonData &common) : Page(common)
|
||||
{
|
||||
commonData = &common;
|
||||
config = commonData->config;
|
||||
logger = commonData->logger;
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageAutopilot");
|
||||
|
||||
// preload configuration data
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
class PageBME280 : public Page
|
||||
{
|
||||
public:
|
||||
PageBME280(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageBME280");
|
||||
PageBME280(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG,"Instantiate PageBME280");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
|
@ -22,8 +22,6 @@ class PageBME280 : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
double value1 = 0;
|
||||
double value2 = 0;
|
||||
|
|
|
@ -9,9 +9,9 @@ class PageBattery : public Page
|
|||
int average = 0; // Average type [0...3], 0=off, 1=10s, 2=60s, 3=300s
|
||||
|
||||
public:
|
||||
PageBattery(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageBattery");
|
||||
PageBattery(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageBattery");
|
||||
}
|
||||
|
||||
virtual void setupKeys(){
|
||||
|
@ -36,8 +36,6 @@ class PageBattery : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
double value1 = 0;
|
||||
|
|
|
@ -13,17 +13,17 @@ bool trend = true; // Trend indicator [0|1], 0=off, 1=on
|
|||
double raw = 0;
|
||||
|
||||
public:
|
||||
PageBattery2(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageBattery2");
|
||||
PageBattery2(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageBattery2");
|
||||
}
|
||||
|
||||
virtual void setupKeys(){
|
||||
void setupKeys(){
|
||||
Page::setupKeys();
|
||||
commonData->keydata[0].label = "AVG";
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key) {
|
||||
// Change average
|
||||
if(key == 1){
|
||||
average ++;
|
||||
|
@ -45,11 +45,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
// Polynominal coefficients second order for battery energy level calculation
|
||||
// index 0 = Pb, 1 = Gel, 2 = AGM, 3 = LiFePo4
|
||||
float x0[4] = {+3082.5178, +1656.1571, +1316.8766, +14986.9336}; // Offset
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
class PageClock : public Page
|
||||
{
|
||||
private:
|
||||
bool simulation = false;
|
||||
int simtime;
|
||||
bool keylock = false;
|
||||
|
@ -29,22 +30,22 @@ double homelon;
|
|||
bool homevalid = false; // homelat and homelon are valid
|
||||
|
||||
public:
|
||||
PageClock(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageClock");
|
||||
PageClock(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageClock");
|
||||
|
||||
// WIP time source
|
||||
#ifdef BOARD_OBP60S3
|
||||
String use_rtc = common.config->getString(common.config->useRTC);
|
||||
String use_rtc = config->getString(config->useRTC);
|
||||
if (use_rtc == "off") {
|
||||
source = 'G';
|
||||
}
|
||||
#endif
|
||||
|
||||
simulation = common.config->getBool(common.config->useSimuData);
|
||||
timezone = common.config->getString(common.config->timeZone).toDouble();
|
||||
homelat = common.config->getString(common.config->homeLAT).toDouble();
|
||||
homelon = common.config->getString(common.config->homeLON).toDouble();
|
||||
simulation = config->getBool(config->useSimuData);
|
||||
timezone = config->getString(config->timeZone).toDouble();
|
||||
homelat = config->getString(config->homeLAT).toDouble();
|
||||
homelon = config->getString(config->homeLON).toDouble();
|
||||
homevalid = homelat >= -180.0 and homelat <= 180 and homelon >= -90.0 and homelon <= 90.0;
|
||||
simtime = 38160; // time value 11:36
|
||||
}
|
||||
|
@ -97,9 +98,6 @@ bool homevalid = false; // homelat and homelon are valid
|
|||
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
static String svalue1old = "";
|
||||
static String unit1old = "";
|
||||
static String svalue2old = "";
|
||||
|
|
|
@ -29,9 +29,9 @@ class PageCompass : public Page
|
|||
int WhichDataDisplay = ShowHDM;
|
||||
|
||||
public:
|
||||
PageCompass(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageCompass");
|
||||
PageCompass(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageCompass");
|
||||
}
|
||||
|
||||
virtual void setupKeys(){
|
||||
|
@ -63,8 +63,6 @@ class PageCompass : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static String OldDataText[HowManyValues] = {"", "", "","", "", ""};
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
class PageDST810 : public Page
|
||||
{
|
||||
public:
|
||||
PageDST810(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageDST810");
|
||||
PageDST810(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageDST810");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
|
@ -22,8 +22,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static String svalue1old = "";
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
class PageEPropulsion : public Page
|
||||
{
|
||||
private:
|
||||
GwConfigHandler *config;
|
||||
GwLog *logger;
|
||||
bool simulation = false;
|
||||
bool holdvalues = false;
|
||||
String flashLED;
|
||||
|
@ -48,11 +46,8 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
PageEPropulsion(CommonData &common)
|
||||
PageEPropulsion(CommonData &common) : Page(common)
|
||||
{
|
||||
commonData = &common;
|
||||
config = commonData->config;
|
||||
logger = commonData->logger;
|
||||
logger->logDebug(GwLog::LOG,"Instantiate PageEPropulsion");
|
||||
|
||||
// preload configuration data
|
||||
|
|
|
@ -75,11 +75,11 @@ class PageFluid : public Page
|
|||
int fluidtype;
|
||||
|
||||
public:
|
||||
PageFluid(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageFluid");
|
||||
simulation = common.config->getBool(common.config->useSimuData);
|
||||
holdvalues = common.config->getBool(common.config->holdvalues);
|
||||
PageFluid(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG,"Instantiate PageFluid");
|
||||
simulation = config->getBool(config->useSimuData);
|
||||
holdvalues = config->getBool(config->holdvalues);
|
||||
simval = double(random(0, 100));
|
||||
simgoto = double(random(0, 100));
|
||||
simstep = (simgoto - simval) / 20.0;
|
||||
|
@ -95,13 +95,11 @@ class PageFluid : public Page
|
|||
}
|
||||
|
||||
virtual void displayNew(PageData &pageData){
|
||||
fluidtype = commonData->config->getInt("page" + String(pageData.pageNumber) + "fluid", 0);
|
||||
commonData->logger->logDebug(GwLog::LOG,"New PageFluid: fluidtype=%d", fluidtype);
|
||||
fluidtype = config->getInt("page" + String(pageData.pageNumber) + "fluid", 0);
|
||||
logger->logDebug(GwLog::LOG, "New PageFluid: fluidtype=%d", fluidtype);
|
||||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static double value1old;
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
class PageFourValues : public Page
|
||||
{
|
||||
public:
|
||||
PageFourValues(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageFourValues");
|
||||
PageFourValues(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageFourValues");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -23,8 +23,6 @@ class PageFourValues : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static String svalue1old = "";
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
class PageFourValues2 : public Page
|
||||
{
|
||||
public:
|
||||
PageFourValues2(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageFourValues2");
|
||||
PageFourValues2(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG,"Instantiate PageFourValues2");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
|
@ -23,8 +23,6 @@ class PageFourValues2 : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static String svalue1old = "";
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
class PageGenerator : public Page
|
||||
{
|
||||
public:
|
||||
PageGenerator(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageGenerator");
|
||||
PageGenerator(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageGenerator");
|
||||
}
|
||||
virtual int handleKey(int key){
|
||||
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -21,10 +22,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
int displayPage(PageData &pageData) {
|
||||
|
||||
// Get config data
|
||||
bool simulation = config->getBool(config->useSimuData);
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
class PageKeelPosition : public Page
|
||||
{
|
||||
public:
|
||||
PageKeelPosition(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageKeelPosition");
|
||||
PageKeelPosition(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageKeelPosition");
|
||||
}
|
||||
|
||||
// Key functions
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -22,10 +22,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
int displayPage(PageData &pageData) {
|
||||
|
||||
double value1 = 0;
|
||||
double value1old = 0;
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
class PageOneValue : public Page
|
||||
{
|
||||
public:
|
||||
PageOneValue(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageOneValue");
|
||||
PageOneValue(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageOneValue");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key) {
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -23,8 +23,6 @@ class PageOneValue : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static String svalue1old = "";
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
class PageRollPitch : public Page
|
||||
{
|
||||
public:
|
||||
PageRollPitch(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageRollPitch");
|
||||
PageRollPitch(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageRollPitch");
|
||||
}
|
||||
|
||||
// Key functions
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -23,8 +23,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
double value1 = 0;
|
||||
double value2 = 0;
|
||||
|
@ -33,7 +31,6 @@ public:
|
|||
String svalue2 = "";
|
||||
String svalue2old = "";
|
||||
|
||||
|
||||
// Get config data
|
||||
String lengthformat = config->getString(config->lengthFormat);
|
||||
bool simulation = config->getBool(config->useSimuData);
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
class PageRudderPosition : public Page
|
||||
{
|
||||
public:
|
||||
PageRudderPosition(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Show PageRudderPosition");
|
||||
PageRudderPosition(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Show PageRudderPosition");
|
||||
}
|
||||
|
||||
// Key functions
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -24,8 +24,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
static String unit1old = "";
|
||||
double value1 = 0.1;
|
||||
|
|
|
@ -16,9 +16,9 @@ const int HowManyValues = 6;
|
|||
class PageSixValues : public Page
|
||||
{
|
||||
public:
|
||||
PageSixValues(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageSixValues");
|
||||
PageSixValues(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageSixValues");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
|
@ -31,9 +31,6 @@ class PageSixValues : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
|
||||
// Old values for hold function
|
||||
static String OldDataText[HowManyValues] = {"", "", "", "", "", ""};
|
||||
|
@ -102,8 +99,7 @@ class PageSixValues : public Page
|
|||
epd->setCursor(x0, y0+72);
|
||||
if (holdvalues == false) {
|
||||
epd->print(DataUnits[ValueIndex]); // Unit
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
epd->print(OldDataUnits[ValueIndex]);
|
||||
}
|
||||
|
||||
|
@ -128,32 +124,33 @@ class PageSixValues : public Page
|
|||
}
|
||||
else {
|
||||
epd->setFont(&DSEG7Classic_BoldItalic26pt7b);
|
||||
if ( DataText[ValueIndex][0] == '-' )
|
||||
if (DataText[ValueIndex][0] == '-' ) {
|
||||
epd->setCursor(x0+25, y0+70);
|
||||
else
|
||||
} else {
|
||||
epd->setCursor(x0+65, y0+70);
|
||||
}
|
||||
}
|
||||
|
||||
// Show bus data
|
||||
if (holdvalues == false) {
|
||||
epd->print(DataText[ValueIndex]); // Real value as formated string
|
||||
}
|
||||
else{
|
||||
} else{
|
||||
epd->print(OldDataText[ValueIndex]); // Old value as formated string
|
||||
}
|
||||
if (DataValid[ValueIndex] == true) {
|
||||
OldDataText[ValueIndex] = DataText[ValueIndex]; // Save the old value
|
||||
OldDataUnits[ValueIndex] = DataUnits[ValueIndex]; // Save the old unit
|
||||
}
|
||||
}
|
||||
} // for j
|
||||
// Vertical line 3 pix
|
||||
epd->fillRect(SixValues_x1+SixValues_DeltaX-8, SixValues_y1+i*SixValues_DeltaY, 3, SixValues_DeltaY, commonData->fgcolor);
|
||||
}
|
||||
} // for i
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
static Page *createPage(CommonData &common){
|
||||
return new PageSixValues(common);
|
||||
}/**
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
class PageSkyView : public Page
|
||||
{
|
||||
public:
|
||||
PageSkyView(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Show PageSkyView");
|
||||
PageSkyView(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG,"Instantiate PageSkyView");
|
||||
}
|
||||
|
||||
int handleKey(int key){
|
||||
|
@ -26,8 +26,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Get config data
|
||||
String flashLED = config->getString(config->flashLED);
|
||||
|
@ -41,7 +39,7 @@ public:
|
|||
}
|
||||
|
||||
// Logging boat values
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageSkyView");
|
||||
logger->logDebug(GwLog::LOG, "Drawing at PageSkyView");
|
||||
|
||||
// Draw page
|
||||
//***********************************************************
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
class PageSolar : public Page
|
||||
{
|
||||
public:
|
||||
PageSolar(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageSolar");
|
||||
PageSolar(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG,"Instantiate PageSolar");
|
||||
}
|
||||
virtual int handleKey(int key){
|
||||
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -22,8 +23,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Get config data
|
||||
bool simulation = config->getBool(config->useSimuData);
|
||||
|
|
|
@ -267,7 +267,7 @@ private:
|
|||
for (int i = 0 ; i < menu->getItemCount(); i++) {
|
||||
ConfigMenuItem *itm = menu->getItemByIndex(i);
|
||||
if (!itm) {
|
||||
LOG_DEBUG(GwLog::ERROR, "Menu item not found: %d", i);
|
||||
logger->logDebug(GwLog::ERROR, "Menu item not found: %d", i);
|
||||
} else {
|
||||
Rect r = menu->getItemRect(i);
|
||||
bool inverted = (i == menu->getActiveIndex());
|
||||
|
@ -416,36 +416,33 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
PageSystem(CommonData &common){
|
||||
commonData = &common;
|
||||
config = commonData->config;
|
||||
logger = commonData->logger;
|
||||
|
||||
PageSystem(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageSystem");
|
||||
if (hasFRAM) {
|
||||
mode = fram.read(FRAM_SYSTEM_MODE);
|
||||
logger->logDebug(GwLog::LOG, "Loaded mode '%c' from FRAM", mode);
|
||||
}
|
||||
flashLED = common.config->getString(common.config->flashLED);
|
||||
flashLED = config->getString(config->flashLED);
|
||||
|
||||
chipid = ESP.getEfuseMac();
|
||||
simulation = common.config->getBool(common.config->useSimuData);
|
||||
simulation = config->getBool(config->useSimuData);
|
||||
#ifdef BOARD_OBP40S3
|
||||
sdcard = common.config->getBool(common.config->useSDCard);
|
||||
sdcard = config->getBool(config->useSDCard);
|
||||
#endif
|
||||
buzzer_mode = common.config->getString(common.config->buzzerMode);
|
||||
buzzer_mode = config->getString(config->buzzerMode);
|
||||
buzzer_mode.toLowerCase();
|
||||
buzzer_power = common.config->getInt(common.config->buzzerPower);
|
||||
cpuspeed = common.config->getString(common.config->cpuSpeed);
|
||||
env_module = common.config->getString(common.config->useEnvSensor);
|
||||
rtc_module = common.config->getString(common.config->useRTC);
|
||||
gps_module = common.config->getString(common.config->useGPS);
|
||||
batt_sensor = common.config->getString(common.config->usePowSensor1);
|
||||
solar_sensor = common.config->getString(common.config->usePowSensor2);
|
||||
gen_sensor = common.config->getString(common.config->usePowSensor3);
|
||||
rot_sensor = common.config->getString(common.config->useRotSensor);
|
||||
homelat = common.config->getString(common.config->homeLAT).toDouble();
|
||||
homelon = common.config->getString(common.config->homeLON).toDouble();
|
||||
buzzer_power = config->getInt(config->buzzerPower);
|
||||
cpuspeed = config->getString(config->cpuSpeed);
|
||||
env_module = config->getString(config->useEnvSensor);
|
||||
rtc_module = config->getString(config->useRTC);
|
||||
gps_module = config->getString(config->useGPS);
|
||||
batt_sensor = config->getString(config->usePowSensor1);
|
||||
solar_sensor = config->getString(config->usePowSensor2);
|
||||
gen_sensor = config->getString(config->usePowSensor3);
|
||||
rot_sensor = config->getString(config->useRotSensor);
|
||||
homelat = config->getString(config->homeLAT).toDouble();
|
||||
homelon = config->getString(config->homeLON).toDouble();
|
||||
|
||||
// CPU speed: 80 | 160 | 240
|
||||
// Power mode: Max | 5V | Min
|
||||
|
@ -478,7 +475,7 @@ public:
|
|||
virtual int handleKey(int key){
|
||||
// do *NOT* handle key #1 this handled by obp60task as exit
|
||||
// Switch display mode
|
||||
commonData->logger->logDebug(GwLog::LOG, "System keyboard handler");
|
||||
logger->logDebug(GwLog::LOG, "System keyboard handler");
|
||||
if (key == 2) {
|
||||
incMode();
|
||||
return 0;
|
||||
|
@ -547,14 +544,12 @@ public:
|
|||
}
|
||||
|
||||
void displayNew(PageData &pageData){
|
||||
// Get references from API
|
||||
NMEA2000 = pageData.api->getNMEA2000();
|
||||
};
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
// GwConfigHandler *config = commonData->config;
|
||||
// GwLog *logger = commonData->logger;
|
||||
|
||||
NMEA2000 = pageData.api->getNMEA2000();
|
||||
logger->logDebug(GwLog::LOG, "PageSystem: N2k source address=%d", NMEA2000->GetN2kSource());
|
||||
|
||||
// Optical warning by limit violation (unused)
|
||||
if(flashLED == "Limit Violation"){
|
||||
|
@ -565,10 +560,6 @@ public:
|
|||
// Logging page information
|
||||
logger->logDebug(GwLog::LOG, "Drawing at PageSystem, Mode=%c", mode);
|
||||
|
||||
// Get references from API
|
||||
// NMEA2000 = pageData.api->getNMEA2000();
|
||||
// LOG_DEBUG(GwLog::LOG,"N2k source address=%d", NMEA2000->GetN2kSource());
|
||||
|
||||
// Set display in partial refresh mode
|
||||
epd->setPartialWindow(0, 0, epd->width(), epd->height());
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
class PageThreeValues : public Page
|
||||
{
|
||||
public:
|
||||
PageThreeValues(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageThreeValue");
|
||||
PageThreeValues(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageThreeValue");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -23,8 +23,6 @@ class PageThreeValues : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static String svalue1old = "";
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
class PageTwoValues : public Page
|
||||
{
|
||||
public:
|
||||
PageTwoValues(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageTwoValue");
|
||||
PageTwoValues(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageTwoValue");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -23,8 +23,6 @@ class PageTwoValues : public Page
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static String svalue1old = "";
|
||||
|
|
|
@ -15,11 +15,8 @@ private:
|
|||
char mode = 'D'; // display mode (A)nalog | (D)igital
|
||||
|
||||
public:
|
||||
PageVoltage(CommonData &common){
|
||||
commonData = &common;
|
||||
config = commonData->config;
|
||||
logger = commonData->logger;
|
||||
|
||||
PageVoltage(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageVoltage");
|
||||
if (hasFRAM) {
|
||||
average = fram.read(FRAM_VOLTAGE_AVG);
|
||||
|
@ -32,14 +29,14 @@ public:
|
|||
logger->logDebug(GwLog::LOG, "Destroy PageVoltage");
|
||||
}
|
||||
|
||||
virtual void setupKeys(){
|
||||
void setupKeys(){
|
||||
Page::setupKeys();
|
||||
commonData->keydata[0].label = "AVG";
|
||||
commonData->keydata[1].label = "MODE";
|
||||
commonData->keydata[4].label = "TRD";
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Change average
|
||||
if(key == 1){
|
||||
average ++;
|
||||
|
@ -110,8 +107,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Get config data
|
||||
bool simulation = config->getBool(config->useSimuData);
|
||||
|
|
|
@ -17,9 +17,9 @@ class PageWhite : public Page
|
|||
char mode = 'W'; // display mode (W)hite | (L)ogo | (M)FD logo
|
||||
|
||||
public:
|
||||
PageWhite(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite");
|
||||
PageWhite(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageWhite");
|
||||
refreshtime = 15000;
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Get config data
|
||||
String flashLED = config->getString(config->flashLED);
|
||||
|
|
|
@ -221,9 +221,9 @@ char mode = 'N'; // page mode (N)ormal | (L)ens | e(X)ample
|
|||
char source = 'A'; // data source (A)pparent | (T)rue
|
||||
|
||||
public:
|
||||
PageWind(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageWind");
|
||||
PageWind(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageWind");
|
||||
if (hasFRAM) {
|
||||
lp = fram.read(FRAM_WIND_SIZE);
|
||||
source = fram.read(FRAM_WIND_SRC);
|
||||
|
@ -231,7 +231,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void setupKeys(){
|
||||
void setupKeys(){
|
||||
Page::setupKeys();
|
||||
commonData->keydata[0].label = "MODE";
|
||||
if (mode == 'X') {
|
||||
|
@ -243,7 +243,7 @@ public:
|
|||
}
|
||||
|
||||
// Key functions
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
|
||||
if(key == 1){ // Mode switch
|
||||
if(mode == 'N'){
|
||||
|
@ -297,10 +297,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
int displayPage(PageData &pageData)
|
||||
{
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
int displayPage(PageData &pageData) {
|
||||
|
||||
static String svalue1old = "";
|
||||
static String unit1old = "";
|
||||
|
|
|
@ -57,13 +57,12 @@ class PageWindPlot : public Page {
|
|||
bool showTWS = true; // Show TWS value in chart area
|
||||
|
||||
public:
|
||||
PageWindPlot(CommonData& common)
|
||||
PageWindPlot(CommonData& common) : Page(common)
|
||||
{
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG, "Instantiate PageWindPlot");
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageWindPlot");
|
||||
}
|
||||
|
||||
virtual void setupKeys()
|
||||
void setupKeys()
|
||||
{
|
||||
Page::setupKeys();
|
||||
// commonData->keydata[0].label = "MODE";
|
||||
|
@ -72,7 +71,7 @@ public:
|
|||
}
|
||||
|
||||
// Key functions
|
||||
virtual int handleKey(int key)
|
||||
int handleKey(int key)
|
||||
{
|
||||
// Set chart mode TWD | TWS -> to be implemented
|
||||
if (key == 1) {
|
||||
|
@ -114,10 +113,7 @@ public:
|
|||
return key;
|
||||
}
|
||||
|
||||
int displayPage(PageData& pageData)
|
||||
{
|
||||
GwConfigHandler* config = commonData->config;
|
||||
GwLog* logger = commonData->logger;
|
||||
int displayPage(PageData& pageData) {
|
||||
|
||||
float twsValue; // TWS value in chart area
|
||||
static String twdName, twdUnit; // TWD name and unit
|
||||
|
|
|
@ -10,13 +10,13 @@ class PageWindRose : public Page
|
|||
int16_t lp = 80; // Pointer length
|
||||
|
||||
public:
|
||||
PageWindRose(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageWindRose");
|
||||
PageWindRose(CommonData &common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageWindRose");
|
||||
}
|
||||
|
||||
// Key functions
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -26,8 +26,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData) {
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
static String svalue1old = "";
|
||||
static String unit1old = "";
|
||||
|
|
|
@ -10,13 +10,13 @@ class PageWindRoseFlex : public Page
|
|||
int16_t lp = 80; // Pointer length
|
||||
|
||||
public:
|
||||
PageWindRoseFlex(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageWindRoseFlex");
|
||||
PageWindRoseFlex(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageWindRoseFlex");
|
||||
}
|
||||
|
||||
// Key functions
|
||||
virtual int handleKey(int key){
|
||||
int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
|
@ -26,8 +26,6 @@ public:
|
|||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
static String svalue1old = "";
|
||||
static String unit1old = "";
|
||||
|
|
|
@ -33,11 +33,11 @@ class PageXTETrack : public Page
|
|||
bool holdvalues = false;
|
||||
|
||||
public:
|
||||
PageXTETrack(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageXTETrack");
|
||||
simulation = common.config->getBool(common.config->useSimuData);
|
||||
holdvalues = common.config->getBool(common.config->holdvalues);
|
||||
PageXTETrack(CommonData &common) : Page(common)
|
||||
{
|
||||
logger->logDebug(GwLog::LOG, "Instantiate PageXTETrack");
|
||||
simulation = config->getBool(config->useSimuData);
|
||||
holdvalues = config->getBool(config->holdvalues);
|
||||
}
|
||||
|
||||
void drawSegment(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
|
||||
|
|
|
@ -130,6 +130,12 @@ protected:
|
|||
GwConfigHandler *config;
|
||||
GwLog *logger;
|
||||
public:
|
||||
Page(){}
|
||||
Page(CommonData &common) {
|
||||
commonData = &common;
|
||||
config = commonData->config;
|
||||
logger = commonData->logger;
|
||||
}
|
||||
int refreshtime = 1000;
|
||||
virtual int displayPage(PageData &pageData)=0;
|
||||
virtual void displayNew(PageData &pageData){}
|
||||
|
|
Loading…
Reference in New Issue