diff --git a/lib/api/GwApi.h b/lib/api/GwApi.h index 88f9690..03f0e71 100644 --- a/lib/api/GwApi.h +++ b/lib/api/GwApi.h @@ -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(){} }; diff --git a/lib/obp60task/PageSystem.cpp b/lib/obp60task/PageSystem.cpp index 776a6db..ea7e99c 100644 --- a/lib/obp60task/PageSystem.cpp +++ b/lib/obp60task/PageSystem.cpp @@ -7,6 +7,7 @@ #include "images/logo64.xbm" #include #include "qrcode.h" +#include "Nmea2kTwai.h" #ifdef BOARD_OBP40S3 #include @@ -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()); diff --git a/lib/obp60task/Pagedata.h b/lib/obp60task/Pagedata.h index 0d411c7..d6cbdb7 100644 --- a/lib/obp60task/Pagedata.h +++ b/lib/obp60task/Pagedata.h @@ -14,6 +14,7 @@ typedef std::vector 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 diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 543dd03..eaa40e0 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -976,6 +976,7 @@ void OBP60Task(GwApi *api){ if (systemPage) { displayFooter(commonData); PageData sysparams; // empty + sysparams.api = api; syspage->displayPage(sysparams); } else { diff --git a/lib/usercode/GwUserCode.cpp b/lib/usercode/GwUserCode.cpp index 1b007f8..d5cb5c3 100644 --- a/lib/usercode/GwUserCode.cpp +++ b/lib/usercode/GwUserCode.cpp @@ -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"); -} \ No newline at end of file +} diff --git a/src/main.cpp b/src/main.cpp index 6daaa51..2dd1f2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -333,6 +333,9 @@ public: status.n2kTx=countNMEA2KOut.getGlobal(); channels.fillStatus(status); } + virtual Nmea2kTwai *getNMEA2000(){ + return &NMEA2000; + } virtual GwBoatData *getBoatData(){ return &boatData; }