More work on system page

This commit is contained in:
Thomas Hooge 2025-08-12 09:57:52 +02:00
parent cf305e9f5a
commit e5ca2a3a3d
3 changed files with 47 additions and 17 deletions

View File

@ -47,9 +47,6 @@
class PageSystem : public Page
{
private:
GwConfigHandler *config;
GwLog *logger;
// NVRAM config options
String flashLED;
@ -72,6 +69,8 @@ private:
double homelat;
double homelon;
Nmea2kTwai *NMEA2000;
char mode = 'N'; // (N)ormal, (S)ettings, (C)onfiguration, (D)evice list, c(A)rd
int8_t editmode = -1; // marker for menu/edit/set function
@ -93,6 +92,7 @@ private:
} else {
mode = 'N';
}
if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
}
void decMode() {
@ -111,6 +111,7 @@ private:
} else {
mode = 'D';
}
if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
}
void displayModeNormal() {
@ -381,6 +382,10 @@ private:
epd->setCursor(20, 100);
epd->print("TxD: ");
epd->print(String(commonData->status.n2kTx));
epd->setCursor(20, 140);
epd->printf("N2k source address: %d", NMEA2000->GetN2kSource());
}
void storeConfig() {
@ -393,9 +398,10 @@ public:
config = commonData->config;
logger = commonData->logger;
logger->logDebug(GwLog::LOG,"Instantiate PageSystem");
logger->logDebug(GwLog::LOG, "Instantiate PageSystem");
if (hasFRAM) {
mode = fram.read(FRAM_SYSTEM_MODE);
logger->logDebug(GwLog::LOG, "Loaded mode '%c' from FRAM", mode);
}
flashLED = common.config->getString(common.config->flashLED);
@ -452,7 +458,6 @@ public:
commonData->logger->logDebug(GwLog::LOG, "System keyboard handler");
if (key == 2) {
incMode();
if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
return 0;
}
#ifdef BOARD_OBP60S3
@ -518,9 +523,15 @@ public:
}
}
void displayNew(PageData &pageData){
};
int displayPage(PageData &pageData){
GwConfigHandler *config = commonData->config;
GwLog *logger = commonData->logger;
// GwConfigHandler *config = commonData->config;
// GwLog *logger = commonData->logger;
NMEA2000 = pageData.api->getNMEA2000();
logger->logDebug(GwLog::LOG, "PageSystem: N2k source address=%d", NMEA2000->GetN2kSource());
// Optical warning by limit violation (unused)
if(flashLED == "Limit Violation"){
@ -529,11 +540,11 @@ public:
}
// Logging page information
LOG_DEBUG(GwLog::LOG,"Drawing at PageSystem, Mode=%c", mode);
logger->logDebug(GwLog::LOG,"Drawing at PageSystem, Mode=%c", mode);
// Get references from API
Nmea2kTwai *NMEA2000 = pageData.api->getNMEA2000();
LOG_DEBUG(GwLog::LOG,"N2k source address=%d", NMEA2000->GetN2kSource());
// NMEA2000 = pageData.api->getNMEA2000();
// LOG_DEBUG(GwLog::LOG,"N2k source address=%d", NMEA2000->GetN2kSource());
// Set display in partial refresh mode
epd->setPartialWindow(0, 0, epd->width(), epd->height());

19
lib/obp60task/TODO Normal file
View File

@ -0,0 +1,19 @@
- fix unstable accesspoint availability
- page refresh after page change and not connected to key codes
- fix sd card code
- config: getFloat, getDouble
- dseg7 font to new version
- new pages: ais, autopilot, epropulsion
- automate config.json generation with extra_task.py
- extend boatdata: ais, waypoints, alarms
- page clock: sunrise / sunset in local time or UTC
- implement alerts

View File

@ -45,7 +45,7 @@ void OBP60Init(GwApi *api){
String devicename = api->getConfig()->getConfigItem(api->getConfig()->deviceName,true)->asString();
api->getConfig()->setValue(GwConfigDefinitions::systemName, devicename, GwConfigInterface::ConfigType::HIDDEN);
api->getLogger()->logDebug(GwLog::LOG,"obp60init running");
logger->logDebug(GwLog::LOG,"obp60init running");
// Check I2C devices
@ -54,7 +54,7 @@ void OBP60Init(GwApi *api){
// Init power
String powermode = api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString();
api->getLogger()->logDebug(GwLog::DEBUG,"Power Mode is: %s", powermode.c_str());
logger->logDebug(GwLog::DEBUG,"Power Mode is: %s", powermode.c_str());
powerInit(powermode);
#ifdef BOARD_OBP40S3
@ -77,7 +77,7 @@ void OBP60Init(GwApi *api){
break;
}
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
LOG_DEBUG(GwLog::LOG,"SD card type %s of size %d MB detected", sdtype, cardSize);
logger->logDebug(GwLog::LOG,"SD card type %s of size %d MB detected", sdtype, cardSize);
}
}
@ -89,7 +89,7 @@ void OBP60Init(GwApi *api){
// Settings for e-paper display
String fastrefresh = api->getConfig()->getConfigItem(api->getConfig()->fastRefresh,true)->asString();
api->getLogger()->logDebug(GwLog::DEBUG,"Fast Refresh Mode is: %s", fastrefresh.c_str());
logger->logDebug(GwLog::DEBUG,"Fast Refresh Mode is: %s", fastrefresh.c_str());
#ifdef DISPLAY_GDEY042T81
if(fastrefresh == "true"){
static const bool useFastFullUpdate = true; // Enable fast full display update only for GDEY042T81
@ -108,11 +108,11 @@ void OBP60Init(GwApi *api){
// Get CPU speed
int freq = getCpuFrequencyMhz();
api->getLogger()->logDebug(GwLog::LOG,"CPU speed at boot: %i MHz", freq);
logger->logDebug(GwLog::LOG,"CPU speed at boot: %i MHz", freq);
// Settings for backlight
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString();
api->getLogger()->logDebug(GwLog::DEBUG,"Backlight Mode is: %s", backlightMode.c_str());
logger->logDebug(GwLog::DEBUG,"Backlight Mode is: %s", backlightMode.c_str());
uint brightness = uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
String backlightColor = api->getConfig()->getConfigItem(api->getConfig()->blColor,true)->asString();
if(String(backlightMode) == "On"){
@ -127,7 +127,7 @@ void OBP60Init(GwApi *api){
// Settings flash LED mode
String ledMode = api->getConfig()->getConfigItem(api->getConfig()->flashLED,true)->asString();
api->getLogger()->logDebug(GwLog::DEBUG,"LED Mode is: %s", ledMode.c_str());
logger->logDebug(GwLog::DEBUG,"LED Mode is: %s", ledMode.c_str());
if(String(ledMode) == "Off"){
setBlinkingLED(false);
}