From 1bdb3ebfb97b92c1c712ccb3d2c870fc0371c23c Mon Sep 17 00:00:00 2001 From: Norbert Walter Date: Sat, 8 Jan 2022 19:19:10 +0100 Subject: [PATCH] Add status infos --- lib/boatData/GwBoatData.cpp | 2 +- lib/obp60task/GwOBP60Task.cpp | 33 +++++++++- lib/obp60task/OBP60Data.h | 21 +++++++ lib/obp60task/OBP60Pages.h | 112 +++++++++++++++++++--------------- 4 files changed, 114 insertions(+), 54 deletions(-) diff --git a/lib/boatData/GwBoatData.cpp b/lib/boatData/GwBoatData.cpp index 91d1bc2..9b33bbf 100644 --- a/lib/boatData/GwBoatData.cpp +++ b/lib/boatData/GwBoatData.cpp @@ -425,7 +425,7 @@ double formatWind(double cv) { double rt = formatCourse(cv); if (rt > 180) - rt = 180 - rt; + rt = (360 - rt) * -1; return rt; } double formatKnots(double cv) diff --git a/lib/obp60task/GwOBP60Task.cpp b/lib/obp60task/GwOBP60Task.cpp index 81f6a5d..937d47e 100644 --- a/lib/obp60task/GwOBP60Task.cpp +++ b/lib/obp60task/GwOBP60Task.cpp @@ -215,6 +215,7 @@ void OBP60Task(void *param){ GwApi *api=(GwApi*)param; GwLog *logger=api->getLogger(); + GwApi::Status status; bool hasPosition = false; @@ -260,8 +261,9 @@ void OBP60Task(void *param){ GwApi::BoatValue *longitude=new GwApi::BoatValue(F("Longitude")); GwApi::BoatValue *latitude=new GwApi::BoatValue(F("Latitude")); GwApi::BoatValue *waterdepth=new GwApi::BoatValue(F("WaterDepth")); + GwApi::BoatValue *hdop=new GwApi::BoatValue(F("HDOP")); GwApi::BoatValue *pdop=new GwApi::BoatValue(F("PDOP")); - GwApi::BoatValue *valueList[]={sog, date, time, longitude, latitude, waterdepth, pdop}; + GwApi::BoatValue *valueList[]={sog, date, time, longitude, latitude, waterdepth, hdop, pdop}; //Init E-Ink display display.init(); // Initialize and clear display @@ -284,7 +286,6 @@ void OBP60Task(void *param){ } } - // Task Loop //############################### while(true){ @@ -339,8 +340,31 @@ void OBP60Task(void *param){ } } + // Read the status values from gateway + api->getStatus(status); + busInfo.wifiApOn = status.wifiApOn; + busInfo.wifiClientOn = status.wifiClientOn; + busInfo.wifiClientConnected = status.wifiClientConnected; + busInfo.wifiApIp = status.wifiApIp; + busInfo.systemName = status.systemName; + busInfo.wifiApPass = status.wifiApPass; + busInfo.wifiClientIp = status.wifiClientIp; + busInfo.wifiClientSSID = status.wifiClientSSID; + busInfo.usbRx = status.usbRx; + busInfo.usbTx = status.usbTx; + busInfo.serRx = status.serRx; + busInfo.serTx = status.serTx; + busInfo.tcpSerRx = status.tcpSerRx; + busInfo.tcpSerTx = status.tcpSerTx; + busInfo.tcpClients = status.tcpClients; + busInfo.tcpClRx = status.tcpClRx; + busInfo.tcpClTx = status.tcpClTx; + busInfo.tcpClientConnected = status.tcpClientConnected; + busInfo.n2kRx = status.n2kRx; + busInfo.n2kTx = status.n2kTx; + // Read the current bus data and copy to stucture - api->getBoatDataValues(7,valueList); + api->getBoatDataValues(8,valueList); busInfo.WaterDepth.fvalue = waterdepth->value; waterdepth->getFormat().toCharArray(busInfo.WaterDepth.unit, 8, 0); @@ -356,6 +380,9 @@ void OBP60Task(void *param){ formatValue(time).toCharArray(busInfo.Time.svalue, 16, 0); busInfo.Time.valid = time->valid; + busInfo.HDOP.fvalue = hdop->value; + busInfo.HDOP.valid = hdop->valid; + busInfo.PDOP.fvalue = pdop->value; busInfo.PDOP.valid = pdop->valid; diff --git a/lib/obp60task/OBP60Data.h b/lib/obp60task/OBP60Data.h index 5798e5d..ec2940c 100644 --- a/lib/obp60task/OBP60Data.h +++ b/lib/obp60task/OBP60Data.h @@ -11,6 +11,27 @@ typedef struct{ // Sub structure for bus data } dataContainer; typedef struct{ + // Gateway status infos + bool wifiApOn = false; + bool wifiClientOn = false; + bool wifiClientConnected = false; + String wifiApIp = ""; + String systemName = ""; // is also AP SSID + String wifiApPass = ""; + String wifiClientIp = ""; + String wifiClientSSID = ""; + unsigned long usbRx = 0; + unsigned long usbTx = 0; + unsigned long serRx = 0; + unsigned long serTx = 0; + unsigned long tcpSerRx = 0; + unsigned long tcpSerTx = 0; + int tcpClients = 0; + unsigned long tcpClRx = 0; + unsigned long tcpClTx = 0; + bool tcpClientConnected = false; + unsigned long n2kRx = 0; + unsigned long n2kTx = 0; // OBP60 Settings char dateformat[3] = "GB"; int timezone = 0; diff --git a/lib/obp60task/OBP60Pages.h b/lib/obp60task/OBP60Pages.h index 14c8731..41ee42f 100644 --- a/lib/obp60task/OBP60Pages.h +++ b/lib/obp60task/OBP60Pages.h @@ -17,7 +17,21 @@ void showPage(busData values){ display.setFont(&Ubuntu_Bold8pt7b); display.setTextColor(GxEPD_BLACK); display.setCursor(0, 15); - display.print(" WiFi AP TCP N2K 183 "); + if(values.wifiApOn){ + display.print(" AP "); + } + if(values.tcpClRx > 0 || values.tcpClTx > 0 || values.tcpSerRx > 0 || values.tcpSerTx > 0){ + display.print("TCP "); + } + if(values.n2kRx > 0 || values.n2kTx > 0){ + display.print("N2K "); + } + if(values.serRx > 0 || values.serTx > 0){ + display.print("183 "); + } + if(values.usbRx > 0 || values.usbTx > 0){ + display.print("USB "); + } if(values.gps == true && values.PDOP.valid == true && values.PDOP.fvalue <= 50){ display.print("GPS"); } @@ -36,61 +50,59 @@ void showPage(busData values){ // Date and time display.setFont(&Ubuntu_Bold8pt7b); display.setCursor(230, 15); - if(values.gps == true){ - if(values.PDOP.valid == true && values.PDOP.fvalue <= 50){ + if(values.HDOP.valid == true && values.HDOP.fvalue <= 50){ + char newdate[16] = ""; + if(String(values.dateformat) == "DE"){ + display.print(values.Date.svalue); + } + if(String(values.dateformat) == "GB"){ + values.Date.svalue[2] = '/'; + values.Date.svalue[5] = '/'; + display.print(values.Date.svalue); + } + if(String(values.dateformat) == "US"){ char newdate[16] = ""; - if(String(values.dateformat) == "DE"){ - display.print(values.Date.svalue); - } - if(String(values.dateformat) == "GB"){ - values.Date.svalue[2] = '/'; - values.Date.svalue[5] = '/'; - display.print(values.Date.svalue); - } - if(String(values.dateformat) == "US"){ - char newdate[16] = ""; - strcpy(newdate, values.Date.svalue); - newdate[0] = values.Date.svalue[3]; - newdate[1] = values.Date.svalue[4]; - newdate[2] = '/'; - newdate[3] = values.Date.svalue[0]; - newdate[4] = values.Date.svalue[1]; - newdate[5] = '/'; - display.print(newdate); - } + strcpy(newdate, values.Date.svalue); + newdate[0] = values.Date.svalue[3]; + newdate[1] = values.Date.svalue[4]; + newdate[2] = '/'; + newdate[3] = values.Date.svalue[0]; + newdate[4] = values.Date.svalue[1]; + newdate[5] = '/'; + display.print(newdate); + } + display.print(" "); + if(values.timezone == 0){ + display.print(values.Time.svalue); display.print(" "); - if(values.timezone == 0){ - display.print(values.Time.svalue); - display.print(" "); - display.print("UTC"); - } - else{ - char newtime[16] = ""; - char newhour[3] = ""; - int hour = 0; - strcpy(newtime, values.Time.svalue); - newhour[0] = values.Time.svalue[0]; - newhour[1] = values.Time.svalue[1]; - hour = strtol(newhour, 0, 10); - if(values.timezone > 0){ - hour += values.timezone; - } - else{ - hour += values.timezone + 24; - } - hour %= 24; - sprintf(newhour, "%d", hour); - newtime[0] = newhour[0]; - newtime[1] = newhour[1]; - display.print(newtime); - display.print(" "); - display.print("LOT"); - } + display.print("UTC"); } else{ - display.print("No GPS data"); + char newtime[16] = ""; + char newhour[3] = ""; + int hour = 0; + strcpy(newtime, values.Time.svalue); + newhour[0] = values.Time.svalue[0]; + newhour[1] = values.Time.svalue[1]; + hour = strtol(newhour, 0, 10); + if(values.timezone > 0){ + hour += values.timezone; + } + else{ + hour += values.timezone + 24; + } + hour %= 24; + sprintf(newhour, "%d", hour); + newtime[0] = newhour[0]; + newtime[1] = newhour[1]; + display.print(newtime); + display.print(" "); + display.print("LOT"); } } + else{ + display.print("No GPS data"); + } } // Read page number