mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-13 05:53:06 +01:00
only recreate value string in boatData if changed
This commit is contained in:
@@ -172,12 +172,15 @@ static void writeToString(GwTextWriter *writer,GwSatInfoList &value){
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void GwBoatItem<T>::fillString(){
|
void GwBoatItem<T>::fillString(){
|
||||||
|
bool valid=isValid();
|
||||||
|
if (writer.getSize() && (valid == lastStringValid)) return;
|
||||||
|
lastStringValid=valid;
|
||||||
writer.reset();
|
writer.reset();
|
||||||
WriterWrapper wrapper(&writer);
|
WriterWrapper wrapper(&writer);
|
||||||
GwTextWriter stringWriter(wrapper);
|
GwTextWriter stringWriter(wrapper);
|
||||||
stringWriter.writeRaw(name.c_str());
|
stringWriter.writeRaw(name.c_str());
|
||||||
stringWriter.writeChar(',');
|
stringWriter.writeChar(',');
|
||||||
stringWriter.writeInteger(isValid()?1:0);
|
stringWriter.writeInteger(valid?1:0);
|
||||||
stringWriter.writeChar(',');
|
stringWriter.writeChar(',');
|
||||||
stringWriter.writeInteger(lastSet);
|
stringWriter.writeInteger(lastSet);
|
||||||
stringWriter.writeChar(',');
|
stringWriter.writeChar(',');
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class GwBoatItemBase{
|
|||||||
void uls(unsigned long ts=0){
|
void uls(unsigned long ts=0){
|
||||||
if (ts) lastSet=ts;
|
if (ts) lastSet=ts;
|
||||||
else lastSet=millis();
|
else lastSet=millis();
|
||||||
|
writer.reset(); //value has changed
|
||||||
}
|
}
|
||||||
int lastUpdateSource;
|
int lastUpdateSource;
|
||||||
public:
|
public:
|
||||||
@@ -74,6 +75,7 @@ class GwBoatData;
|
|||||||
template<class T> class GwBoatItem : public GwBoatItemBase{
|
template<class T> class GwBoatItem : public GwBoatItemBase{
|
||||||
protected:
|
protected:
|
||||||
T data;
|
T data;
|
||||||
|
bool lastStringValid=false;
|
||||||
public:
|
public:
|
||||||
GwBoatItem(String name,String formatInfo,unsigned long invalidTime=INVALID_TIME,GwBoatItemMap *map=NULL);
|
GwBoatItem(String name,String formatInfo,unsigned long invalidTime=INVALID_TIME,GwBoatItemMap *map=NULL);
|
||||||
virtual ~GwBoatItem(){}
|
virtual ~GwBoatItem(){}
|
||||||
|
|||||||
@@ -1088,7 +1088,7 @@ function updateDashboard(data) {
|
|||||||
let names={};
|
let names={};
|
||||||
for (let n in data) {
|
for (let n in data) {
|
||||||
let current=parseBoatDataLine(data[n]);
|
let current=parseBoatDataLine(data[n]);
|
||||||
if (! current.name) return;
|
if (! current.name) continue;
|
||||||
names[current.name]=true;
|
names[current.name]=true;
|
||||||
let de = document.getElementById('data_' + current.name);
|
let de = document.getElementById('data_' + current.name);
|
||||||
if (! de && frame){
|
if (! de && frame){
|
||||||
@@ -1127,6 +1127,7 @@ function updateDashboard(data) {
|
|||||||
src.textContent=sourceName(current.source);
|
src.textContent=sourceName(current.source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("update");
|
||||||
forEl('.dashValue',function(el){
|
forEl('.dashValue',function(el){
|
||||||
let id=el.getAttribute('id');
|
let id=el.getAttribute('id');
|
||||||
if (id){
|
if (id){
|
||||||
|
|||||||
Reference in New Issue
Block a user