mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-28 21:23:07 +01:00
Add new PageNavigation (not complete)
This commit is contained in:
142
lib/obp60task/PageNavigation.cpp
Normal file
142
lib/obp60task/PageNavigation.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||
|
||||
#include "Pagedata.h"
|
||||
#include "OBP60Extensions.h"
|
||||
|
||||
class PageNavigation : public Page
|
||||
{
|
||||
public:
|
||||
PageNavigation(CommonData &common){
|
||||
commonData = &common;
|
||||
common.logger->logDebug(GwLog::LOG,"Instantiate PageNavigation");
|
||||
}
|
||||
|
||||
virtual int handleKey(int key){
|
||||
// Code for keylock
|
||||
if(key == 11){
|
||||
commonData->keylock = !commonData->keylock;
|
||||
return 0; // Commit the key
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
int displayPage(PageData &pageData){
|
||||
GwConfigHandler *config = commonData->config;
|
||||
GwLog *logger = commonData->logger;
|
||||
|
||||
// Old values for hold function
|
||||
static String svalue1old = "";
|
||||
static String unit1old = "";
|
||||
static String svalue2old = "";
|
||||
static String unit2old = "";
|
||||
static String svalue3old = "";
|
||||
static String unit3old = "";
|
||||
static String svalue4old = "";
|
||||
static String unit4old = "";
|
||||
|
||||
// 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);
|
||||
|
||||
// Get boat values #1
|
||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
||||
name1 = name1.substring(0, 6); // String length limit for value name
|
||||
double value1 = bvalue1->value; // Value as double in SI unit
|
||||
bool valid1 = bvalue1->valid; // Valid information
|
||||
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
|
||||
|
||||
// Get boat values #2
|
||||
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue)
|
||||
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
||||
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
|
||||
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
|
||||
|
||||
// Get boat values #3
|
||||
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue)
|
||||
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
||||
name3 = name3.substring(0, 6); // String length limit for value name
|
||||
double 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
|
||||
|
||||
// Get boat values #4
|
||||
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue)
|
||||
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
||||
name4 = name4.substring(0, 6); // String length limit for value name
|
||||
double value4 = bvalue4->value; // Value as double in SI unit
|
||||
bool valid4 = bvalue4->valid; // Valid information
|
||||
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||
String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value
|
||||
|
||||
// Optical warning by limit violation (unused)
|
||||
if(String(flashLED) == "Limit Violation"){
|
||||
setBlinkingLED(false);
|
||||
setFlashLED(false);
|
||||
}
|
||||
|
||||
// Logging boat values
|
||||
if (bvalue1 == NULL) return PAGE_OK; // WTF why this statement?
|
||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageNavigation, %s: %f, %s: %f, %s: %f, %s: %f", name1.c_str(), value1, name2.c_str(), value2, name3.c_str(), value3, name4.c_str(), value4);
|
||||
|
||||
// Draw page
|
||||
//***********************************************************
|
||||
|
||||
// Set display in partial refresh mode
|
||||
getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
|
||||
|
||||
getdisplay().setTextColor(commonData->fgcolor);
|
||||
|
||||
// ############### Draw Navigation Map ################
|
||||
getdisplay().setFont(&Ubuntu_Bold12pt8b);
|
||||
|
||||
getdisplay().setCursor(20, 60);
|
||||
getdisplay().print(name1);
|
||||
getdisplay().setCursor(120, 60);
|
||||
getdisplay().print(svalue1);
|
||||
|
||||
getdisplay().setCursor(20, 80);
|
||||
getdisplay().print(name2);
|
||||
getdisplay().setCursor(120, 80);
|
||||
getdisplay().print(svalue2);
|
||||
|
||||
getdisplay().setCursor(20, 100);
|
||||
getdisplay().print(name3);
|
||||
getdisplay().setCursor(120, 100);
|
||||
getdisplay().print(svalue3);
|
||||
|
||||
getdisplay().setCursor(20, 120);
|
||||
getdisplay().print(name4);
|
||||
getdisplay().setCursor(120, 120);
|
||||
getdisplay().print(svalue4);
|
||||
|
||||
return PAGE_UPDATE;
|
||||
};
|
||||
};
|
||||
|
||||
static Page *createPage(CommonData &common){
|
||||
return new PageNavigation(common);
|
||||
}/**
|
||||
* with the code below we make this page known to the PageTask
|
||||
* we give it a type (name) that can be selected in the config
|
||||
* we define which function is to be called
|
||||
* and we provide the number of user parameters we expect
|
||||
* this will be number of BoatValue pointers in pageData.values
|
||||
*/
|
||||
PageDescription registerPageNavigation(
|
||||
"Navigation", // Page name
|
||||
createPage, // Action
|
||||
0, // Number of bus values depends on selection in Web configuration
|
||||
{"LAT","LON","HDT","SOG"}, // Bus values we need in the page
|
||||
true // Show display header on/off
|
||||
);
|
||||
|
||||
#endif
|
||||
@@ -1231,6 +1231,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -1529,6 +1530,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -1819,6 +1821,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -2101,6 +2104,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -2375,6 +2379,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -2641,6 +2646,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -2899,6 +2905,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -3149,6 +3156,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -3391,6 +3399,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -3625,6 +3634,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
|
||||
@@ -1254,6 +1254,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -1582,6 +1583,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -1901,6 +1903,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -2211,6 +2214,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -2512,6 +2516,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -2804,6 +2809,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -3087,6 +3093,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -3361,6 +3368,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -3626,6 +3634,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
@@ -3882,6 +3891,7 @@
|
||||
"FourValues2",
|
||||
"Generator",
|
||||
"KeelPosition",
|
||||
"Navigation",
|
||||
"OneValue",
|
||||
"RollPitch",
|
||||
"RudderPosition",
|
||||
|
||||
@@ -260,6 +260,8 @@ void registerAllPages(PageList &list){
|
||||
list.add(®isterPageFluid);
|
||||
extern PageDescription registerPageSkyView;
|
||||
list.add(®isterPageSkyView);
|
||||
extern PageDescription registerPageNavigation;
|
||||
list.add(®isterPageNavigation);
|
||||
}
|
||||
|
||||
// Undervoltage detection for shutdown display
|
||||
|
||||
@@ -99,8 +99,8 @@ build_flags=
|
||||
-D HARDWARE_V10 #OBP40 hardware revision V1.0 SKU:DIE07300S V1.1 (CrowPanel 4.2)
|
||||
-D DISPLAY_GDEY042T81 #new E-Ink display from Good Display (Waveshare), R10 2.2 ohm - good (contast lost by shunshine)
|
||||
#-D DISPLAY_ZJY400300-042CAAMFGN #alternativ E-Ink display from ZZE Technology, R10 2.2 ohm - very good
|
||||
#-D LIPO_ACCU_1200 #Hardware extension, LiPo accu 3,7V 1200mAh
|
||||
#-D VOLTAGE_SENSOR #Hardware extension, LiPo voltage sensor with two resistors
|
||||
-D LIPO_ACCU_1200 #Hardware extension, LiPo accu 3,7V 1200mAh
|
||||
-D VOLTAGE_SENSOR #Hardware extension, LiPo voltage sensor with two resistors
|
||||
${env.build_flags}
|
||||
upload_port = /dev/ttyUSB0 #OBP40 download via external USB/Serail converter
|
||||
upload_protocol = esptool #firmware upload via USB OTG seriell, by first upload need to set the ESP32-S3 in the upload mode with shortcut GND to Pin27
|
||||
|
||||
Reference in New Issue
Block a user