Skip to content

Commit

Permalink
Fix for issue #79
Browse files Browse the repository at this point in the history
  • Loading branch information
norbert-walter committed Nov 2, 2024
1 parent c5449a9 commit db69b37
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions lib/obp60task/PageClock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ bool keylock = false; // Keylock
static String svalue2old = "";
static String unit2old = "";
static String svalue3old = "";
static String svalue4old = "";
static String unit3old = "";

static String svalue5old = "";
static String svalue6old = "";

double value1 = 0;
double value2 = 0;
double value3 = 0;

// Get config data
String lengthformat = config->getString(config->lengthFormat);
Expand Down Expand Up @@ -66,7 +70,7 @@ bool keylock = false; // Keylock
}

// Get boat values for GPS date
GwApi::BoatValue *bvalue2 = pageData.values[1]; // First element in list (only one value by PageOneValue)
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue)
String name2 = bvalue2->getName().c_str(); // Value name
name2 = name2.substring(0, 6); // String length limit for value name
value2 = bvalue2->value; // Value as double in SI unit
Expand All @@ -78,6 +82,19 @@ bool keylock = false; // Keylock
unit2old = unit2; // Save old unit
}

// Get boat values for HDOP date
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list (only one value by PageOneValue)
String name3 = bvalue3->getName().c_str(); // Value name
name3 = name3.substring(0, 6); // String length limit for value name
value3 = bvalue3->value; // Value as double in SI unit
bool valid3 = bvalue3->valid; // Valid information
String svalue3 = formatValue(bvalue3, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
String unit3 = formatValue(bvalue3, commonData).unit; // Unit of value
if(valid3 == true){
svalue3old = svalue3; // Save old value
unit3old = unit3; // Save old unit
}

// Optical warning by limit violation (unused)
if(String(flashLED) == "Limit Violation"){
setBlinkingLED(false);
Expand Down Expand Up @@ -133,16 +150,16 @@ bool keylock = false; // Keylock

// Show values sunrise
String sunrise = "---";
if(valid1 == true && valid2 == true){
if(valid1 == true && valid2 == true && valid3 == true){
sunrise = String(commonData.sundata.sunriseHour) + ":" + String(commonData.sundata.sunriseMinute + 100).substring(1);
svalue3old = sunrise;
svalue5old = sunrise;
}

getdisplay().setTextColor(textcolor);
getdisplay().setFont(&Ubuntu_Bold8pt7b);
getdisplay().setCursor(335, 65);
if(holdvalues == false) getdisplay().print(sunrise); // Value
else getdisplay().print(svalue3old);
else getdisplay().print(svalue5old);
getdisplay().setFont(&Ubuntu_Bold12pt7b);
getdisplay().setCursor(335, 95);
getdisplay().print("SunR"); // Name
Expand All @@ -152,16 +169,16 @@ bool keylock = false; // Keylock

// Show values sunset
String sunset = "---";
if(valid1 == true && valid2 == true){
if(valid1 == true && valid2 == true && valid3 == true){
sunset = String(commonData.sundata.sunsetHour) + ":" + String(commonData.sundata.sunsetMinute + 100).substring(1);
svalue4old = sunset;
svalue6old = sunset;
}

getdisplay().setTextColor(textcolor);
getdisplay().setFont(&Ubuntu_Bold8pt7b);
getdisplay().setCursor(335, 250);
if(holdvalues == false) getdisplay().print(sunset); // Value
else getdisplay().print(svalue4old);
else getdisplay().print(svalue6old);
getdisplay().setFont(&Ubuntu_Bold12pt7b);
getdisplay().setCursor(335, 220);
getdisplay().print("SunS"); // Name
Expand Down Expand Up @@ -350,10 +367,10 @@ static Page *createPage(CommonData &common){
* and will will provide the names of the fixed values we need
*/
PageDescription registerPageClock(
"Clock", // Page name
"Clock", // Page name
createPage, // Action
0, // Number of bus values depends on selection in Web configuration
{"GPST", "GPSD"}, // Bus values we need in the page
{"GPST", "GPSD", "HDOP"}, // Bus values we need in the page
true // Show display header on/off
);

Expand Down

0 comments on commit db69b37

Please sign in to comment.