static void OnAltitudeData(DataField *Sender, DataField::DataAccessKind_t Mode){ static double newalt=0; WndProperty* wp; switch(Mode){ case DataField::daGet: break; case DataField::daPut: case DataField::daChange: newalt = Sender->GetAsFloat(); QNH=FindQNH(GPS_INFO.BaroAltitude,Units::ToSysAltitude(newalt)); // 100411 wp = (WndProperty*)wf->FindByName(TEXT("prpQNH")); if (wp) { if (PressureHg) { INHg=QNH/TOHPA; wp->GetDataField()-> SetAsFloat(INHg); } else { wp->GetDataField()-> SetAsFloat(QNH); } wp->RefreshDisplay(); } UpdateQNH(QNH); break; case DataField::daInc: case DataField::daDec: case DataField::daSpecial: break; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Parses LXWP0 sentence. /// /// @param d device descriptor /// @param sentence received NMEA sentence /// @param info GPS info to be updated /// /// @retval true if the sentence has been parsed /// //static bool DevLXMiniMap::LXWP0(PDeviceDescriptor_t d, const TCHAR* sentence, NMEA_INFO* info) { // $LXWP0,logger_stored, airspeed, airaltitude, // v1[0],v1[1],v1[2],v1[3],v1[4],v1[5], hdg, windspeed*CS<CR><LF> // // 0 loger_stored : [Y|N] (not used in LX1600) // 1 IAS [km/h] ----> Condor uses TAS! // 2 baroaltitude [m] // 3-8 vario values [m/s] (last 6 measurements in last second) // 9 heading of plane (not used in LX1600) // 10 windcourse [deg] (not used in LX1600) // 11 windspeed [km/h] (not used in LX1600) // // e.g.: // $LXWP0,Y,222.3,1665.5,1.71,,,,,,239,174,10.1 TICKER = GetTickCount(); double alt, airspeed; if (ParToDouble(sentence, 1, &airspeed)) { airspeed /= TOKPH; info->TrueAirspeed = airspeed; info->AirspeedAvailable = TRUE; } if (ParToDouble(sentence, 2, &alt)) { info->IndicatedAirspeed = airspeed / AirDensityRatio(alt); if (d == pDevPrimaryBaroSource) { UpdateQNH(CalculateQNH(alt, alt + AltOffset)); UpdateBaroSource(info, 0, d, alt + AltOffset); /* if(FirstCheckBaroAlt) { FirstCheckBaroAlt = false; InputEvents::eventSetup(_T("Basic")); }*/ } } if (ParToDouble(sentence, 3, &info->Vario)) info->VarioAvailable = TRUE; if (ParToDouble(sentence, 10, &info->ExternalWindDirection) && ParToDouble(sentence, 11, &info->ExternalWindSpeed)) info->ExternalWindAvailable = TRUE; TriggerVarioUpdate(); return(true); } // LXWP0()
static void OnQnhData(DataField *Sender, DataField::DataAccessKind_t Mode){ WndProperty* wp; double newqnh=0; switch(Mode){ case DataField::daGet: if (PressureHg) { INHg=QNH/TOHPA; Sender->Set(INHg); } else { Sender->Set(QNH); } break; case DataField::daPut: case DataField::daChange: if (PressureHg) { INHg = Sender->GetAsFloat(); newqnh=INHg*TOHPA; } else { newqnh = Sender->GetAsFloat(); } if ( UpdateQNH(newqnh) ) devPutQNH(devAll(), newqnh); // VarioWriteSettings(); wp = (WndProperty*)wf->FindByName(TEXT("prpAltitude")); if (wp) { wp->GetDataField()-> SetAsFloat(Units::ToUserAltitude(GPS_INFO.BaroAltitude)); wp->RefreshDisplay(); } break; default: break; } }
static BOOL PDGFTL1(PDeviceDescriptor_t d, TCHAR *String, NMEA_INFO *pGPS) { /* $PDGFTL1 field example QNE 1013.25 altitude 0 2025 meters QNH altitude 1 2000 meters vario cm/s 2 250 2.5m/s netto vario 3 -14 dm/s IAS 4 45 kmh ground efficiency 5 134 13:4 GR Wind speed 6 28 kmh Wind direction 7 65 degrees Main lithium battery 3,82 v 8 382 0.01v Backup AA battery 1,53 v 9 153 0.01v 100209 Paolo Ventafridda netto and ias optionals */ TCHAR ctemp[80]; double vtas, vias; double altqne, altqnh; static bool initqnh=true; NMEAParser::ExtractParameter(String,ctemp,0); altqne = StrToDouble(ctemp,NULL); NMEAParser::ExtractParameter(String,ctemp,1); altqnh = StrToDouble(ctemp,NULL); // AutoQNH will take care of setting an average QNH if nobody does it for a while if (initqnh) { // if digifly has qnh set by user qne and qnh are of course different if (altqne != altqnh) { UpdateQNH(FindQNH(altqne,altqnh)); StartupStore(_T(". Using Digifly QNH %f%s"),QNH,NEWLINE); initqnh=false; } else { // if locally QNH was set, either by user of by AutoQNH, stop processing QNH from digifly if ( (QNH <= 1012) || (QNH>=1014)) initqnh=false; // else continue entering initqnh until somebody changes qnh in either digifly or lk8000 } } UpdateBaroSource( pGPS,0, d, AltitudeToQNHAltitude(altqne)); NMEAParser::ExtractParameter(String,ctemp,2); #if 1 pGPS->Vario = StrToDouble(ctemp,NULL)/100; #else double newVario = StrToDouble(ctemp,NULL)/100; pGPS->Vario = LowPassFilter(pGPS->Vario,newVario,0.1); #endif pGPS->VarioAvailable = TRUE; NMEAParser::ExtractParameter(String,ctemp,3); if (ctemp[0] != '\0') { pGPS->NettoVario = StrToDouble(ctemp,NULL)/10; // dm/s pGPS->NettoVarioAvailable = TRUE; } else pGPS->NettoVarioAvailable = FALSE; NMEAParser::ExtractParameter(String,ctemp,4); if (ctemp[0] != '\0') { // we store m/s , so we convert it from kmh vias = StrToDouble(ctemp,NULL)/3.6; if (vias >1) { vtas = vias*AirDensityRatio(altqne); pGPS->TrueAirspeed = vtas; pGPS->IndicatedAirspeed = vias; pGPS->AirspeedAvailable = TRUE; } } else { pGPS->AirspeedAvailable = FALSE; } NMEAParser::ExtractParameter(String,ctemp,8); pGPS->ExtBatt1_Voltage = StrToDouble(ctemp,NULL)/100; NMEAParser::ExtractParameter(String,ctemp,9); pGPS->ExtBatt2_Voltage = StrToDouble(ctemp,NULL)/100; TriggerVarioUpdate(); return TRUE; }
bool DevLXV7_EXP::PLXV0(PDeviceDescriptor_t d, const TCHAR* sentence, NMEA_INFO* info) { TCHAR szTmp1[80], szTmp2[80]; NMEAParser::ExtractParameter(sentence,szTmp1,1); if (_tcscmp(szTmp1,_T("W"))!=0) // no write flag received return false; NMEAParser::ExtractParameter(sentence,szTmp1,0); if (_tcscmp(szTmp1,_T("BRGPS"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); LXV7_EXP_iGPSBaudrate = LXV7_EXPBaudrate( (int)( (StrToDouble(szTmp2,NULL))+0.1 ) ); return true; } if (_tcscmp(szTmp1,_T("BRPDA"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); LXV7_EXP_iPDABaudrate = LXV7_EXPBaudrate( (int) StrToDouble(szTmp2,NULL)); return true; } NMEAParser::ExtractParameter(sentence,szTmp1,0); if (_tcscmp(szTmp1,_T("QNH"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); UpdateQNH((StrToDouble(szTmp2,NULL))/100.0); return true; } #ifdef DEBUG_PARAMETERS if (_tcscmp(szTmp1,_T("MC"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); iTmp =(int) StrToDouble(szTmp2,NULL); return true; } if (_tcscmp(szTmp1,_T("BAL"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); iTmp = (int) StrToDouble(szTmp2,NULL); return true; } if (_tcscmp(szTmp1,_T("BUGS"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); iTmp = (int) StrToDouble(szTmp2,NULL); return true; } if (_tcscmp(szTmp1,_T("VOL"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); iTmp = (int) StrToDouble(szTmp2,NULL); return true; } if (_tcscmp(szTmp1,_T("POLAR"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); iTmp = (int) StrToDouble(szTmp2,NULL); return true; } if (_tcscmp(szTmp1,_T("CONNECTION"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); iTmp = (int) StrToDouble(szTmp2,NULL); return true; } if (_tcscmp(szTmp1,_T("NMEARATE"))==0) { NMEAParser::ExtractParameter(sentence,szTmp2,2); iTmp = (int) StrToDouble(szTmp2,NULL); return true; } #endif return(false); } // PLXV0()