static int OnTimerNotify(WindowControl * Sender) { (void)Sender; // devices are updates by BallastDump() method when dumping water ballast SetBallast(false); WndProperty* wp; static double altlast = GPS_INFO.BaroAltitude; if (fabs(GPS_INFO.BaroAltitude-altlast)>1) { wp = (WndProperty*)wf->FindByName(TEXT("prpAltitude")); if (wp) { wp->GetDataField()-> SetAsFloat(Units::ToUserAltitude(GPS_INFO.BaroAltitude)); wp->RefreshDisplay(); } } altlast = GPS_INFO.BaroAltitude; static float flastBugs=BUGS; if (fabs(flastBugs-BUGS) >= 0.001) /* update on change only */ { if(wf) { wp = (WndProperty*)wf->FindByName(gettext(TEXT("prpBugs"))); if (wp) { wp->GetDataField()->SetAsFloat(BUGS*100); wp->RefreshDisplay(); flastBugs = BUGS; } } } return 0; }
static void OnBallastData(DataField *Sender, DataField::DataAccessKind_t Mode){ static double lastRead = -1; switch(Mode){ case DataField::daSpecial: if (BALLAST>0.01) { BallastTimerActive = !BallastTimerActive; } else { BallastTimerActive = false; } ((WndButton *)wf->FindByName(TEXT("buttonDumpBallast")))->SetVisible(!BallastTimerActive); ((WndButton *)wf->FindByName(TEXT("buttonStopDump")))->SetVisible(BallastTimerActive); break; case DataField::daGet: lastRead = BALLAST; Sender->Set(BALLAST*100); break; case DataField::daChange: case DataField::daPut: if (fabs(lastRead-Sender->GetAsFloat()/100.0) >= 0.005){ lastRead = BALLAST = Sender->GetAsFloat()/100.0; SetBallast(true); } break; case DataField::daInc: case DataField::daDec: break; } }
static void RunUI(Port &port, OperationEnvironment &env) { WriteMenu(); while (true) { fprintf(stdout, "> "); char in[20]; if (fgets(in, 20, stdin) == NULL || strlen(in) == 0) { fprintf(stdout, "Invalid input\n"); continue; } switch (in[0]) { case '?': case 'h': case 'H': WriteMenu(); break; case '1': SetMC(port, env); break; case '2': SetBallast(port, env); break; case '3': SetBugs(port, env); break; case '4': SetAltitudeOffset(port, env); break; case '5': SetQNH(port, env); break; case '6': SetVolume(port, env); break; case 'p': case 'P': SetPolar(port, env); break; case 'f': case 'F': SetFilters(port, env); break; case 's': case 'S': SetSCSettings(port, env); break; case 'q': case 'Q': fprintf(stdout, "Closing LX1600 Utils ...\n"); return; default: fprintf(stdout, "Invalid input\n"); break; } } }
virtual void Show(const PixelRect &rc) override { RowFormWidget::Show(rc); Timer::Schedule(500); OnTimer(); SetButtons(); SetBallast(); }
void FlightSetupPanel::OnTimer() { const PolarSettings &settings = CommonInterface::GetComputerSettings().polar; if (settings.ballast_timer_active) { /* display the new values on the screen */ SetBallast(); } RefreshAltitudeControl(); }
/** * This function is called repeatedly by the timer and updates the * current altitude and ballast. The ballast can change without user * input due to the dump function. */ static void OnTimerNotify(gcc_unused WndForm &Sender) { if (protected_task_manager != NULL && XCSoarInterface::GetComputerSettings().ballast_timer_active && !changed) { /* get new GlidePolar values */ glide_polar = CommonInterface::GetComputerSettings().glide_polar_task; /* display the new values on the screen */ SetBallast(); /* SetBallast() may have set the "changed" flag, reset it */ changed = false; } RefreshAltitudeControl(); }
static void OnBallastData(DataField *Sender, DataField::DataAccessKind_t Mode) { DataFieldFloat &df = *(DataFieldFloat *)Sender; switch (Mode) { case DataField::daSpecial: SetBallastTimer(glide_polar.HasBallast() && !XCSoarInterface::GetComputerSettings().ballast_timer_active); break; case DataField::daChange: glide_polar.SetBallastLitres(df.GetAsFixed()); changed = true; SetButtons(); SetBallast(); break; } }
static int OnTimerNotify(WindowControl * Sender) { (void)Sender; // devices are updates by BallastDump() method when dumping water ballast SetBallast(false); static double altlast = GPS_INFO.BaroAltitude; if (fabs(GPS_INFO.BaroAltitude-altlast)>1) { WndProperty* wp; wp = (WndProperty*)wf->FindByName(TEXT("prpAltitude")); if (wp) { wp->GetDataField()-> SetAsFloat(Units::ToUserAltitude(GPS_INFO.BaroAltitude)); wp->RefreshDisplay(); } } altlast = GPS_INFO.BaroAltitude; return 0; }
void SetBallastLitres(fixed ballast_litres) { polar_settings.glide_polar_task.SetBallastLitres(ballast_litres); PublishPolarSettings(); SetButtons(); SetBallast(); }
void dlgBasicSettingsShowModal() { const ComputerSettings &settings = CommonInterface::GetComputerSettings(); glide_polar = settings.glide_polar_task; wf = LoadDialog(CallBackTable, XCSoarInterface::main_window, _T("IDR_XML_BASICSETTINGS")); if (wf == NULL) return; changed = false; wf->SetTimerNotify(OnTimerNotify); OnTimerNotify(*wf); SetButtons(); SetBallast(); LoadFormProperty(*wf, _T("prpBugs"), (fixed_one - glide_polar.GetBugs()) * 100); LoadFormProperty(*wf, _T("prpQNH"), Units::ToUserPressure(settings.pressure.GetHectoPascal())); WndProperty* wp; wp = (WndProperty*)wf->FindByName(_T("prpQNH")); if (wp) { DataFieldFloat &df = *(DataFieldFloat *)wp->GetDataField(); df.SetMin(Units::ToUserPressure(Units::ToSysUnit(fixed(850), unHectoPascal))); df.SetMax(Units::ToUserPressure(Units::ToSysUnit(fixed(1300), unHectoPascal))); df.SetStep(Units::ToUserPressure(Units::ToSysUnit(fixed_one, unHectoPascal))); df.SetUnits(Units::GetPressureName()); df.SetStep(Units::PressureStep()); df.SetFormat( Units::GetFormatUserPressure()); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(_T("prpTemperature")); if (wp) { DataFieldFloat &df = *(DataFieldFloat *)wp->GetDataField(); df.SetMin(Units::ToUserTemperature(Units::ToSysUnit(fixed(-50), unGradCelcius))); df.SetMax(Units::ToUserTemperature(Units::ToSysUnit(fixed(60), unGradCelcius))); df.SetUnits(Units::GetTemperatureName()); df.Set(Units::ToUserTemperature(settings.forecast_temperature)); wp->RefreshDisplay(); } if (wf->ShowModal() == mrOK) { ComputerSettings &settings = CommonInterface::SetComputerSettings(); if (changed) { settings.glide_polar_task = glide_polar; if (protected_task_manager != NULL) protected_task_manager->SetGlidePolar(glide_polar); } SaveFormProperty(*wf, _T("prpTemperature"), ugTemperature, settings.forecast_temperature); } delete wf; }