mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-09-11 19:55:14 +02:00
Enable pages Battery2, Generator, Solar, RollPitch for small decimals
This commit is contained in:
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
class PageBattery2 : public Page
|
class PageBattery2 : public Page
|
||||||
{
|
{
|
||||||
|
static constexpr int8_t LEFT = 0;
|
||||||
|
static constexpr int8_t CENTER = 1;
|
||||||
|
static constexpr int8_t RIGHT = 2;
|
||||||
|
|
||||||
bool init = false; // Marker for init done
|
bool init = false; // Marker for init done
|
||||||
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
|
||||||
bool trend = true; // Trend indicator [0|1], 0=off, 1=on
|
bool trend = true; // Trend indicator [0|1], 0=off, 1=on
|
||||||
@@ -65,6 +69,7 @@ public:
|
|||||||
String batType = config->getString(config->batteryType);
|
String batType = config->getString(config->batteryType);
|
||||||
String backlightMode = config->getString(config->backlight);
|
String backlightMode = config->getString(config->backlight);
|
||||||
String powerSensor = config->getString(config->usePowSensor1);
|
String powerSensor = config->getString(config->usePowSensor1);
|
||||||
|
bool smallDecimals = config->getBool(config->smallDecimals);
|
||||||
|
|
||||||
double value1 = 0; // Battery voltage
|
double value1 = 0; // Battery voltage
|
||||||
double value2 = 0; // Battery current
|
double value2 = 0; // Battery current
|
||||||
@@ -198,20 +203,16 @@ public:
|
|||||||
getdisplay().print(batType);
|
getdisplay().print(batType);
|
||||||
|
|
||||||
// Show voltage type
|
// Show voltage type
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
|
||||||
getdisplay().setCursor(10, 140);
|
|
||||||
int bvoltage = 0;
|
int bvoltage = 0;
|
||||||
if(String(batVoltage) == "12V") bvoltage = 12;
|
if(String(batVoltage) == "12V") bvoltage = 12;
|
||||||
else bvoltage = 24;
|
else bvoltage = 24;
|
||||||
getdisplay().print(bvoltage);
|
printBoatValue(String(bvoltage), 10, 140, LEFT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("V");
|
getdisplay().print("V");
|
||||||
|
|
||||||
// Show battery capacity
|
// Show battery capacity
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalueCapacity = (batCapacity <= 999) ? String(batCapacity) : String(float(batCapacity/1000.0), 1);
|
||||||
getdisplay().setCursor(10, 200);
|
printBoatValue(svalueCapacity, 10, 200, LEFT, 20, smallDecimals);
|
||||||
if(batCapacity <= 999) getdisplay().print(batCapacity, 0);
|
|
||||||
if(batCapacity > 999) getdisplay().print(float(batCapacity/1000.0), 1);
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
if(batCapacity <= 999) getdisplay().print("Ah");
|
if(batCapacity <= 999) getdisplay().print("Ah");
|
||||||
if(batCapacity > 999) getdisplay().print("kAh");
|
if(batCapacity > 999) getdisplay().print("kAh");
|
||||||
@@ -248,20 +249,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show fill level in percent
|
// Show fill level in percent
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
printBoatValue(String(batPercentage), 150, 200, LEFT, 20, smallDecimals);
|
||||||
getdisplay().setCursor(150, 200);
|
|
||||||
getdisplay().print(batPercentage);
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("%");
|
getdisplay().print("%");
|
||||||
|
|
||||||
// Show time to full discharge
|
// Show time to full discharge
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalueRange;
|
||||||
getdisplay().setCursor(150, 260);
|
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||||
if(batRange < 9.9) getdisplay().print(batRange, 1);
|
svalueRange = (batRange < 9.9) ? String(batRange, 1) : String(batRange, 0);
|
||||||
else getdisplay().print(batRange, 0);
|
|
||||||
}
|
}
|
||||||
else getdisplay().print("--");
|
else{
|
||||||
|
svalueRange = "--";
|
||||||
|
}
|
||||||
|
printBoatValue(svalueRange, 150, 260, LEFT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("h");
|
getdisplay().print("h");
|
||||||
|
|
||||||
@@ -282,54 +282,38 @@ public:
|
|||||||
getdisplay().print("Sensor Modul");
|
getdisplay().print("Sensor Modul");
|
||||||
|
|
||||||
// Reading bus data or using simulation data
|
// Reading bus data or using simulation data
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue1;
|
||||||
getdisplay().setCursor(260, 140);
|
|
||||||
if(simulation == true){
|
|
||||||
if(batVoltage == "12V"){
|
|
||||||
value1 = 12.0;
|
|
||||||
}
|
|
||||||
if(batVoltage == "24V"){
|
|
||||||
value1 = 24.0;
|
|
||||||
}
|
|
||||||
value1 += float(random(0, 5)) / 10; // Simulation data
|
|
||||||
getdisplay().print(value1,1);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// Check for valid real data, display also if hold values activated
|
// Check for valid real data, display also if hold values activated
|
||||||
if(valid1 == true || holdvalues == true){
|
if(valid1 == true || holdvalues == true){
|
||||||
// Resolution switching
|
svalue1 = formatValue(value1, String("formatXdr:U:V"), *commonData);
|
||||||
if(value1 <= 9.9) getdisplay().print(value1, 2);
|
} else {
|
||||||
if(value1 > 9.9 && value1 <= 99.9)getdisplay().print(value1, 1);
|
svalue1 = "---"; // Missing bus data
|
||||||
if(value1 > 99.9) getdisplay().print(value1, 0);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
getdisplay().print("---"); // Missing bus data
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
printBoatValue(svalue1, 355, 140, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("V");
|
getdisplay().print("V");
|
||||||
|
|
||||||
// Show actual current in A
|
// Show actual current in A
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue2;
|
||||||
getdisplay().setCursor(260, 200);
|
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||||
if(value2 <= 9.9) getdisplay().print(value2, 2);
|
svalue2 = formatValue(value2, String("formatXdr:I:A"), *commonData);
|
||||||
if(value2 > 9.9 && value2 <= 99.9)getdisplay().print(value2, 1);
|
|
||||||
if(value2 > 99.9) getdisplay().print(value2, 0);
|
|
||||||
}
|
}
|
||||||
else getdisplay().print("---");
|
else{
|
||||||
|
svalue2 = "---";
|
||||||
|
}
|
||||||
|
printBoatValue(svalue2, 355, 200, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("A");
|
getdisplay().print("A");
|
||||||
|
|
||||||
// Show actual consumption in W
|
// Show actual consumption in W
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue3;
|
||||||
getdisplay().setCursor(260, 260);
|
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||||
if(value3 <= 9.9) getdisplay().print(value3, 2);
|
svalue3 = formatValue(value3, String("formatXdr:G:"), *commonData);
|
||||||
if(value3 > 9.9 && value3 <= 99.9)getdisplay().print(value3, 1);
|
|
||||||
if(value3 > 99.9) getdisplay().print(value3, 0);
|
|
||||||
}
|
}
|
||||||
else getdisplay().print("---");
|
else{
|
||||||
|
svalue3 = "---";
|
||||||
|
}
|
||||||
|
printBoatValue(svalue3, 355, 260, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("W");
|
getdisplay().print("W");
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
class PageGenerator : public Page
|
class PageGenerator : public Page
|
||||||
{
|
{
|
||||||
|
static constexpr int8_t LEFT = 0;
|
||||||
|
static constexpr int8_t CENTER = 1;
|
||||||
|
static constexpr int8_t RIGHT = 2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageGenerator(CommonData &common){
|
PageGenerator(CommonData &common){
|
||||||
commonData = &common;
|
commonData = &common;
|
||||||
@@ -32,6 +36,7 @@ public:
|
|||||||
int genPower = config->getInt(config->genPower);
|
int genPower = config->getInt(config->genPower);
|
||||||
String backlightMode = config->getString(config->backlight);
|
String backlightMode = config->getString(config->backlight);
|
||||||
String powerSensor = config->getString(config->usePowSensor3);
|
String powerSensor = config->getString(config->usePowSensor3);
|
||||||
|
bool smallDecimals = config->getBool(config->smallDecimals);
|
||||||
|
|
||||||
double value1 = 0; // Solar voltage
|
double value1 = 0; // Solar voltage
|
||||||
double value2 = 0; // Solar current
|
double value2 = 0; // Solar current
|
||||||
@@ -95,20 +100,16 @@ public:
|
|||||||
getdisplay().print("Generator");
|
getdisplay().print("Generator");
|
||||||
|
|
||||||
// Show voltage type
|
// Show voltage type
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
|
||||||
getdisplay().setCursor(10, 140);
|
|
||||||
int bvoltage = 0;
|
int bvoltage = 0;
|
||||||
if(String(batVoltage) == "12V") bvoltage = 12;
|
if(String(batVoltage) == "12V") bvoltage = 12;
|
||||||
else bvoltage = 24;
|
else bvoltage = 24;
|
||||||
getdisplay().print(bvoltage);
|
printBoatValue(String(bvoltage), 10, 140, LEFT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("V");
|
getdisplay().print("V");
|
||||||
|
|
||||||
// Show solar power
|
// Show solar power
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalueGenPower = (genPower <= 999) ? String(genPower) : String(float(genPower/1000.0), 1);
|
||||||
getdisplay().setCursor(10, 200);
|
printBoatValue(svalueGenPower, 10, 200, LEFT, 20, smallDecimals);
|
||||||
if(genPower <= 999) getdisplay().print(genPower, 0);
|
|
||||||
if(genPower > 999) getdisplay().print(float(genPower/1000.0), 1);
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
if(genPower <= 999) getdisplay().print("W");
|
if(genPower <= 999) getdisplay().print("W");
|
||||||
if(genPower > 999) getdisplay().print("kW");
|
if(genPower > 999) getdisplay().print("kW");
|
||||||
@@ -124,9 +125,7 @@ public:
|
|||||||
generatorGraphic(200, 95, commonData->fgcolor, commonData->bgcolor);
|
generatorGraphic(200, 95, commonData->fgcolor, commonData->bgcolor);
|
||||||
|
|
||||||
// Show load level in percent
|
// Show load level in percent
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
printBoatValue(String(genPercentage), 150, 200, LEFT, 20, smallDecimals);
|
||||||
getdisplay().setCursor(150, 200);
|
|
||||||
getdisplay().print(genPercentage);
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("%");
|
getdisplay().print("%");
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
@@ -151,54 +150,37 @@ public:
|
|||||||
getdisplay().print("Sensor Modul");
|
getdisplay().print("Sensor Modul");
|
||||||
|
|
||||||
// Reading bus data or using simulation data
|
// Reading bus data or using simulation data
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue1;
|
||||||
getdisplay().setCursor(260, 140);
|
|
||||||
if(simulation == true){
|
|
||||||
if(batVoltage == "12V"){
|
|
||||||
value1 = 12.0;
|
|
||||||
}
|
|
||||||
if(batVoltage == "24V"){
|
|
||||||
value1 = 24.0;
|
|
||||||
}
|
|
||||||
value1 += float(random(0, 5)) / 10; // Simulation data
|
|
||||||
getdisplay().print(value1,1);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// Check for valid real data, display also if hold values activated
|
|
||||||
if(valid1 == true || holdvalues == true){
|
if(valid1 == true || holdvalues == true){
|
||||||
// Resolution switching
|
svalue1 = formatValue(value1, String("formatXdr:U:V"), *commonData);
|
||||||
if(value1 <= 9.9) getdisplay().print(value1, 2);
|
} else {
|
||||||
if(value1 > 9.9 && value1 <= 99.9)getdisplay().print(value1, 1);
|
svalue1 = "---"; // Missing bus data
|
||||||
if(value1 > 99.9) getdisplay().print(value1, 0);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
getdisplay().print("---"); // Missing bus data
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
printBoatValue(svalue1, 355, 140, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("V");
|
getdisplay().print("V");
|
||||||
|
|
||||||
// Show actual current in A
|
// Show actual current in A
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue2;
|
||||||
getdisplay().setCursor(260, 200);
|
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||||
if(value2 <= 9.9) getdisplay().print(value2, 2);
|
svalue2 = formatValue(value2, String("formatXdr:I:A"), *commonData);
|
||||||
if(value2 > 9.9 && value2 <= 99.9)getdisplay().print(value2, 1);
|
|
||||||
if(value2 > 99.9) getdisplay().print(value2, 0);
|
|
||||||
}
|
}
|
||||||
else getdisplay().print("---");
|
else{
|
||||||
|
svalue2 = "---";
|
||||||
|
}
|
||||||
|
printBoatValue(svalue2, 355, 200, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("A");
|
getdisplay().print("A");
|
||||||
|
|
||||||
// Show actual consumption in W
|
// Show actual consumption in W
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue3;
|
||||||
getdisplay().setCursor(260, 260);
|
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||||
if(value3 <= 9.9) getdisplay().print(value3, 2);
|
svalue3 = formatValue(value3, String("formatXdr:G:"), *commonData);
|
||||||
if(value3 > 9.9 && value3 <= 99.9)getdisplay().print(value3, 1);
|
|
||||||
if(value3 > 99.9) getdisplay().print(value3, 0);
|
|
||||||
}
|
}
|
||||||
else getdisplay().print("---");
|
else{
|
||||||
|
svalue3 = "---";
|
||||||
|
}
|
||||||
|
printBoatValue(svalue3, 355, 260, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("W");
|
getdisplay().print("W");
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
class PageRollPitch : public Page
|
class PageRollPitch : public Page
|
||||||
{
|
{
|
||||||
|
static constexpr int8_t LEFT = 0;
|
||||||
|
static constexpr int8_t CENTER = 1;
|
||||||
|
static constexpr int8_t RIGHT = 2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageRollPitch(CommonData &common){
|
PageRollPitch(CommonData &common){
|
||||||
commonData = &common;
|
commonData = &common;
|
||||||
@@ -44,12 +48,15 @@ public:
|
|||||||
double rolloffset = roffset.toFloat()/360*(2*M_PI);
|
double rolloffset = roffset.toFloat()/360*(2*M_PI);
|
||||||
String poffset = config->getString(config->pitchOffset);
|
String poffset = config->getString(config->pitchOffset);
|
||||||
double pitchoffset = poffset.toFloat()/360*(2*M_PI);
|
double pitchoffset = poffset.toFloat()/360*(2*M_PI);
|
||||||
|
bool smallDecimals = config->getBool(config->smallDecimals);
|
||||||
|
|
||||||
// Get boat values for roll
|
// Get boat values for roll
|
||||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (xdrRoll)
|
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (xdrRoll)
|
||||||
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 5); // String length limit for value name
|
||||||
bool valid1 = bvalue1->valid; // Valid information
|
bool valid1 = bvalue1->valid; // Valid information
|
||||||
|
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
||||||
|
unit1 = unit1.substring(0, 4); // String length limit for value unit
|
||||||
if(valid1 == true){
|
if(valid1 == true){
|
||||||
value1 = bvalue1->value + rolloffset; // Raw value for pitch
|
value1 = bvalue1->value + rolloffset; // Raw value for pitch
|
||||||
}
|
}
|
||||||
@@ -73,8 +80,10 @@ public:
|
|||||||
// Get boat values for pitch
|
// Get boat values for pitch
|
||||||
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (xdrPitch)
|
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (xdrPitch)
|
||||||
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 5); // String length limit for value name
|
||||||
bool valid2 = bvalue2->valid; // Valid information
|
bool valid2 = bvalue2->valid; // Valid information
|
||||||
|
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
||||||
|
unit2 = unit2.substring(0, 4); // String length limit for value unit
|
||||||
if(valid2 == true){
|
if(valid2 == true){
|
||||||
value2 = bvalue2->value + pitchoffset; // Raw value for pitch
|
value2 = bvalue2->value + pitchoffset; // Raw value for pitch
|
||||||
}
|
}
|
||||||
@@ -86,7 +95,7 @@ public:
|
|||||||
value2 = 0;
|
value2 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(value2/(2*PI)*360 > -10 && value2/(2*M_PI)*360 < 10){
|
if(value2/(2*M_PI)*360 > -10 && value2/(2*M_PI)*360 < 10){
|
||||||
svalue2 = String(value2/(2*M_PI)*360,1); // Convert raw value to string
|
svalue2 = String(value2/(2*M_PI)*360,1); // Convert raw value to string
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -121,53 +130,44 @@ public:
|
|||||||
getdisplay().setTextColor(commonData->fgcolor);
|
getdisplay().setTextColor(commonData->fgcolor);
|
||||||
|
|
||||||
// Show roll limit
|
// Show roll limit
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
printBoatValue(String(rolllimit), 10, 65, LEFT, 20, smallDecimals); // Value
|
||||||
getdisplay().setCursor(10, 65);
|
|
||||||
getdisplay().print(rolllimit); // Value
|
|
||||||
//getdisplay().print(svalue1); // Value
|
|
||||||
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
getdisplay().setCursor(10, 95);
|
getdisplay().setCursor(10, 95);
|
||||||
getdisplay().print("Limit"); // Name
|
getdisplay().print("Limit"); // Name
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
getdisplay().setCursor(10, 115);
|
getdisplay().setCursor(10, 115);
|
||||||
getdisplay().print("DEG");
|
getdisplay().print("Deg");
|
||||||
|
|
||||||
// Horizintal separator left
|
// Horizintal separator left
|
||||||
getdisplay().fillRect(0, 149, 60, 3, commonData->fgcolor);
|
getdisplay().fillRect(0, 149, 60, 3, commonData->fgcolor);
|
||||||
|
|
||||||
// Show roll value
|
// Show roll value
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
if(holdvalues == false) printBoatValue(svalue1, 101, 270, RIGHT, 20, smallDecimals); // Value
|
||||||
getdisplay().setCursor(10, 270);
|
else printBoatValue(svalue1old, 101, 270, RIGHT, 20, smallDecimals);
|
||||||
if(holdvalues == false) getdisplay().print(svalue1); // Value
|
|
||||||
else getdisplay().print(svalue1old);
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
getdisplay().setCursor(10, 220);
|
getdisplay().setCursor(10, 220);
|
||||||
getdisplay().print(name1); // Name
|
getdisplay().print(name1); // Name
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
getdisplay().setCursor(10, 190);
|
getdisplay().setCursor(10, 190);
|
||||||
getdisplay().print("Deg");
|
getdisplay().print(unit1); // Unit
|
||||||
|
|
||||||
// Horizintal separator right
|
// Horizintal separator right
|
||||||
getdisplay().fillRect(340, 149, 80, 3, commonData->fgcolor);
|
getdisplay().fillRect(340, 149, 80, 3, commonData->fgcolor);
|
||||||
|
|
||||||
// Show pitch value
|
// Show pitch value
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
if(holdvalues == false) printBoatValue(svalue2, 395, 270, RIGHT, 20, smallDecimals); // Value
|
||||||
getdisplay().setCursor(295, 270);
|
else printBoatValue(svalue2old, 395, 270, RIGHT, 20, smallDecimals);
|
||||||
if(holdvalues == false) getdisplay().print(svalue2); // Value
|
|
||||||
else getdisplay().print(svalue2old);
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||||
getdisplay().setCursor(335, 220);
|
drawTextRalign(395, 220, name2); // Name
|
||||||
getdisplay().print(name2); // Name
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
getdisplay().setCursor(335, 190);
|
getdisplay().setCursor(335, 190);
|
||||||
getdisplay().print("Deg");
|
getdisplay().print(unit2); // Unit
|
||||||
|
|
||||||
//*******************************************************************************************
|
//*******************************************************************************************
|
||||||
|
|
||||||
// Draw instrument
|
// Draw instrument
|
||||||
int rInstrument = 100; // Radius of instrument
|
int rInstrument = 100; // Radius of instrument
|
||||||
float pi = 3.141592;
|
|
||||||
|
|
||||||
getdisplay().fillCircle(200, 150, rInstrument + 10, commonData->fgcolor); // Outer circle
|
getdisplay().fillCircle(200, 150, rInstrument + 10, commonData->fgcolor); // Outer circle
|
||||||
getdisplay().fillCircle(200, 150, rInstrument + 7, commonData->bgcolor); // Outer circle
|
getdisplay().fillCircle(200, 150, rInstrument + 7, commonData->bgcolor); // Outer circle
|
||||||
@@ -264,11 +264,11 @@ public:
|
|||||||
int y0 = 150;
|
int y0 = 150;
|
||||||
int x1 = x0 + 50*cos(value1);
|
int x1 = x0 + 50*cos(value1);
|
||||||
int y1 = y0 + 50*sin(value1);
|
int y1 = y0 + 50*sin(value1);
|
||||||
int x2 = x0 + 50*cos(value1 - pi/2);
|
int x2 = x0 + 50*cos(value1 - M_PI/2);
|
||||||
int y2 = y0 + 50*sin(value1 - pi/2);
|
int y2 = y0 + 50*sin(value1 - M_PI/2);
|
||||||
getdisplay().fillTriangle(x0, y0, x1, y1, x2, y2, commonData->bgcolor); // Clear half top side of boat circle (right triangle)
|
getdisplay().fillTriangle(x0, y0, x1, y1, x2, y2, commonData->bgcolor); // Clear half top side of boat circle (right triangle)
|
||||||
x1 = x0 + 50*cos(value1 + pi);
|
x1 = x0 + 50*cos(value1 + M_PI);
|
||||||
y1 = y0 + 50*sin(value1 + pi);
|
y1 = y0 + 50*sin(value1 + M_PI);
|
||||||
getdisplay().fillTriangle(x0, y0, x1, y1, x2, y2, commonData->bgcolor); // Clear half top side of boat circle (left triangle)
|
getdisplay().fillTriangle(x0, y0, x1, y1, x2, y2, commonData->bgcolor); // Clear half top side of boat circle (left triangle)
|
||||||
getdisplay().fillRect(150, 160, 100, 4, commonData->fgcolor); // Water line
|
getdisplay().fillRect(150, 160, 100, 4, commonData->fgcolor); // Water line
|
||||||
|
|
||||||
|
|||||||
+26
-44
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
class PageSolar : public Page
|
class PageSolar : public Page
|
||||||
{
|
{
|
||||||
|
static constexpr int8_t LEFT = 0;
|
||||||
|
static constexpr int8_t CENTER = 1;
|
||||||
|
static constexpr int8_t RIGHT = 2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageSolar(CommonData &common){
|
PageSolar(CommonData &common){
|
||||||
commonData = &common;
|
commonData = &common;
|
||||||
@@ -31,6 +35,7 @@ public:
|
|||||||
int solPower = config->getInt(config->solarPower);
|
int solPower = config->getInt(config->solarPower);
|
||||||
String backlightMode = config->getString(config->backlight);
|
String backlightMode = config->getString(config->backlight);
|
||||||
String powerSensor = config->getString(config->usePowSensor2);
|
String powerSensor = config->getString(config->usePowSensor2);
|
||||||
|
bool smallDecimals = config->getBool(config->smallDecimals);
|
||||||
|
|
||||||
double value1 = 0; // Solar voltage
|
double value1 = 0; // Solar voltage
|
||||||
double value2 = 0; // Solar current
|
double value2 = 0; // Solar current
|
||||||
@@ -91,20 +96,16 @@ public:
|
|||||||
getdisplay().print("Solar");
|
getdisplay().print("Solar");
|
||||||
|
|
||||||
// Show voltage type
|
// Show voltage type
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
|
||||||
getdisplay().setCursor(10, 140);
|
|
||||||
int bvoltage = 0;
|
int bvoltage = 0;
|
||||||
if(String(batVoltage) == "12V") bvoltage = 12;
|
if(String(batVoltage) == "12V") bvoltage = 12;
|
||||||
else bvoltage = 24;
|
else bvoltage = 24;
|
||||||
getdisplay().print(bvoltage);
|
printBoatValue(String(bvoltage), 10, 140, LEFT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("V");
|
getdisplay().print("V");
|
||||||
|
|
||||||
// Show solar power
|
// Show solar power
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalueSolPower = (solPower <= 999) ? String(solPower) : String(float(solPower/1000.0), 1);
|
||||||
getdisplay().setCursor(10, 200);
|
printBoatValue(svalueSolPower, 10, 200, LEFT, 20, smallDecimals);
|
||||||
if(solPower <= 999) getdisplay().print(solPower, 0);
|
|
||||||
if(solPower > 999) getdisplay().print(float(solPower/1000.0), 1);
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
if(solPower <= 999) getdisplay().print("W");
|
if(solPower <= 999) getdisplay().print("W");
|
||||||
if(solPower > 999) getdisplay().print("kW");
|
if(solPower > 999) getdisplay().print("kW");
|
||||||
@@ -120,9 +121,7 @@ public:
|
|||||||
solarGraphic(150, 45, commonData->fgcolor, commonData->bgcolor);
|
solarGraphic(150, 45, commonData->fgcolor, commonData->bgcolor);
|
||||||
|
|
||||||
// Show load level in percent
|
// Show load level in percent
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
printBoatValue(String(solPercentage), 150, 200, LEFT, 20, smallDecimals);
|
||||||
getdisplay().setCursor(150, 200);
|
|
||||||
getdisplay().print(solPercentage);
|
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("%");
|
getdisplay().print("%");
|
||||||
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
getdisplay().setFont(&Ubuntu_Bold8pt8b);
|
||||||
@@ -147,54 +146,37 @@ public:
|
|||||||
getdisplay().print("Sensor Modul");
|
getdisplay().print("Sensor Modul");
|
||||||
|
|
||||||
// Reading bus data or using simulation data
|
// Reading bus data or using simulation data
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue1;
|
||||||
getdisplay().setCursor(260, 140);
|
|
||||||
if(simulation == true){
|
|
||||||
if(batVoltage == "12V"){
|
|
||||||
value1 = 12.0;
|
|
||||||
}
|
|
||||||
if(batVoltage == "24V"){
|
|
||||||
value1 = 24.0;
|
|
||||||
}
|
|
||||||
value1 += float(random(0, 5)) / 10; // Simulation data
|
|
||||||
getdisplay().print(value1,1);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// Check for valid real data, display also if hold values activated
|
|
||||||
if(valid1 == true || holdvalues == true){
|
if(valid1 == true || holdvalues == true){
|
||||||
// Resolution switching
|
svalue1 = formatValue(value1, String("formatXdr:U:V"), *commonData);
|
||||||
if(value1 <= 9.9) getdisplay().print(value1, 2);
|
} else {
|
||||||
if(value1 > 9.9 && value1 <= 99.9)getdisplay().print(value1, 1);
|
svalue1 = "---"; // Missing bus data
|
||||||
if(value1 > 99.9) getdisplay().print(value1, 0);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
getdisplay().print("---"); // Missing bus data
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
printBoatValue(svalue1, 355, 140, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("V");
|
getdisplay().print("V");
|
||||||
|
|
||||||
// Show actual current in A
|
// Show actual current in A
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue2;
|
||||||
getdisplay().setCursor(260, 200);
|
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||||
if(value2 <= 9.9) getdisplay().print(value2, 2);
|
svalue2 = formatValue(value2, String("formatXdr:I:A"), *commonData);
|
||||||
if(value2 > 9.9 && value2 <= 99.9)getdisplay().print(value2, 1);
|
|
||||||
if(value2 > 99.9) getdisplay().print(value2, 0);
|
|
||||||
}
|
}
|
||||||
else getdisplay().print("---");
|
else{
|
||||||
|
svalue2 = "---";
|
||||||
|
}
|
||||||
|
printBoatValue(svalue2, 355, 200, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("A");
|
getdisplay().print("A");
|
||||||
|
|
||||||
// Show actual consumption in W
|
// Show actual consumption in W
|
||||||
getdisplay().setFont(&DSEG7Classic_BoldItalic20pt7b);
|
String svalue3;
|
||||||
getdisplay().setCursor(260, 260);
|
|
||||||
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
if((powerSensor == "INA219" || powerSensor == "INA226") && simulation == false){
|
||||||
if(value3 <= 9.9) getdisplay().print(value3, 2);
|
svalue3 = formatValue(value3, String("formatXdr:G:"), *commonData);
|
||||||
if(value3 > 9.9 && value3 <= 99.9)getdisplay().print(value3, 1);
|
|
||||||
if(value3 > 99.9) getdisplay().print(value3, 0);
|
|
||||||
}
|
}
|
||||||
else getdisplay().print("---");
|
else{
|
||||||
|
svalue3 = "---";
|
||||||
|
}
|
||||||
|
printBoatValue(svalue3, 355, 260, RIGHT, 20, smallDecimals);
|
||||||
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
getdisplay().setFont(&Ubuntu_Bold16pt8b);
|
||||||
getdisplay().print("W");
|
getdisplay().print("W");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user