Implemented string boatdata value WPName for next waypoint
This commit is contained in:
parent
318a218470
commit
ae9334236b
|
@ -6,3 +6,4 @@
|
|||
generated/*
|
||||
lib/generated
|
||||
webinstall/token.php
|
||||
*~
|
||||
|
|
|
@ -24,6 +24,7 @@ class GwApi{
|
|||
bool formatSet=false;
|
||||
public:
|
||||
double value=0;
|
||||
String svalue="";
|
||||
bool valid=false;
|
||||
int source=-1;
|
||||
bool changed=false; //will be set by getBoatDataValues
|
||||
|
|
|
@ -2,12 +2,6 @@
|
|||
#include <GwJsonDocument.h>
|
||||
#include <ArduinoJson/Json/TextFormatter.hpp>
|
||||
#include "GWConfig.h"
|
||||
#define GWTYPE_DOUBLE 1
|
||||
#define GWTYPE_UINT32 2
|
||||
#define GWTYPE_UINT16 3
|
||||
#define GWTYPE_INT16 4
|
||||
#define GWTYPE_STRING 5
|
||||
#define GWTYPE_USER 100
|
||||
|
||||
class GwBoatItemTypes
|
||||
{
|
||||
|
@ -294,6 +288,7 @@ template class GwBoatItem<double>;
|
|||
template class GwBoatItem<uint32_t>;
|
||||
template class GwBoatItem<uint16_t>;
|
||||
template class GwBoatItem<int16_t>;
|
||||
template class GwBoatItem<String>;
|
||||
void GwSatInfoList::houseKeeping(unsigned long ts)
|
||||
{
|
||||
if (ts == 0)
|
||||
|
|
|
@ -9,6 +9,13 @@
|
|||
#define GW_BOAT_VALUE_LEN 32
|
||||
#define GWSC(name) static constexpr const char* name=#name
|
||||
|
||||
#define GWTYPE_DOUBLE 1
|
||||
#define GWTYPE_UINT32 2
|
||||
#define GWTYPE_UINT16 3
|
||||
#define GWTYPE_INT16 4
|
||||
#define GWTYPE_STRING 5
|
||||
#define GWTYPE_USER 100
|
||||
|
||||
//see https://github.com/wellenvogel/esp32-nmea2000/issues/44
|
||||
//factor to convert from N2k/SI rad/s to current NMEA rad/min
|
||||
#define ROT_WA_FACTOR 60
|
||||
|
@ -93,6 +100,7 @@ class GwBoatItemBase{
|
|||
virtual int getLastSource(){return lastUpdateSource;}
|
||||
virtual void refresh(unsigned long ts=0){uls(ts);}
|
||||
virtual double getDoubleValue()=0;
|
||||
virtual String getStringValue()=0;
|
||||
String getName(){return name;}
|
||||
const String & getFormat() const{return format;}
|
||||
virtual void setInvalidTime(GwConfigHandler *cfg);
|
||||
|
@ -128,6 +136,10 @@ template<class T> class GwBoatItem : public GwBoatItemBase{
|
|||
return (double)data;
|
||||
}
|
||||
}
|
||||
virtual String getStringValue(){
|
||||
return (String)data;
|
||||
}
|
||||
|
||||
virtual void fillString();
|
||||
virtual void toJsonDoc(GwJsonDocument *doc, unsigned long minTime);
|
||||
virtual int getLastSource(){return lastUpdateSource;}
|
||||
|
|
|
@ -355,6 +355,7 @@ private:
|
|||
AppendN2kRouteWPInfo(n2kMsg,destinationId,rmb.destID,rmb.latitude,rmb.longitude);
|
||||
send(n2kMsg,msg.sourceId);
|
||||
}
|
||||
boatData->WPName->update(String(rmb.destID), msg.sourceId);
|
||||
}
|
||||
void convertRMC(const SNMEA0183Msg &msg)
|
||||
{
|
||||
|
|
|
@ -133,6 +133,8 @@ public:
|
|||
epd->setCursor(360-w, 257);
|
||||
epd->print(sval_btw);
|
||||
|
||||
GwApi::BoatValue *bv_wpname = pageData.values[4]; // WPName
|
||||
|
||||
bool valid = bv_cog->valid && bv_btw->valid;
|
||||
|
||||
// XTETrack view
|
||||
|
@ -144,7 +146,7 @@ public:
|
|||
String sval_wpname = "no data";
|
||||
|
||||
if (valid) {
|
||||
sval_wpname = "Tonne 122";
|
||||
sval_wpname = bv_wpname->svalue;
|
||||
}
|
||||
|
||||
epd->setFont(&Ubuntu_Bold10pt8b);
|
||||
|
@ -225,7 +227,7 @@ PageDescription registerPageXTETrack(
|
|||
"XTETrack", // Page name
|
||||
createPage, // Action
|
||||
0, // Number of bus values depends on selection in Web configuration
|
||||
{"XTE", "COG", "DTW", "BTW"}, // Bus values we need in the page
|
||||
{"XTE", "COG", "DTW", "BTW", "WPName"}, // Bus values we need in the page
|
||||
true // Show display header on/off
|
||||
);
|
||||
|
||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -302,9 +302,15 @@ public:
|
|||
if (newValid != list[i]->valid) list[i]->changed=true;
|
||||
list[i]->valid=newValid;
|
||||
if (newValid){
|
||||
double newValue=item->getDoubleValue();
|
||||
if (newValue != list[i]->value) list[i]->changed=true;
|
||||
list[i]->value=newValue;
|
||||
if (item->getCurrentType() == GWTYPE_STRING) {
|
||||
String newValue=item->getStringValue();
|
||||
if (newValue != list[i]->svalue) list[i]->changed=true;
|
||||
list[i]->svalue=newValue;
|
||||
} else {
|
||||
double newValue=item->getDoubleValue();
|
||||
if (newValue != list[i]->value) list[i]->changed=true;
|
||||
list[i]->value=newValue;
|
||||
}
|
||||
int newSource=item->getLastSource();
|
||||
if (newSource != list[i]->source){
|
||||
list[i]->source=newSource;
|
||||
|
|
Loading…
Reference in New Issue