1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-14 06:23:07 +01:00

#107: correctly handle DBT,DBS,DBK

This commit is contained in:
andreas
2025-04-22 19:35:57 +02:00
parent c55bcc1f94
commit 38d370dcfb
4 changed files with 27 additions and 18 deletions

View File

@@ -267,21 +267,29 @@ private:
double DepthBelowTransducer;
double Offset;
double Range;
double WaterDepth;
if (ParseN2kWaterDepth(N2kMsg, SID, DepthBelowTransducer, Offset, Range))
{
WaterDepth = DepthBelowTransducer + Offset;
updateDouble(boatData->DBS, WaterDepth);
updateDouble(boatData->DBT,DepthBelowTransducer);
tNMEA0183Msg NMEA0183Msg;
if (NMEA0183SetDPT(NMEA0183Msg, DepthBelowTransducer, Offset,talkerId))
if (updateDouble(boatData->DBT, DepthBelowTransducer))
{
SendMessage(NMEA0183Msg);
}
if (NMEA0183SetDBx(NMEA0183Msg, DepthBelowTransducer, Offset,talkerId))
{
SendMessage(NMEA0183Msg);
tNMEA0183Msg NMEA0183Msg;
bool offsetValid=true;
if (N2kIsNA(Offset)) {
Offset=NMEA0183DoubleNA;
offsetValid=false;
}
if (NMEA0183SetDPT(NMEA0183Msg, DepthBelowTransducer, Offset, talkerId))
{
SendMessage(NMEA0183Msg);
}
if (offsetValid)
{
double WaterDepth = DepthBelowTransducer + Offset;
updateDouble(boatData->DBS, WaterDepth);
}
if (NMEA0183SetDBx(NMEA0183Msg, DepthBelowTransducer, Offset, talkerId))
{
SendMessage(NMEA0183Msg);
}
}
}
}