Add simulation feature to more pages
This commit is contained in:
parent
1174622b4a
commit
7be102127e
|
@ -380,8 +380,14 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
|||
}
|
||||
//########################################################
|
||||
else if (value->getFormat() == "formatXte"){
|
||||
double xte = abs(value->value);
|
||||
rawvalue = value->value;
|
||||
double xte = 0;
|
||||
if (!usesimudata) {
|
||||
xte = abs(value->value);
|
||||
rawvalue = value->value;
|
||||
} else {
|
||||
rawvalue = 6.0 + float(random(0, 4));
|
||||
xte = rawvalue;
|
||||
}
|
||||
if (xte >= 100) {
|
||||
snprintf(buffer,bsize,"%3.0f",value->value);
|
||||
} else if (xte >= 10) {
|
||||
|
|
|
@ -5,10 +5,15 @@
|
|||
|
||||
class PageClock : public Page
|
||||
{
|
||||
public:
|
||||
bool simulation = false;
|
||||
int simtime;
|
||||
|
||||
public:
|
||||
PageClock(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageClock");
|
||||
simulation = config->getBool(config->useSimuData);
|
||||
simtime = 38160; // time value 11:36
|
||||
}
|
||||
|
||||
// Key functions
|
||||
|
@ -42,7 +47,6 @@ public:
|
|||
|
||||
// Get config data
|
||||
String lengthformat = config->getString(config->lengthFormat);
|
||||
bool simulation = config->getBool(config->useSimuData);
|
||||
bool holdvalues = config->getBool(config->holdvalues);
|
||||
String flashLED = config->getString(config->flashLED);
|
||||
String backlightMode = config->getString(config->backlight);
|
||||
|
@ -57,7 +61,7 @@ public:
|
|||
value1 = bvalue1->value; // Value as double in SI unit
|
||||
}
|
||||
else{
|
||||
value1 = 38160; // Simulation data for time value 11:36 in seconds
|
||||
value1 = simtime++; // Simulation data for time value 11:36 in seconds
|
||||
} // Other simulation data see OBP60Formater.cpp
|
||||
bool valid1 = bvalue1->valid; // Valid information
|
||||
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
|
@ -137,6 +141,8 @@ public:
|
|||
if(valid1 == true && valid2 == true && valid3 == true){
|
||||
sunrise = String(commonData->sundata.sunriseHour) + ":" + String(commonData->sundata.sunriseMinute + 100).substring(1);
|
||||
svalue5old = sunrise;
|
||||
} else if (simulation) {
|
||||
sunrise = String("06:42");
|
||||
}
|
||||
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
|
@ -155,6 +161,8 @@ public:
|
|||
if(valid1 == true && valid2 == true && valid3 == true){
|
||||
sunset = String(commonData->sundata.sunsetHour) + ":" + String(commonData->sundata.sunsetMinute + 100).substring(1);
|
||||
svalue6old = sunset;
|
||||
} else if (simulation) {
|
||||
sunset = String("21:03");
|
||||
}
|
||||
|
||||
getdisplay().setFont(&Ubuntu_Bold8pt7b);
|
||||
|
|
|
@ -66,6 +66,10 @@ static unsigned char fish_bits[] = {
|
|||
|
||||
class PageFluid : public Page
|
||||
{
|
||||
bool simulation = false;
|
||||
double simgoto;
|
||||
double simval;
|
||||
double simstep;
|
||||
bool holdvalues = false;
|
||||
int fluidtype;
|
||||
|
||||
|
@ -73,7 +77,11 @@ class PageFluid : public Page
|
|||
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);
|
||||
simval = double(random(0, 100));
|
||||
simgoto = double(random(0, 100));
|
||||
simstep = (simgoto - simval) / 20.0;
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
|
@ -109,8 +117,18 @@ class PageFluid : public Page
|
|||
|
||||
GwApi::BoatValue *bvalue1 = pageData.values[0];
|
||||
String name1 = bvalue1->getName();
|
||||
if (holdvalues and bvalue1->valid) {
|
||||
value1old = bvalue1->value;
|
||||
double fluidlevel = bvalue1->value;
|
||||
if (!simulation) {
|
||||
if (holdvalues and bvalue1->valid) {
|
||||
value1old = bvalue1->value;
|
||||
}
|
||||
} else {
|
||||
fluidlevel = simval;
|
||||
simval += simstep;
|
||||
if ((simgoto - simval) < 1.5 * simstep) {
|
||||
simgoto = double(random(0, 100));
|
||||
simstep = (simgoto - simval) / 20.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Logging boat values
|
||||
|
@ -148,8 +166,8 @@ class PageFluid : public Page
|
|||
|
||||
// value down centered
|
||||
char buffer[6];
|
||||
if (bvalue1->valid) {
|
||||
snprintf(buffer, 6, "%3.0f%%", bvalue1->value);
|
||||
if (bvalue1->valid or simulation) {
|
||||
snprintf(buffer, 6, "%3.0f%%", fluidlevel);
|
||||
} else {
|
||||
strcpy(buffer, "---");
|
||||
}
|
||||
|
@ -222,14 +240,14 @@ class PageFluid : public Page
|
|||
}
|
||||
|
||||
// pointer
|
||||
if (bvalue1->valid) {
|
||||
if (bvalue1->valid or simulation) {
|
||||
pts = {
|
||||
{c.x - 1, c.y - (r - 20)},
|
||||
{c.x + 1, c.y - (r - 20)},
|
||||
{c.x + 6, c.y + 15},
|
||||
{c.x - 6, c.y + 15}
|
||||
};
|
||||
fillPoly4(rotatePoints(c, pts, -120 + bvalue1->value * 2.4), commonData->fgcolor);
|
||||
fillPoly4(rotatePoints(c, pts, -120 + fluidlevel * 2.4), commonData->fgcolor);
|
||||
// Pointer axis is white
|
||||
getdisplay().fillCircle(c.x, c.y, 6, commonData->bgcolor);
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ public:
|
|||
|
||||
// Get config data
|
||||
String lengthformat = config->getString(config->lengthFormat);
|
||||
// bool simulation = config->getBool(config->useSimuData);
|
||||
bool simulation = config->getBool(config->useSimuData);
|
||||
bool holdvalues = config->getBool(config->holdvalues);
|
||||
String flashLED = config->getString(config->flashLED);
|
||||
String backlightMode = config->getString(config->backlight);
|
||||
|
@ -338,6 +338,9 @@ public:
|
|||
name2 = name2.substring(0, 6); // String length limit for value name
|
||||
double value2 = bvalue2->value; // Value as double in SI unit
|
||||
// bool valid2 = bvalue2->valid; // Valid information
|
||||
if (simulation) {
|
||||
value2 = 0.62731; // some random value
|
||||
}
|
||||
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
|
||||
|
||||
|
@ -402,7 +405,7 @@ public:
|
|||
getdisplay().fillCircle(c.x, c.y, lp + 1, commonData->bgcolor);
|
||||
|
||||
// Wind pointer
|
||||
if (bvalue2->valid) {
|
||||
if (bvalue2->valid or simulation) {
|
||||
uint8_t lp0 = lp * 0.6; // effective pointer outside size
|
||||
uint8_t lp1 = lp * 0.4; // effective pointer inside size
|
||||
// zero position
|
||||
|
@ -478,7 +481,7 @@ public:
|
|||
}
|
||||
|
||||
// Wind pointer (angle)
|
||||
if (bvalue2->valid) {
|
||||
if (bvalue2->valid or simulation) {
|
||||
float alpha = RadToDeg(value2);
|
||||
bool port = (alpha > 180);
|
||||
if (port) {
|
||||
|
@ -594,7 +597,7 @@ public:
|
|||
getdisplay().print("kts");
|
||||
|
||||
// Wind pointer (angle)
|
||||
if (bvalue2->valid) {
|
||||
if (bvalue2->valid or simulation) {
|
||||
float alpha = RadToDeg(value2);
|
||||
getdisplay().fillCircle(c.x, c.y, 8, commonData->fgcolor);
|
||||
pts = {
|
||||
|
|
|
@ -28,10 +28,15 @@ static unsigned char ship_bits[] PROGMEM = {
|
|||
|
||||
class PageXTETrack : public Page
|
||||
{
|
||||
bool simulation = false;
|
||||
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);
|
||||
}
|
||||
|
||||
void drawSegment(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
|
||||
|
@ -140,7 +145,7 @@ class PageXTETrack : public Page
|
|||
String sval_wpname = "no data";
|
||||
|
||||
if (valid) {
|
||||
sval_wpname = "Tonne 122";
|
||||
sval_wpname = "Tonne 122";
|
||||
}
|
||||
|
||||
getdisplay().setFont(&Ubuntu_Bold10pt7b);
|
||||
|
@ -153,7 +158,12 @@ class PageXTETrack : public Page
|
|||
|
||||
// draw course segments
|
||||
|
||||
double diff = bv_cog->value - bv_btw->value;
|
||||
double diff;
|
||||
if (!simulation) {
|
||||
diff = bv_cog->value - bv_btw->value;
|
||||
} else {
|
||||
diff = 7.0;
|
||||
}
|
||||
if (diff < -180) {
|
||||
diff += 360;
|
||||
} else if (diff > 180) {
|
||||
|
|
Loading…
Reference in New Issue