mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-13 05:53:06 +01:00
add changed flag to BoatDataValue in API
This commit is contained in:
@@ -15,6 +15,7 @@ class GwApi{
|
||||
public:
|
||||
double value=0;
|
||||
bool valid=false;
|
||||
bool changed=false; //will be set by getBoatDataValues
|
||||
BoatValue(){}
|
||||
BoatValue(const String &n):name(n){
|
||||
}
|
||||
|
||||
@@ -88,8 +88,6 @@ void exampleTask(GwApi *api){
|
||||
GwApi::BoatValue *latitude=new GwApi::BoatValue(F("Latitude"));
|
||||
GwApi::BoatValue *testValue=new GwApi::BoatValue(boatItemName);
|
||||
GwApi::BoatValue *valueList[]={longitude,latitude,testValue};
|
||||
double lastTestValue=0;
|
||||
bool lastTestValueValid=false;
|
||||
while(true){
|
||||
delay(1000);
|
||||
/*
|
||||
@@ -155,16 +153,13 @@ void exampleTask(GwApi *api){
|
||||
}
|
||||
}
|
||||
if (testValue->valid){
|
||||
if (! lastTestValueValid || lastTestValue != testValue->value){
|
||||
if (testValue->changed){
|
||||
LOG_DEBUG(GwLog::LOG,"%s new value %s",testValue->getName().c_str(),formatValue(testValue).c_str());
|
||||
lastTestValueValid=true;
|
||||
lastTestValue=testValue->value;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (lastTestValueValid){
|
||||
if (testValue->changed){
|
||||
LOG_DEBUG(GwLog::LOG,"%s now invalid",testValue->getName().c_str());
|
||||
lastTestValueValid=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user