Add heartbeat, date time and faster page update rate

This commit is contained in:
Norbert Walter 2021-12-19 13:51:47 +01:00
parent 2ca4cfbd38
commit 9e5d1b5244
4 changed files with 66 additions and 6 deletions

View File

@ -80,6 +80,37 @@ class GetBoatDataRequest: public GwMessage{
};
};
String formatValue(GwApi::BoatValue *value){
if (! value->valid) return "----";
static const int bsize=30;
char buffer[bsize+1];
buffer[0]=0;
if (value->getFormat() == "formatDate"){
time_t tv=tNMEA0183Msg::daysToTime_t(value->value);
tmElements_t parts;
tNMEA0183Msg::breakTime(tv,parts);
snprintf(buffer,bsize,"%02d.%02d.%04d",parts.tm_mday,parts.tm_mon+1,parts.tm_year+1900);
}
else if(value->getFormat() == "formatTime"){
double inthr;
double intmin;
double intsec;
double val;
val=modf(value->value/3600.0,&inthr);
val=modf(val*3600.0/60.0,&intmin);
modf(val*60.0,&intsec);
snprintf(buffer,bsize,"%02.0f:%02.0f:%02.0f",inthr,intmin,intsec);
}
else if (value->getFormat() == "formatFixed0"){
snprintf(buffer,bsize,"%.0f",value->value);
}
else{
snprintf(buffer,bsize,"%.4f",value->value);
}
buffer[bsize]=0;
return String(buffer);
}
// Hardware initialisation before start all services
//##################################################
void OBP60Init(GwApi *api){
@ -204,7 +235,8 @@ 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 *valueList[]={sog, date, time, longitude, latitude, waterdepth};
GwApi::BoatValue *pdop=new GwApi::BoatValue(F("PDOP"));
GwApi::BoatValue *valueList[]={sog, date, time, longitude, latitude, waterdepth, pdop};
//Init E-Ink display
display.init(); // Initialize and clear display
@ -283,14 +315,23 @@ void OBP60Task(void *param){
}
//fetch the current values of the items that we have in itemNames
api->getBoatDataValues(6,valueList);
api->getBoatDataValues(7,valueList);
busInfo.WaterDepth.fvalue = waterdepth->value;
waterdepth->getFormat().toCharArray(busInfo.WaterDepth.unit, 8, 0);
busInfo.WaterDepth.valid = int(waterdepth->valid);
busInfo.SOG.fvalue = sog->value;
sog->getFormat().toCharArray(busInfo.SOG.unit, 8, 0);
busInfo.SOG.valid = int(sog->valid);
formatValue(date).toCharArray(busInfo.Date.svalue, 31, 0);
busInfo.Date.valid = date->valid;
formatValue(time).toCharArray(busInfo.Time.svalue, 31, 0);
busInfo.Time.valid = time->valid;
busInfo.PDOP.fvalue = pdop->value;
busInfo.PDOP.valid = pdop->valid;
// Subtask all 1000ms show pages
if((taskRunCounter % 100) == 0 || first_view == true){
// Subtask all 500ms show pages
if((taskRunCounter % 50) == 0 || first_view == true){
LOG_DEBUG(GwLog::DEBUG,"Keystatus: %s", keystatus);
LOG_DEBUG(GwLog::DEBUG,"Pagenumber: %d", pageNumber);
if(displayMode == "Logo + QR Code" || displayMode == "Logo" || displayMode == "White Screen"){

View File

@ -6,6 +6,7 @@
typedef struct{
float fvalue = 0; // Float value
char svalue[31] = ""; // Char value
char unit[8] = ""; // Unit
int valid = 0; // Valid flag
} dataContainer;

View File

@ -6,6 +6,7 @@
// Global vars
int pageNumber = 0; // Page number for actual page
bool first_view = true;
bool heartbeat = false;
void showPage(busData values){
// Clear display
@ -17,8 +18,25 @@ void showPage(busData values){
display.setTextColor(GxEPD_BLACK);
display.setCursor(0, 15);
display.print(" WiFi AP TCP N2K 183 GPS");
display.setFont(&Ubuntu_Bold32pt7b);
display.setCursor(205, 14);
if(heartbeat == true){
display.print(".");
}
else{
display.print(" ");
}
heartbeat = !heartbeat;
display.setFont(&Ubuntu_Bold8pt7b);
display.setCursor(230, 15);
display.print("14.12.2021 17:50 UTC");
if(values.PDOP.valid == true && values.PDOP.fvalue <= 50){
display.print(values.Date.svalue);
display.print(" ");
display.print(values.Time.svalue);
}
else{
display.print("No GPS data");
}
// Read page number
switch (pageNumber) {

View File

@ -5,7 +5,7 @@
#include "OBP60Hardware.h"
void page_0(busData pvalues){
// Measuring Values
// Name and unit
display.setFont(&Ubuntu_Bold32pt7b);
display.setTextColor(GxEPD_BLACK);
display.setCursor(20, 100);