Compare commits

...

2 Commits

Author SHA1 Message Date
Thomas Hooge 15ca3614ba Include uptime in system page 2025-08-12 13:29:36 +02:00
Thomas Hooge e5ca2a3a3d More work on system page 2025-08-12 09:57:52 +02:00
4 changed files with 71 additions and 18 deletions

View File

@ -47,9 +47,6 @@
class PageSystem : public Page class PageSystem : public Page
{ {
private: private:
GwConfigHandler *config;
GwLog *logger;
// NVRAM config options // NVRAM config options
String flashLED; String flashLED;
@ -72,6 +69,8 @@ private:
double homelat; double homelat;
double homelon; double homelon;
Nmea2kTwai *NMEA2000;
char mode = 'N'; // (N)ormal, (S)ettings, (C)onfiguration, (D)evice list, c(A)rd 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 int8_t editmode = -1; // marker for menu/edit/set function
@ -93,6 +92,7 @@ private:
} else { } else {
mode = 'N'; mode = 'N';
} }
if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
} }
void decMode() { void decMode() {
@ -111,6 +111,7 @@ private:
} else { } else {
mode = 'D'; mode = 'D';
} }
if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
} }
void displayModeNormal() { void displayModeNormal() {
@ -191,6 +192,29 @@ private:
} }
#endif #endif
// Uptime
int64_t uptime = esp_timer_get_time() / 1000000;
String uptime_unit;
if (uptime < 120) {
uptime_unit = " seconds";
} else {
if (uptime < 2 * 3600) {
uptime /= 60;
uptime_unit = " minutes";
} else if (uptime < 2 * 3600 * 24) {
uptime /= 3600;
uptime_unit = " hours";
} else {
uptime /= 86400;
uptime_unit = " days";
}
}
epd->setCursor(8, y0 + 80);
epd->print("Uptime:");
epd->setCursor(90, y0 + 80);
epd->print(uptime);
epd->print(uptime_unit);
// CPU speed config / active // CPU speed config / active
epd->setCursor(202, y0); epd->setCursor(202, y0);
epd->print("CPU speed:"); epd->print("CPU speed:");
@ -381,6 +405,10 @@ private:
epd->setCursor(20, 100); epd->setCursor(20, 100);
epd->print("TxD: "); epd->print("TxD: ");
epd->print(String(commonData->status.n2kTx)); epd->print(String(commonData->status.n2kTx));
epd->setCursor(20, 140);
epd->printf("N2k source address: %d", NMEA2000->GetN2kSource());
} }
void storeConfig() { void storeConfig() {
@ -396,6 +424,7 @@ public:
logger->logDebug(GwLog::LOG, "Instantiate PageSystem"); logger->logDebug(GwLog::LOG, "Instantiate PageSystem");
if (hasFRAM) { if (hasFRAM) {
mode = fram.read(FRAM_SYSTEM_MODE); mode = fram.read(FRAM_SYSTEM_MODE);
logger->logDebug(GwLog::LOG, "Loaded mode '%c' from FRAM", mode);
} }
flashLED = common.config->getString(common.config->flashLED); flashLED = common.config->getString(common.config->flashLED);
@ -452,7 +481,6 @@ public:
commonData->logger->logDebug(GwLog::LOG, "System keyboard handler"); commonData->logger->logDebug(GwLog::LOG, "System keyboard handler");
if (key == 2) { if (key == 2) {
incMode(); incMode();
if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
return 0; return 0;
} }
#ifdef BOARD_OBP60S3 #ifdef BOARD_OBP60S3
@ -518,9 +546,15 @@ public:
} }
} }
void displayNew(PageData &pageData){
};
int displayPage(PageData &pageData){ int displayPage(PageData &pageData){
GwConfigHandler *config = commonData->config; // GwConfigHandler *config = commonData->config;
GwLog *logger = commonData->logger; // 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) // Optical warning by limit violation (unused)
if(flashLED == "Limit Violation"){ if(flashLED == "Limit Violation"){
@ -529,11 +563,11 @@ public:
} }
// Logging page information // 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 // Get references from API
Nmea2kTwai *NMEA2000 = pageData.api->getNMEA2000(); // NMEA2000 = pageData.api->getNMEA2000();
LOG_DEBUG(GwLog::LOG,"N2k source address=%d", NMEA2000->GetN2kSource()); // LOG_DEBUG(GwLog::LOG,"N2k source address=%d", NMEA2000->GetN2kSource());
// Set display in partial refresh mode // Set display in partial refresh mode
epd->setPartialWindow(0, 0, epd->width(), epd->height()); 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(); String devicename = api->getConfig()->getConfigItem(api->getConfig()->deviceName,true)->asString();
api->getConfig()->setValue(GwConfigDefinitions::systemName, devicename, GwConfigInterface::ConfigType::HIDDEN); 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 // Check I2C devices
@ -54,7 +54,7 @@ void OBP60Init(GwApi *api){
// Init power // Init power
String powermode = api->getConfig()->getConfigItem(api->getConfig()->powerMode,true)->asString(); 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); powerInit(powermode);
#ifdef BOARD_OBP40S3 #ifdef BOARD_OBP40S3
@ -77,7 +77,7 @@ void OBP60Init(GwApi *api){
break; break;
} }
uint64_t cardSize = SD.cardSize() / (1024 * 1024); 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 // Settings for e-paper display
String fastrefresh = api->getConfig()->getConfigItem(api->getConfig()->fastRefresh,true)->asString(); 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 #ifdef DISPLAY_GDEY042T81
if(fastrefresh == "true"){ if(fastrefresh == "true"){
static const bool useFastFullUpdate = true; // Enable fast full display update only for GDEY042T81 static const bool useFastFullUpdate = true; // Enable fast full display update only for GDEY042T81
@ -108,11 +108,11 @@ void OBP60Init(GwApi *api){
// Get CPU speed // Get CPU speed
int freq = getCpuFrequencyMhz(); 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 // Settings for backlight
String backlightMode = api->getConfig()->getConfigItem(api->getConfig()->backlight,true)->asString(); 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()); uint brightness = uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
String backlightColor = api->getConfig()->getConfigItem(api->getConfig()->blColor,true)->asString(); String backlightColor = api->getConfig()->getConfigItem(api->getConfig()->blColor,true)->asString();
if(String(backlightMode) == "On"){ if(String(backlightMode) == "On"){
@ -127,7 +127,7 @@ void OBP60Init(GwApi *api){
// Settings flash LED mode // Settings flash LED mode
String ledMode = api->getConfig()->getConfigItem(api->getConfig()->flashLED,true)->asString(); 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"){ if(String(ledMode) == "Off"){
setBlinkingLED(false); setBlinkingLED(false);
} }

View File

@ -30,7 +30,7 @@ lib_deps =
Update Update
[env] [env]
platform = espressif32 @ 6.9.0 platform = espressif32 @ 6.11.0
framework = arduino framework = arduino
;platform_packages= ;platform_packages=
; framework-arduinoespressif32 @ 3.20017.0 ; framework-arduinoespressif32 @ 3.20017.0