Fixing simulation in page clock

This commit is contained in:
norbert-walter 2022-03-11 12:17:32 +01:00
parent f73ccfbe5c
commit 9e03b3cb4a
1 changed files with 27 additions and 17 deletions

View File

@ -4,7 +4,6 @@
class PageClock : public Page class PageClock : public Page
{ {
bool keylock = false; // Keylock bool keylock = false; // Keylock
int16_t lp = 80; // Pointer length
public: public:
PageClock(CommonData &common){ PageClock(CommonData &common){
@ -31,6 +30,9 @@ public:
static String svalue2old = ""; static String svalue2old = "";
static String unit2old = ""; static String unit2old = "";
double value1 = 0;
double value2 = 0;
// 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);
@ -44,7 +46,12 @@ public:
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue) GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
String name1 = bvalue1->getName().c_str(); // Value name String name1 = bvalue1->getName().c_str(); // Value name
name1 = name1.substring(0, 6); // String length limit for value name name1 = name1.substring(0, 6); // String length limit for value name
double value1 = bvalue1->value; // Value as double in SI unit if(simulation == false){
value1 = bvalue1->value; // Value as double in SI unit
}
else{
value1 = 38160; // Simulation data for time value 11:36 in seconds
} // Other simulation data see OBP60Formater.cpp
bool valid1 = bvalue1->valid; // Valid information bool valid1 = bvalue1->valid; // Valid information
String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places String svalue1 = formatValue(bvalue1, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value String unit1 = formatValue(bvalue1, commonData).unit; // Unit of value
@ -57,7 +64,7 @@ public:
GwApi::BoatValue *bvalue2 = pageData.values[1]; // First element in list (only one value by PageOneValue) GwApi::BoatValue *bvalue2 = pageData.values[1]; // First element in list (only one value by PageOneValue)
String name2 = bvalue2->getName().c_str(); // Value name String name2 = bvalue2->getName().c_str(); // Value name
name2 = name2.substring(0, 6); // String length limit for value name name2 = name2.substring(0, 6); // String length limit for value name
double value2 = bvalue2->value; // Value as double in SI unit value2 = bvalue2->value; // Value as double in SI unit
bool valid2 = bvalue2->valid; // Valid information bool valid2 = bvalue2->valid; // Valid information
String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places String svalue2 = formatValue(bvalue2, commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value String unit2 = formatValue(bvalue2, commonData).unit; // Unit of value
@ -104,11 +111,6 @@ public:
display.setFont(&Ubuntu_Bold12pt7b); display.setFont(&Ubuntu_Bold12pt7b);
display.setCursor(10, 95); display.setCursor(10, 95);
display.print("Date"); // Name display.print("Date"); // Name
display.setFont(&Ubuntu_Bold12pt7b);
display.setCursor(185, 100);
display.print(" ");
display.print(unit2); // Unit
} }
else{ else{
display.setFont(&Ubuntu_Bold8pt7b); display.setFont(&Ubuntu_Bold8pt7b);
@ -117,11 +119,6 @@ public:
display.setFont(&Ubuntu_Bold12pt7b); display.setFont(&Ubuntu_Bold12pt7b);
display.setCursor(10, 95); display.setCursor(10, 95);
display.print("Date"); // Name display.print("Date"); // Name
display.setFont(&Ubuntu_Bold12pt7b);
display.setCursor(185, 100);
display.print(" ");
display.print(unit2old); // Unit
} }
// Horizintal separator left // Horizintal separator left
@ -189,8 +186,8 @@ public:
//******************************************************************************************* //*******************************************************************************************
// Draw wind rose // Draw clock
int rWindGraphic = 110; // Radius of grafic instrument int rWindGraphic = 110; // Radius of clock
float pi = 3.141592; float pi = 3.141592;
display.fillCircle(200, 150, rWindGraphic + 10, pixelcolor); // Outer circle display.fillCircle(200, 150, rWindGraphic + 10, pixelcolor); // Outer circle
@ -252,6 +249,19 @@ public:
} }
} }
// Print Unit in clock
display.setTextColor(textcolor);
if(holdvalues == false){
display.setFont(&Ubuntu_Bold12pt7b);
display.setCursor(175, 110);
display.print(unit2); // Unit
}
else{
display.setFont(&Ubuntu_Bold12pt7b);
display.setCursor(175, 110);
display.print(unit2old); // Unit
}
// Clock values // Clock values
double hour = 0; double hour = 0;
double minute = 0; double minute = 0;
@ -262,7 +272,7 @@ public:
// Draw hour pointer // Draw hour pointer
float startwidth = 8; // Start width of pointer float startwidth = 8; // Start width of pointer
if(valid1 == true || holdvalues == true){ if(valid1 == true || holdvalues == true || simulation == true){
float sinx=sin(hour * 30.0 * pi / 180); // Hour float sinx=sin(hour * 30.0 * pi / 180); // Hour
float cosx=cos(hour * 30.0 * pi / 180); float cosx=cos(hour * 30.0 * pi / 180);
// Normal pointer // Normal pointer
@ -288,7 +298,7 @@ public:
// Draw minute pointer // Draw minute pointer
startwidth = 8; // Start width of pointer startwidth = 8; // Start width of pointer
if(valid1 == true || holdvalues == true){ if(valid1 == true || holdvalues == true || simulation == true){
float sinx=sin(minute * 6.0 * pi / 180); // Minute float sinx=sin(minute * 6.0 * pi / 180); // Minute
float cosx=cos(minute * 6.0 * pi / 180); float cosx=cos(minute * 6.0 * pi / 180);
// Normal pointer // Normal pointer