Fix for GPS and RTC see issue #79 and #88

This commit is contained in:
norbert-walter 2024-11-02 16:28:22 +01:00
parent 717d66054d
commit c5449a91a6
4 changed files with 26 additions and 8 deletions

View File

@ -234,7 +234,7 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa
getdisplay().print("USB ");
}
double gpshdop = formatValue(hdop, commonData).value;
if(commonData.config->getString(commonData.config->useGPS) != "off" && gpshdop > 0.3){
if(commonData.config->getString(commonData.config->useGPS) != "off" && gpshdop <= commonData.config->getInt(commonData.config->hdopAccuracy) && hdop->valid == true){
getdisplay().print("GPS");
}
// Save old telegram counter
@ -265,6 +265,7 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa
getdisplay().setTextColor(textcolor);
getdisplay().setFont(&Ubuntu_Bold8pt7b);
getdisplay().setCursor(230, 15);
// Show date and time if date present
if(date->valid == true){
String acttime = formatValue(time, commonData).svalue;
acttime = acttime.substring(0, 5);

View File

@ -147,6 +147,7 @@ void sensorTask(void *param){
// Settings for GPS sensors
String gpsOn=api->getConfig()->getConfigItem(api->getConfig()->useGPS,true)->asString();
uint hdopAccuracy = uint(api->getConfig()->getConfigItem(api->getConfig()->hdopAccuracy,true)->asInt());
if(String(gpsOn) == "NEO-6M"){
Serial2.begin(9600, SERIAL_8N1, OBP_GPS_RX, OBP_GPS_TX, false); // not inverted (false)
if (!Serial2) {
@ -354,7 +355,8 @@ void sensorTask(void *param){
GwApi::BoatValue *gpsdays=new GwApi::BoatValue(GwBoatData::_GPSD);
GwApi::BoatValue *gpsseconds=new GwApi::BoatValue(GwBoatData::_GPST);
GwApi::BoatValue *valueList[]={gpsdays, gpsseconds};
GwApi::BoatValue *hdop=new GwApi::BoatValue(GwBoatData::_HDOP);
GwApi::BoatValue *valueList[]={gpsdays, gpsseconds, hdop};
// Sensor task loop runs with 100ms
//####################################################################################
@ -366,7 +368,7 @@ void sensorTask(void *param){
{
starttime0 = millis();
// Send NMEA0183 GPS data on several bus systems all 100ms
if (GPS_ready == true)
if (GPS_ready == true && hdop->value <= hdopAccuracy)
{
SNMEA0183Msg NMEA0183Msg;
while (NMEA0183.GetMessageCor(NMEA0183Msg))
@ -381,8 +383,8 @@ void sensorTask(void *param){
if(millis() > starttime11 + 5*60*1000){
starttime11 = millis();
if(rtcOn == "DS1388" && RTC_ready == true && GPS_ready == true){
api->getBoatDataValues(2,valueList);
if(gpsdays->valid && gpsseconds->valid){
api->getBoatDataValues(3,valueList);
if(gpsdays->valid && gpsseconds->valid && hdop->valid){
long ts = tNMEA0183Msg::daysToTime_t(gpsdays->value - (30*365+7))+floor(gpsseconds->value); // Adjusted to reference year 2000 (-30 years and 7 days for switch years)
// sample input: date = "Dec 26 2009", time = "12:34:56"
// ds1388.adjust(DateTime("Dec 26 2009", "12:34:56"));
@ -421,7 +423,7 @@ void sensorTask(void *param){
// If GPS not ready or installed then send RTC time on bus all 500ms
if(millis() > starttime12 + 500){
starttime12 = millis();
if(rtcOn == "DS1388" && RTC_ready == true && GPS_ready == false){
if((rtcOn == "DS1388" && RTC_ready == true && GPS_ready == false) || (rtcOn == "DS1388" && RTC_ready == true && GPS_ready == true && hdop->valid == false)){
// Convert RTC time to Unix system time
// https://de.wikipedia.org/wiki/Unixzeit
const short daysOfYear[12] = {0,31,59,90,120,151,181,212,243,273,304,334};

View File

@ -311,6 +311,20 @@
"obp60":"true"
}
},
{
"name": "hdopAccuracy",
"label": "HDOP Accuracy [m]",
"type": "number",
"default": "20",
"check": "checkMinMax",
"min": 1,
"max": 50,
"description": "HDOP ccuracy in m for a valid GPS signal [1...50]",
"category": "OBP60 Hardware",
"capabilities": {
"obp60":"true"
}
},
{
"name": "useEnvSensor",
"label": "Env. Sensor",

View File

@ -432,6 +432,7 @@ void OBP60Task(GwApi *api){
uint brightness = 2.55 * uint(api->getConfig()->getConfigItem(api->getConfig()->blBrightness,true)->asInt());
bool uvoltage = api->getConfig()->getConfigItem(api->getConfig()->underVoltage,true)->asBoolean();
String cpuspeed = api->getConfig()->getConfigItem(api->getConfig()->cpuSpeed,true)->asString();
uint hdopAccuracy = uint(api->getConfig()->getConfigItem(api->getConfig()->hdopAccuracy,true)->asInt());
// refreshmode defined in init section
// displaycolor defined in init section
@ -498,11 +499,11 @@ void OBP60Task(GwApi *api){
commonData.data.maxpage = numPages;
// If GPS fix then LED off (HDOP)
if(String(gpsFix) == "GPS Fix Lost" && date->valid == true){
if(String(gpsFix) == "GPS Fix Lost" && hdop->value <= hdopAccuracy && hdop->valid == true){
setFlashLED(false);
}
// If missing GPS fix then LED on
if(String(gpsFix) == "GPS Fix Lost" && date->valid == false){
if((String(gpsFix) == "GPS Fix Lost" && hdop->value > hdopAccuracy && hdop->valid == true) || (String(gpsFix) == "GPS Fix Lost" && hdop->valid == false)){
setFlashLED(true);
}