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
|
class PageAIS : public Page
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
GwConfigHandler *config;
|
|
||||||
GwLog *logger;
|
|
||||||
bool simulation = false;
|
bool simulation = false;
|
||||||
bool holdvalues = false;
|
bool holdvalues = false;
|
||||||
String flashLED;
|
String flashLED;
|
||||||
|
@ -84,11 +82,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageAIS(CommonData &common)
|
PageAIS(CommonData &common) : Page(common)
|
||||||
{
|
{
|
||||||
commonData = &common;
|
|
||||||
config = commonData->config;
|
|
||||||
logger = commonData->logger;
|
|
||||||
logger->logDebug(GwLog::LOG,"Instantiate PageAIS");
|
logger->logDebug(GwLog::LOG,"Instantiate PageAIS");
|
||||||
|
|
||||||
// preload configuration data
|
// preload configuration data
|
||||||
|
|
|
@ -51,8 +51,6 @@ static unsigned char anchor_bits[] = {
|
||||||
class PageAnchor : public Page
|
class PageAnchor : public Page
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
GwConfigHandler *config;
|
|
||||||
GwLog *logger;
|
|
||||||
bool simulation = false;
|
bool simulation = false;
|
||||||
bool holdvalues = false;
|
bool holdvalues = false;
|
||||||
String flashLED;
|
String flashLED;
|
||||||
|
@ -244,11 +242,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageAnchor(CommonData &common)
|
PageAnchor(CommonData &common) : Page(common)
|
||||||
{
|
{
|
||||||
commonData = &common;
|
|
||||||
config = commonData->config;
|
|
||||||
logger = commonData->logger;
|
|
||||||
logger->logDebug(GwLog::LOG,"Instantiate PageAnchor");
|
logger->logDebug(GwLog::LOG,"Instantiate PageAnchor");
|
||||||
|
|
||||||
// preload configuration data
|
// preload configuration data
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
class PageAutopilot : public Page
|
class PageAutopilot : public Page
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
GwConfigHandler *config;
|
|
||||||
GwLog *logger;
|
|
||||||
bool simulation = false;
|
bool simulation = false;
|
||||||
bool holdvalues = false;
|
bool holdvalues = false;
|
||||||
String flashLED;
|
String flashLED;
|
||||||
|
@ -48,12 +46,9 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageAutopilot(CommonData &common)
|
PageAutopilot(CommonData &common) : Page(common)
|
||||||
{
|
{
|
||||||
commonData = &common;
|
logger->logDebug(GwLog::LOG, "Instantiate PageAutopilot");
|
||||||
config = commonData->config;
|
|
||||||
logger = commonData->logger;
|
|
||||||
logger->logDebug(GwLog::LOG,"Instantiate PageAutopilot");
|
|
||||||
|
|
||||||
// preload configuration data
|
// preload configuration data
|
||||||
simulation = config->getBool(config->useSimuData);
|
simulation = config->getBool(config->useSimuData);
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
class PageBME280 : public Page
|
class PageBME280 : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageBME280(CommonData &common){
|
PageBME280(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageBME280");
|
logger->logDebug(GwLog::LOG,"Instantiate PageBME280");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
virtual int handleKey(int key){
|
||||||
|
@ -22,8 +22,6 @@ class PageBME280 : public Page
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
double value1 = 0;
|
double value1 = 0;
|
||||||
double value2 = 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
|
int average = 0; // Average type [0...3], 0=off, 1=10s, 2=60s, 3=300s
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageBattery(CommonData &common){
|
PageBattery(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageBattery");
|
logger->logDebug(GwLog::LOG, "Instantiate PageBattery");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setupKeys(){
|
virtual void setupKeys(){
|
||||||
|
@ -36,9 +36,7 @@ class PageBattery : public Page
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
double value1 = 0;
|
double value1 = 0;
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
|
|
|
@ -13,17 +13,17 @@ bool trend = true; // Trend indicator [0|1], 0=off, 1=on
|
||||||
double raw = 0;
|
double raw = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageBattery2(CommonData &common){
|
PageBattery2(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageBattery2");
|
logger->logDebug(GwLog::LOG, "Instantiate PageBattery2");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setupKeys(){
|
void setupKeys(){
|
||||||
Page::setupKeys();
|
Page::setupKeys();
|
||||||
commonData->keydata[0].label = "AVG";
|
commonData->keydata[0].label = "AVG";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key) {
|
||||||
// Change average
|
// Change average
|
||||||
if(key == 1){
|
if(key == 1){
|
||||||
average ++;
|
average ++;
|
||||||
|
@ -45,11 +45,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData)
|
int displayPage(PageData &pageData) {
|
||||||
{
|
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Polynominal coefficients second order for battery energy level calculation
|
// Polynominal coefficients second order for battery energy level calculation
|
||||||
// index 0 = Pb, 1 = Gel, 2 = AGM, 3 = LiFePo4
|
// index 0 = Pb, 1 = Gel, 2 = AGM, 3 = LiFePo4
|
||||||
float x0[4] = {+3082.5178, +1656.1571, +1316.8766, +14986.9336}; // Offset
|
float x0[4] = {+3082.5178, +1656.1571, +1316.8766, +14986.9336}; // Offset
|
||||||
|
|
|
@ -17,34 +17,35 @@
|
||||||
|
|
||||||
class PageClock : public Page
|
class PageClock : public Page
|
||||||
{
|
{
|
||||||
bool simulation = false;
|
private:
|
||||||
int simtime;
|
bool simulation = false;
|
||||||
bool keylock = false;
|
int simtime;
|
||||||
char source = 'R'; // time source (R)TC | (G)PS | (N)TP
|
bool keylock = false;
|
||||||
char mode = 'A'; // display mode (A)nalog | (D)igital | race (T)imer
|
char source = 'R'; // time source (R)TC | (G)PS | (N)TP
|
||||||
char tz = 'L'; // time zone (L)ocal | (U)TC
|
char mode = 'A'; // display mode (A)nalog | (D)igital | race (T)imer
|
||||||
double timezone = 0; // there are timezones with non int offsets, e.g. 5.5 or 5.75
|
char tz = 'L'; // time zone (L)ocal | (U)TC
|
||||||
double homelat;
|
double timezone = 0; // there are timezones with non int offsets, e.g. 5.5 or 5.75
|
||||||
double homelon;
|
double homelat;
|
||||||
bool homevalid = false; // homelat and homelon are valid
|
double homelon;
|
||||||
|
bool homevalid = false; // homelat and homelon are valid
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageClock(CommonData &common){
|
PageClock(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageClock");
|
logger->logDebug(GwLog::LOG, "Instantiate PageClock");
|
||||||
|
|
||||||
// WIP time source
|
// WIP time source
|
||||||
#ifdef BOARD_OBP60S3
|
#ifdef BOARD_OBP60S3
|
||||||
String use_rtc = common.config->getString(common.config->useRTC);
|
String use_rtc = config->getString(config->useRTC);
|
||||||
if (use_rtc == "off") {
|
if (use_rtc == "off") {
|
||||||
source = 'G';
|
source = 'G';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
simulation = common.config->getBool(common.config->useSimuData);
|
simulation = config->getBool(config->useSimuData);
|
||||||
timezone = common.config->getString(common.config->timeZone).toDouble();
|
timezone = config->getString(config->timeZone).toDouble();
|
||||||
homelat = common.config->getString(common.config->homeLAT).toDouble();
|
homelat = config->getString(config->homeLAT).toDouble();
|
||||||
homelon = common.config->getString(common.config->homeLON).toDouble();
|
homelon = config->getString(config->homeLON).toDouble();
|
||||||
homevalid = homelat >= -180.0 and homelat <= 180 and homelon >= -90.0 and homelon <= 90.0;
|
homevalid = homelat >= -180.0 and homelat <= 180 and homelon >= -90.0 and homelon <= 90.0;
|
||||||
simtime = 38160; // time value 11:36
|
simtime = 38160; // time value 11:36
|
||||||
}
|
}
|
||||||
|
@ -97,9 +98,6 @@ bool homevalid = false; // homelat and homelon are valid
|
||||||
|
|
||||||
int displayPage(PageData &pageData)
|
int displayPage(PageData &pageData)
|
||||||
{
|
{
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
static String unit1old = "";
|
static String unit1old = "";
|
||||||
static String svalue2old = "";
|
static String svalue2old = "";
|
||||||
|
|
|
@ -29,9 +29,9 @@ class PageCompass : public Page
|
||||||
int WhichDataDisplay = ShowHDM;
|
int WhichDataDisplay = ShowHDM;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageCompass(CommonData &common){
|
PageCompass(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageCompass");
|
logger->logDebug(GwLog::LOG, "Instantiate PageCompass");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setupKeys(){
|
virtual void setupKeys(){
|
||||||
|
@ -63,9 +63,7 @@ class PageCompass : public Page
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String OldDataText[HowManyValues] = {"", "", "","", "", ""};
|
static String OldDataText[HowManyValues] = {"", "", "","", "", ""};
|
||||||
static String OldDataUnits[HowManyValues] = {"", "", "","", "", ""};
|
static String OldDataUnits[HowManyValues] = {"", "", "","", "", ""};
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
class PageDST810 : public Page
|
class PageDST810 : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageDST810(CommonData &common){
|
PageDST810(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageDST810");
|
logger->logDebug(GwLog::LOG, "Instantiate PageDST810");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
virtual int handleKey(int key){
|
||||||
|
@ -22,8 +22,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
class PageEPropulsion : public Page
|
class PageEPropulsion : public Page
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
GwConfigHandler *config;
|
|
||||||
GwLog *logger;
|
|
||||||
bool simulation = false;
|
bool simulation = false;
|
||||||
bool holdvalues = false;
|
bool holdvalues = false;
|
||||||
String flashLED;
|
String flashLED;
|
||||||
|
@ -48,11 +46,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageEPropulsion(CommonData &common)
|
PageEPropulsion(CommonData &common) : Page(common)
|
||||||
{
|
{
|
||||||
commonData = &common;
|
|
||||||
config = commonData->config;
|
|
||||||
logger = commonData->logger;
|
|
||||||
logger->logDebug(GwLog::LOG,"Instantiate PageEPropulsion");
|
logger->logDebug(GwLog::LOG,"Instantiate PageEPropulsion");
|
||||||
|
|
||||||
// preload configuration data
|
// preload configuration data
|
||||||
|
|
|
@ -75,11 +75,11 @@ class PageFluid : public Page
|
||||||
int fluidtype;
|
int fluidtype;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageFluid(CommonData &common){
|
PageFluid(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageFluid");
|
logger->logDebug(GwLog::LOG,"Instantiate PageFluid");
|
||||||
simulation = common.config->getBool(common.config->useSimuData);
|
simulation = config->getBool(config->useSimuData);
|
||||||
holdvalues = common.config->getBool(common.config->holdvalues);
|
holdvalues = config->getBool(config->holdvalues);
|
||||||
simval = double(random(0, 100));
|
simval = double(random(0, 100));
|
||||||
simgoto = double(random(0, 100));
|
simgoto = double(random(0, 100));
|
||||||
simstep = (simgoto - simval) / 20.0;
|
simstep = (simgoto - simval) / 20.0;
|
||||||
|
@ -95,13 +95,11 @@ class PageFluid : public Page
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void displayNew(PageData &pageData){
|
virtual void displayNew(PageData &pageData){
|
||||||
fluidtype = commonData->config->getInt("page" + String(pageData.pageNumber) + "fluid", 0);
|
fluidtype = config->getInt("page" + String(pageData.pageNumber) + "fluid", 0);
|
||||||
commonData->logger->logDebug(GwLog::LOG,"New PageFluid: fluidtype=%d", fluidtype);
|
logger->logDebug(GwLog::LOG, "New PageFluid: fluidtype=%d", fluidtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static double value1old;
|
static double value1old;
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
|
|
||||||
class PageFourValues : public Page
|
class PageFourValues : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageFourValues(CommonData &common){
|
PageFourValues(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageFourValues");
|
logger->logDebug(GwLog::LOG, "Instantiate PageFourValues");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -23,8 +23,6 @@ class PageFourValues : public Page
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
|
|
||||||
class PageFourValues2 : public Page
|
class PageFourValues2 : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageFourValues2(CommonData &common){
|
PageFourValues2(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageFourValues2");
|
logger->logDebug(GwLog::LOG,"Instantiate PageFourValues2");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
virtual int handleKey(int key){
|
||||||
|
@ -23,8 +23,6 @@ class PageFourValues2 : public Page
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
class PageGenerator : public Page
|
class PageGenerator : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageGenerator(CommonData &common){
|
PageGenerator(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageGenerator");
|
logger->logDebug(GwLog::LOG, "Instantiate PageGenerator");
|
||||||
}
|
}
|
||||||
virtual int handleKey(int key){
|
|
||||||
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -21,10 +22,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData)
|
int displayPage(PageData &pageData) {
|
||||||
{
|
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
bool simulation = config->getBool(config->useSimuData);
|
bool simulation = config->getBool(config->useSimuData);
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
class PageKeelPosition : public Page
|
class PageKeelPosition : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageKeelPosition(CommonData &common){
|
PageKeelPosition(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageKeelPosition");
|
logger->logDebug(GwLog::LOG, "Instantiate PageKeelPosition");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key functions
|
// Key functions
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -22,10 +22,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData)
|
int displayPage(PageData &pageData) {
|
||||||
{
|
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
double value1 = 0;
|
double value1 = 0;
|
||||||
double value1old = 0;
|
double value1old = 0;
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
class PageOneValue : public Page
|
class PageOneValue : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageOneValue(CommonData &common){
|
PageOneValue(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageOneValue");
|
logger->logDebug(GwLog::LOG, "Instantiate PageOneValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key) {
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -22,9 +22,7 @@ class PageOneValue : public Page
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
class PageRollPitch : public Page
|
class PageRollPitch : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageRollPitch(CommonData &common){
|
PageRollPitch(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageRollPitch");
|
logger->logDebug(GwLog::LOG, "Instantiate PageRollPitch");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key functions
|
// Key functions
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -22,9 +22,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
double value1 = 0;
|
double value1 = 0;
|
||||||
double value2 = 0;
|
double value2 = 0;
|
||||||
|
@ -33,7 +31,6 @@ public:
|
||||||
String svalue2 = "";
|
String svalue2 = "";
|
||||||
String svalue2old = "";
|
String svalue2old = "";
|
||||||
|
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
String lengthformat = config->getString(config->lengthFormat);
|
String lengthformat = config->getString(config->lengthFormat);
|
||||||
bool simulation = config->getBool(config->useSimuData);
|
bool simulation = config->getBool(config->useSimuData);
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
class PageRudderPosition : public Page
|
class PageRudderPosition : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageRudderPosition(CommonData &common){
|
PageRudderPosition(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Show PageRudderPosition");
|
logger->logDebug(GwLog::LOG, "Show PageRudderPosition");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key functions
|
// Key functions
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -23,9 +23,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
static String unit1old = "";
|
static String unit1old = "";
|
||||||
double value1 = 0.1;
|
double value1 = 0.1;
|
||||||
|
|
|
@ -15,10 +15,10 @@ const int HowManyValues = 6;
|
||||||
|
|
||||||
class PageSixValues : public Page
|
class PageSixValues : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageSixValues(CommonData &common){
|
PageSixValues(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageSixValues");
|
logger->logDebug(GwLog::LOG, "Instantiate PageSixValues");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
virtual int handleKey(int key){
|
||||||
|
@ -30,130 +30,127 @@ class PageSixValues : public Page
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String OldDataText[HowManyValues] = {"", "", "", "", "", ""};
|
static String OldDataText[HowManyValues] = {"", "", "", "", "", ""};
|
||||||
static String OldDataUnits[HowManyValues] = {"", "", "", "", "", ""};
|
static String OldDataUnits[HowManyValues] = {"", "", "", "", "", ""};
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
String lengthformat = config->getString(config->lengthFormat);
|
String lengthformat = config->getString(config->lengthFormat);
|
||||||
// bool simulation = config->getBool(config->useSimuData);
|
// bool simulation = config->getBool(config->useSimuData);
|
||||||
bool holdvalues = config->getBool(config->holdvalues);
|
bool holdvalues = config->getBool(config->holdvalues);
|
||||||
String flashLED = config->getString(config->flashLED);
|
String flashLED = config->getString(config->flashLED);
|
||||||
String backlightMode = config->getString(config->backlight);
|
String backlightMode = config->getString(config->backlight);
|
||||||
|
|
||||||
GwApi::BoatValue *bvalue;
|
GwApi::BoatValue *bvalue;
|
||||||
String DataName[HowManyValues];
|
String DataName[HowManyValues];
|
||||||
double DataValue[HowManyValues];
|
double DataValue[HowManyValues];
|
||||||
bool DataValid[HowManyValues];
|
bool DataValid[HowManyValues];
|
||||||
String DataText[HowManyValues];
|
String DataText[HowManyValues];
|
||||||
String DataUnits[HowManyValues];
|
String DataUnits[HowManyValues];
|
||||||
String DataFormat[HowManyValues];
|
String DataFormat[HowManyValues];
|
||||||
|
|
||||||
for (int i = 0; i < HowManyValues; i++){
|
for (int i = 0; i < HowManyValues; i++){
|
||||||
bvalue = pageData.values[i];
|
bvalue = pageData.values[i];
|
||||||
DataName[i] = xdrDelete(bvalue->getName());
|
DataName[i] = xdrDelete(bvalue->getName());
|
||||||
DataName[i] = DataName[i].substring(0, 6); // String length limit for value name
|
DataName[i] = DataName[i].substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(bvalue, logger); // Check if boat data value is to be calibrated
|
||||||
DataValue[i] = bvalue->value; // Value as double in SI unit
|
DataValue[i] = bvalue->value; // Value as double in SI unit
|
||||||
DataValid[i] = bvalue->valid;
|
DataValid[i] = bvalue->valid;
|
||||||
DataText[i] = formatValue(bvalue, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
DataText[i] = formatValue(bvalue, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
DataUnits[i] = formatValue(bvalue, *commonData).unit;
|
DataUnits[i] = formatValue(bvalue, *commonData).unit;
|
||||||
DataFormat[i] = bvalue->getFormat(); // Unit of value
|
DataFormat[i] = bvalue->getFormat(); // Unit of value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optical warning by limit violation (unused)
|
// Optical warning by limit violation (unused)
|
||||||
if(String(flashLED) == "Limit Violation"){
|
if(String(flashLED) == "Limit Violation"){
|
||||||
setBlinkingLED(false);
|
setBlinkingLED(false);
|
||||||
setFlashLED(false);
|
setFlashLED(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bvalue == NULL) return PAGE_OK; // WTF why this statement?
|
if (bvalue == NULL) return PAGE_OK; // WTF why this statement?
|
||||||
|
|
||||||
// Draw page
|
// Draw page
|
||||||
//***********************************************************
|
//***********************************************************
|
||||||
|
|
||||||
// Set display in partial refresh mode
|
|
||||||
epd->setPartialWindow(0, 0, epd->width(), epd->height()); // Set partial update
|
|
||||||
epd->setTextColor(commonData->fgcolor);
|
|
||||||
|
|
||||||
for (int i = 0; i < ( HowManyValues / 2 ); i++){
|
// Set display in partial refresh mode
|
||||||
if (i < (HowManyValues / 2) - 1) { // Don't draw horizontal line after last line of values -> standard design
|
epd->setPartialWindow(0, 0, epd->width(), epd->height()); // Set partial update
|
||||||
// Horizontal line 3 pix
|
epd->setTextColor(commonData->fgcolor);
|
||||||
epd->fillRect(0, SixValues_y1+(i+1)*SixValues_DeltaY, 400, 3, commonData->fgcolor);
|
|
||||||
}
|
for (int i = 0; i < ( HowManyValues / 2 ); i++) {
|
||||||
for (int j = 0; j < 2; j++){
|
if (i < (HowManyValues / 2) - 1) { // Don't draw horizontal line after last line of values -> standard design
|
||||||
int ValueIndex = i * 2 + j;
|
// Horizontal line 3 pix
|
||||||
int x0 = SixValues_x1 + j * SixValues_DeltaX;
|
epd->fillRect(0, SixValues_y1+(i+1)*SixValues_DeltaY, 400, 3, commonData->fgcolor);
|
||||||
int y0 = SixValues_y1 + i * SixValues_DeltaY;
|
|
||||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageSixValue: %d %s %f %s", ValueIndex, DataName[ValueIndex], DataValue[ValueIndex], DataFormat[ValueIndex] );
|
|
||||||
|
|
||||||
// Show name
|
|
||||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
|
||||||
epd->setCursor(x0, y0+25);
|
|
||||||
epd->print(DataName[ValueIndex]); // Page name
|
|
||||||
|
|
||||||
// Show unit
|
|
||||||
epd->setFont(&Ubuntu_Bold8pt8b);
|
|
||||||
epd->setCursor(x0, y0+72);
|
|
||||||
if(holdvalues == false){
|
|
||||||
epd->print(DataUnits[ValueIndex]); // Unit
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
epd->print(OldDataUnits[ValueIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch font if format for any values
|
|
||||||
if(DataFormat[ValueIndex] == "formatLatitude" || DataFormat[ValueIndex] == "formatLongitude"){
|
|
||||||
epd->setFont(&Ubuntu_Bold12pt8b);
|
|
||||||
epd->setCursor(x0+10, y0+60);
|
|
||||||
}
|
|
||||||
else if(DataFormat[ValueIndex] == "formatTime" || DataFormat[ValueIndex] == "formatDate"){
|
|
||||||
epd->setFont(&Ubuntu_Bold16pt8b);
|
|
||||||
epd->setCursor(x0+20,y0+55);
|
|
||||||
}
|
|
||||||
// pressure in hPa
|
|
||||||
else if(DataFormat[ValueIndex] == "formatXdr:P:P"){
|
|
||||||
epd->setFont(&DSEG7Classic_BoldItalic26pt7b);
|
|
||||||
epd->setCursor(x0+5, y0+70);
|
|
||||||
}
|
|
||||||
// RPM
|
|
||||||
else if(DataFormat[ValueIndex] == "formatXdr:T:R"){
|
|
||||||
epd->setFont(&DSEG7Classic_BoldItalic16pt7b);
|
|
||||||
epd->setCursor(x0+25, y0+70);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
epd->setFont(&DSEG7Classic_BoldItalic26pt7b);
|
|
||||||
if ( DataText[ValueIndex][0] == '-' )
|
|
||||||
epd->setCursor(x0+25, y0+70);
|
|
||||||
else
|
|
||||||
epd->setCursor(x0+65, y0+70);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show bus data
|
|
||||||
if(holdvalues == false){
|
|
||||||
epd->print(DataText[ValueIndex]); // Real value as formated string
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Vertical line 3 pix
|
|
||||||
epd->fillRect(SixValues_x1+SixValues_DeltaX-8, SixValues_y1+i*SixValues_DeltaY, 3, SixValues_DeltaY, commonData->fgcolor);
|
|
||||||
}
|
}
|
||||||
|
for (int j = 0; j < 2; j++) {
|
||||||
|
int ValueIndex = i * 2 + j;
|
||||||
|
int x0 = SixValues_x1 + j * SixValues_DeltaX;
|
||||||
|
int y0 = SixValues_y1 + i * SixValues_DeltaY;
|
||||||
|
LOG_DEBUG(GwLog::LOG, "Drawing at PageSixValue: %d %s %f %s", ValueIndex, DataName[ValueIndex], DataValue[ValueIndex], DataFormat[ValueIndex]);
|
||||||
|
|
||||||
return PAGE_UPDATE;
|
// Show name
|
||||||
};
|
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||||
|
epd->setCursor(x0, y0+25);
|
||||||
|
epd->print(DataName[ValueIndex]); // Page name
|
||||||
|
|
||||||
|
// Show unit
|
||||||
|
epd->setFont(&Ubuntu_Bold8pt8b);
|
||||||
|
epd->setCursor(x0, y0+72);
|
||||||
|
if (holdvalues == false) {
|
||||||
|
epd->print(DataUnits[ValueIndex]); // Unit
|
||||||
|
} else {
|
||||||
|
epd->print(OldDataUnits[ValueIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Switch font if format for any values
|
||||||
|
if (DataFormat[ValueIndex] == "formatLatitude" || DataFormat[ValueIndex] == "formatLongitude") {
|
||||||
|
epd->setFont(&Ubuntu_Bold12pt8b);
|
||||||
|
epd->setCursor(x0+10, y0+60);
|
||||||
|
}
|
||||||
|
else if (DataFormat[ValueIndex] == "formatTime" || DataFormat[ValueIndex] == "formatDate") {
|
||||||
|
epd->setFont(&Ubuntu_Bold16pt8b);
|
||||||
|
epd->setCursor(x0+20,y0+55);
|
||||||
|
}
|
||||||
|
// pressure in hPa
|
||||||
|
else if (DataFormat[ValueIndex] == "formatXdr:P:P") {
|
||||||
|
epd->setFont(&DSEG7Classic_BoldItalic26pt7b);
|
||||||
|
epd->setCursor(x0+5, y0+70);
|
||||||
|
}
|
||||||
|
// RPM
|
||||||
|
else if (DataFormat[ValueIndex] == "formatXdr:T:R") {
|
||||||
|
epd->setFont(&DSEG7Classic_BoldItalic16pt7b);
|
||||||
|
epd->setCursor(x0+25, y0+70);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
epd->setFont(&DSEG7Classic_BoldItalic26pt7b);
|
||||||
|
if (DataText[ValueIndex][0] == '-' ) {
|
||||||
|
epd->setCursor(x0+25, y0+70);
|
||||||
|
} else {
|
||||||
|
epd->setCursor(x0+65, y0+70);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show bus data
|
||||||
|
if (holdvalues == false) {
|
||||||
|
epd->print(DataText[ValueIndex]); // Real value as formated string
|
||||||
|
} 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){
|
static Page *createPage(CommonData &common){
|
||||||
return new PageSixValues(common);
|
return new PageSixValues(common);
|
||||||
}/**
|
}/**
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
class PageSkyView : public Page
|
class PageSkyView : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageSkyView(CommonData &common){
|
PageSkyView(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Show PageSkyView");
|
logger->logDebug(GwLog::LOG,"Instantiate PageSkyView");
|
||||||
}
|
}
|
||||||
|
|
||||||
int handleKey(int key){
|
int handleKey(int key){
|
||||||
|
@ -26,8 +26,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData) {
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
String flashLED = config->getString(config->flashLED);
|
String flashLED = config->getString(config->flashLED);
|
||||||
|
@ -41,7 +39,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logging boat values
|
// Logging boat values
|
||||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageSkyView");
|
logger->logDebug(GwLog::LOG, "Drawing at PageSkyView");
|
||||||
|
|
||||||
// Draw page
|
// Draw page
|
||||||
//***********************************************************
|
//***********************************************************
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
class PageSolar : public Page
|
class PageSolar : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageSolar(CommonData &common){
|
PageSolar(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageSolar");
|
logger->logDebug(GwLog::LOG,"Instantiate PageSolar");
|
||||||
}
|
}
|
||||||
virtual int handleKey(int key){
|
|
||||||
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -21,9 +22,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
bool simulation = config->getBool(config->useSimuData);
|
bool simulation = config->getBool(config->useSimuData);
|
||||||
|
|
|
@ -267,7 +267,7 @@ private:
|
||||||
for (int i = 0 ; i < menu->getItemCount(); i++) {
|
for (int i = 0 ; i < menu->getItemCount(); i++) {
|
||||||
ConfigMenuItem *itm = menu->getItemByIndex(i);
|
ConfigMenuItem *itm = menu->getItemByIndex(i);
|
||||||
if (!itm) {
|
if (!itm) {
|
||||||
LOG_DEBUG(GwLog::ERROR, "Menu item not found: %d", i);
|
logger->logDebug(GwLog::ERROR, "Menu item not found: %d", i);
|
||||||
} else {
|
} else {
|
||||||
Rect r = menu->getItemRect(i);
|
Rect r = menu->getItemRect(i);
|
||||||
bool inverted = (i == menu->getActiveIndex());
|
bool inverted = (i == menu->getActiveIndex());
|
||||||
|
@ -416,36 +416,33 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageSystem(CommonData &common){
|
PageSystem(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
config = commonData->config;
|
|
||||||
logger = commonData->logger;
|
|
||||||
|
|
||||||
logger->logDebug(GwLog::LOG, "Instantiate PageSystem");
|
logger->logDebug(GwLog::LOG, "Instantiate PageSystem");
|
||||||
if (hasFRAM) {
|
if (hasFRAM) {
|
||||||
mode = fram.read(FRAM_SYSTEM_MODE);
|
mode = fram.read(FRAM_SYSTEM_MODE);
|
||||||
logger->logDebug(GwLog::LOG, "Loaded mode '%c' from FRAM", 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();
|
chipid = ESP.getEfuseMac();
|
||||||
simulation = common.config->getBool(common.config->useSimuData);
|
simulation = config->getBool(config->useSimuData);
|
||||||
#ifdef BOARD_OBP40S3
|
#ifdef BOARD_OBP40S3
|
||||||
sdcard = common.config->getBool(common.config->useSDCard);
|
sdcard = config->getBool(config->useSDCard);
|
||||||
#endif
|
#endif
|
||||||
buzzer_mode = common.config->getString(common.config->buzzerMode);
|
buzzer_mode = config->getString(config->buzzerMode);
|
||||||
buzzer_mode.toLowerCase();
|
buzzer_mode.toLowerCase();
|
||||||
buzzer_power = common.config->getInt(common.config->buzzerPower);
|
buzzer_power = config->getInt(config->buzzerPower);
|
||||||
cpuspeed = common.config->getString(common.config->cpuSpeed);
|
cpuspeed = config->getString(config->cpuSpeed);
|
||||||
env_module = common.config->getString(common.config->useEnvSensor);
|
env_module = config->getString(config->useEnvSensor);
|
||||||
rtc_module = common.config->getString(common.config->useRTC);
|
rtc_module = config->getString(config->useRTC);
|
||||||
gps_module = common.config->getString(common.config->useGPS);
|
gps_module = config->getString(config->useGPS);
|
||||||
batt_sensor = common.config->getString(common.config->usePowSensor1);
|
batt_sensor = config->getString(config->usePowSensor1);
|
||||||
solar_sensor = common.config->getString(common.config->usePowSensor2);
|
solar_sensor = config->getString(config->usePowSensor2);
|
||||||
gen_sensor = common.config->getString(common.config->usePowSensor3);
|
gen_sensor = config->getString(config->usePowSensor3);
|
||||||
rot_sensor = common.config->getString(common.config->useRotSensor);
|
rot_sensor = config->getString(config->useRotSensor);
|
||||||
homelat = common.config->getString(common.config->homeLAT).toDouble();
|
homelat = config->getString(config->homeLAT).toDouble();
|
||||||
homelon = common.config->getString(common.config->homeLON).toDouble();
|
homelon = config->getString(config->homeLON).toDouble();
|
||||||
|
|
||||||
// CPU speed: 80 | 160 | 240
|
// CPU speed: 80 | 160 | 240
|
||||||
// Power mode: Max | 5V | Min
|
// Power mode: Max | 5V | Min
|
||||||
|
@ -478,7 +475,7 @@ public:
|
||||||
virtual int handleKey(int key){
|
virtual int handleKey(int key){
|
||||||
// do *NOT* handle key #1 this handled by obp60task as exit
|
// do *NOT* handle key #1 this handled by obp60task as exit
|
||||||
// Switch display mode
|
// Switch display mode
|
||||||
commonData->logger->logDebug(GwLog::LOG, "System keyboard handler");
|
logger->logDebug(GwLog::LOG, "System keyboard handler");
|
||||||
if (key == 2) {
|
if (key == 2) {
|
||||||
incMode();
|
incMode();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -547,14 +544,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayNew(PageData &pageData){
|
void displayNew(PageData &pageData){
|
||||||
|
// Get references from API
|
||||||
|
NMEA2000 = pageData.api->getNMEA2000();
|
||||||
};
|
};
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
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)
|
// Optical warning by limit violation (unused)
|
||||||
if(flashLED == "Limit Violation"){
|
if(flashLED == "Limit Violation"){
|
||||||
|
@ -563,11 +558,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logging page information
|
// Logging page information
|
||||||
logger->logDebug(GwLog::LOG,"Drawing at PageSystem, Mode=%c", mode);
|
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
|
// Set display in partial refresh mode
|
||||||
epd->setPartialWindow(0, 0, epd->width(), epd->height());
|
epd->setPartialWindow(0, 0, epd->width(), epd->height());
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
class PageThreeValues : public Page
|
class PageThreeValues : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageThreeValues(CommonData &common){
|
PageThreeValues(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageThreeValue");
|
logger->logDebug(GwLog::LOG, "Instantiate PageThreeValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -22,9 +22,7 @@ class PageThreeValues : public Page
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
class PageTwoValues : public Page
|
class PageTwoValues : public Page
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageTwoValues(CommonData &common){
|
PageTwoValues(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageTwoValue");
|
logger->logDebug(GwLog::LOG, "Instantiate PageTwoValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -22,9 +22,7 @@ class PageTwoValues : public Page
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Old values for hold function
|
// Old values for hold function
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
|
|
|
@ -15,12 +15,9 @@ private:
|
||||||
char mode = 'D'; // display mode (A)nalog | (D)igital
|
char mode = 'D'; // display mode (A)nalog | (D)igital
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageVoltage(CommonData &common){
|
PageVoltage(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
config = commonData->config;
|
logger->logDebug(GwLog::LOG, "Instantiate PageVoltage");
|
||||||
logger = commonData->logger;
|
|
||||||
|
|
||||||
logger->logDebug(GwLog::LOG,"Instantiate PageVoltage");
|
|
||||||
if (hasFRAM) {
|
if (hasFRAM) {
|
||||||
average = fram.read(FRAM_VOLTAGE_AVG);
|
average = fram.read(FRAM_VOLTAGE_AVG);
|
||||||
trend = fram.read(FRAM_VOLTAGE_TREND);
|
trend = fram.read(FRAM_VOLTAGE_TREND);
|
||||||
|
@ -29,17 +26,17 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
~PageVoltage(){
|
~PageVoltage(){
|
||||||
logger->logDebug(GwLog::LOG,"Destroy PageVoltage");
|
logger->logDebug(GwLog::LOG, "Destroy PageVoltage");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setupKeys(){
|
void setupKeys(){
|
||||||
Page::setupKeys();
|
Page::setupKeys();
|
||||||
commonData->keydata[0].label = "AVG";
|
commonData->keydata[0].label = "AVG";
|
||||||
commonData->keydata[1].label = "MODE";
|
commonData->keydata[1].label = "MODE";
|
||||||
commonData->keydata[4].label = "TRD";
|
commonData->keydata[4].label = "TRD";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Change average
|
// Change average
|
||||||
if(key == 1){
|
if(key == 1){
|
||||||
average ++;
|
average ++;
|
||||||
|
@ -109,9 +106,7 @@ public:
|
||||||
epd->fillRect(x + 16, y + 11, 6, 3, color);
|
epd->fillRect(x + 16, y + 11, 6, 3, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
bool simulation = config->getBool(config->useSimuData);
|
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
|
char mode = 'W'; // display mode (W)hite | (L)ogo | (M)FD logo
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageWhite(CommonData &common){
|
PageWhite(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite");
|
logger->logDebug(GwLog::LOG, "Instantiate PageWhite");
|
||||||
refreshtime = 15000;
|
refreshtime = 15000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
// Get config data
|
// Get config data
|
||||||
String flashLED = config->getString(config->flashLED);
|
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
|
char source = 'A'; // data source (A)pparent | (T)rue
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageWind(CommonData &common){
|
PageWind(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageWind");
|
logger->logDebug(GwLog::LOG, "Instantiate PageWind");
|
||||||
if (hasFRAM) {
|
if (hasFRAM) {
|
||||||
lp = fram.read(FRAM_WIND_SIZE);
|
lp = fram.read(FRAM_WIND_SIZE);
|
||||||
source = fram.read(FRAM_WIND_SRC);
|
source = fram.read(FRAM_WIND_SRC);
|
||||||
|
@ -231,7 +231,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setupKeys(){
|
void setupKeys(){
|
||||||
Page::setupKeys();
|
Page::setupKeys();
|
||||||
commonData->keydata[0].label = "MODE";
|
commonData->keydata[0].label = "MODE";
|
||||||
if (mode == 'X') {
|
if (mode == 'X') {
|
||||||
|
@ -243,7 +243,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key functions
|
// Key functions
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
|
|
||||||
if(key == 1){ // Mode switch
|
if(key == 1){ // Mode switch
|
||||||
if(mode == 'N'){
|
if(mode == 'N'){
|
||||||
|
@ -297,10 +297,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData)
|
int displayPage(PageData &pageData) {
|
||||||
{
|
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
static String unit1old = "";
|
static String unit1old = "";
|
||||||
|
|
|
@ -57,13 +57,12 @@ class PageWindPlot : public Page {
|
||||||
bool showTWS = true; // Show TWS value in chart area
|
bool showTWS = true; // Show TWS value in chart area
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageWindPlot(CommonData& common)
|
PageWindPlot(CommonData& common) : Page(common)
|
||||||
{
|
{
|
||||||
commonData = &common;
|
logger->logDebug(GwLog::LOG, "Instantiate PageWindPlot");
|
||||||
common.logger->logDebug(GwLog::LOG, "Instantiate PageWindPlot");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setupKeys()
|
void setupKeys()
|
||||||
{
|
{
|
||||||
Page::setupKeys();
|
Page::setupKeys();
|
||||||
// commonData->keydata[0].label = "MODE";
|
// commonData->keydata[0].label = "MODE";
|
||||||
|
@ -72,7 +71,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key functions
|
// Key functions
|
||||||
virtual int handleKey(int key)
|
int handleKey(int key)
|
||||||
{
|
{
|
||||||
// Set chart mode TWD | TWS -> to be implemented
|
// Set chart mode TWD | TWS -> to be implemented
|
||||||
if (key == 1) {
|
if (key == 1) {
|
||||||
|
@ -114,10 +113,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData& pageData)
|
int displayPage(PageData& pageData) {
|
||||||
{
|
|
||||||
GwConfigHandler* config = commonData->config;
|
|
||||||
GwLog* logger = commonData->logger;
|
|
||||||
|
|
||||||
float twsValue; // TWS value in chart area
|
float twsValue; // TWS value in chart area
|
||||||
static String twdName, twdUnit; // TWD name and unit
|
static String twdName, twdUnit; // TWD name and unit
|
||||||
|
|
|
@ -10,13 +10,13 @@ class PageWindRose : public Page
|
||||||
int16_t lp = 80; // Pointer length
|
int16_t lp = 80; // Pointer length
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageWindRose(CommonData &common){
|
PageWindRose(CommonData &common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageWindRose");
|
logger->logDebug(GwLog::LOG, "Instantiate PageWindRose");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key functions
|
// Key functions
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -25,9 +25,7 @@ public:
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData) {
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
static String unit1old = "";
|
static String unit1old = "";
|
||||||
|
|
|
@ -10,13 +10,13 @@ class PageWindRoseFlex : public Page
|
||||||
int16_t lp = 80; // Pointer length
|
int16_t lp = 80; // Pointer length
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageWindRoseFlex(CommonData &common){
|
PageWindRoseFlex(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageWindRoseFlex");
|
logger->logDebug(GwLog::LOG, "Instantiate PageWindRoseFlex");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key functions
|
// Key functions
|
||||||
virtual int handleKey(int key){
|
int handleKey(int key){
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if(key == 11){
|
if(key == 11){
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -26,8 +26,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayPage(PageData &pageData){
|
int displayPage(PageData &pageData){
|
||||||
GwConfigHandler *config = commonData->config;
|
|
||||||
GwLog *logger = commonData->logger;
|
|
||||||
|
|
||||||
static String svalue1old = "";
|
static String svalue1old = "";
|
||||||
static String unit1old = "";
|
static String unit1old = "";
|
||||||
|
@ -142,7 +140,7 @@ public:
|
||||||
|
|
||||||
// Logging boat values
|
// Logging boat values
|
||||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageWindRoseFlex, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4, name5.c_str(), value5, name6.c_str(), value6);
|
LOG_DEBUG(GwLog::LOG, "Drawing at PageWindRoseFlex, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f, %s:%f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4, name5.c_str(), value5, name6.c_str(), value6);
|
||||||
|
|
||||||
// Draw page
|
// Draw page
|
||||||
//***********************************************************
|
//***********************************************************
|
||||||
|
|
|
@ -33,11 +33,11 @@ class PageXTETrack : public Page
|
||||||
bool holdvalues = false;
|
bool holdvalues = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageXTETrack(CommonData &common){
|
PageXTETrack(CommonData &common) : Page(common)
|
||||||
commonData = &common;
|
{
|
||||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageXTETrack");
|
logger->logDebug(GwLog::LOG, "Instantiate PageXTETrack");
|
||||||
simulation = common.config->getBool(common.config->useSimuData);
|
simulation = config->getBool(config->useSimuData);
|
||||||
holdvalues = common.config->getBool(common.config->holdvalues);
|
holdvalues = config->getBool(config->holdvalues);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawSegment(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
|
void drawSegment(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
|
||||||
|
|
|
@ -130,6 +130,12 @@ protected:
|
||||||
GwConfigHandler *config;
|
GwConfigHandler *config;
|
||||||
GwLog *logger;
|
GwLog *logger;
|
||||||
public:
|
public:
|
||||||
|
Page(){}
|
||||||
|
Page(CommonData &common) {
|
||||||
|
commonData = &common;
|
||||||
|
config = commonData->config;
|
||||||
|
logger = commonData->logger;
|
||||||
|
}
|
||||||
int refreshtime = 1000;
|
int refreshtime = 1000;
|
||||||
virtual int displayPage(PageData &pageData)=0;
|
virtual int displayPage(PageData &pageData)=0;
|
||||||
virtual void displayNew(PageData &pageData){}
|
virtual void displayNew(PageData &pageData){}
|
||||||
|
|
Loading…
Reference in New Issue