NMEA2000 access for system page

This commit is contained in:
Thomas Hooge 2025-08-06 15:21:29 +02:00
parent f823dadc6b
commit cf305e9f5a
6 changed files with 17 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#define _GWAPI_H
#include "GwMessage.h"
#include "N2kMsg.h"
#include "Nmea2kTwai.h"
#include "NMEA0183Msg.h"
#include "GWConfig.h"
#include "GwBoatData.h"
@ -222,6 +223,7 @@ class GwApi{
* accessing boat data must only be executed from within the main thread
* you need to use the request pattern as shown in GwExampleTask.cpp
*/
virtual Nmea2kTwai *getNMEA2000()=0;
virtual GwBoatData *getBoatData()=0;
virtual ~GwApi(){}
};

View File

@ -7,6 +7,7 @@
#include "images/logo64.xbm"
#include <esp32/clk.h>
#include "qrcode.h"
#include "Nmea2kTwai.h"
#ifdef BOARD_OBP40S3
#include <SD.h>
@ -530,6 +531,10 @@ public:
// Logging page information
LOG_DEBUG(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());
// Set display in partial refresh mode
epd->setPartialWindow(0, 0, epd->width(), epd->height());

View File

@ -14,6 +14,7 @@
typedef std::vector<GwApi::BoatValue *> ValueList;
typedef struct{
GwApi *api;
String pageName;
uint8_t pageNumber; // page number in sequence of visible pages
//the values will always contain the user defined values first

View File

@ -976,6 +976,7 @@ void OBP60Task(GwApi *api){
if (systemPage) {
displayFooter(commonData);
PageData sysparams; // empty
sysparams.api = api;
syspage->displayPage(sysparams);
}
else {

View File

@ -216,6 +216,10 @@ public:
{
return api->getLogger();
}
virtual Nmea2kTwai *getNMEA2000()
{
return api->getNMEA2000();
}
virtual GwBoatData *getBoatData()
{
return api->getBoatData();
@ -428,4 +432,4 @@ void GwUserCode::handleWebRequest(const String &url,AsyncWebServerRequest *req){
}
LOG_DEBUG(GwLog::DEBUG,"no task found for web request %s[%s]",url.c_str(),tname.c_str());
req->send(404, "text/plain", "not found");
}
}

View File

@ -333,6 +333,9 @@ public:
status.n2kTx=countNMEA2KOut.getGlobal();
channels.fillStatus(status);
}
virtual Nmea2kTwai *getNMEA2000(){
return &NMEA2000;
}
virtual GwBoatData *getBoatData(){
return &boatData;
}