Exemple #1
0
void
InfoBoxContentTeamBearing::Update(InfoBoxWindow &infobox)
{
  if (XCSoarInterface::SettingsComputer().TeamFlarmIdTarget.defined() ||
      XCSoarInterface::SettingsComputer().TeammateCodeValid == true){
    // Set Value
    infobox.SetValue(XCSoarInterface::Calculated().TeammateBearing,
                     _T("T"));
  }
  else
    infobox.SetValueInvalid();

  // Set Comment
  if (!XCSoarInterface::SettingsComputer().TeamFlarmIdTarget.defined())
    infobox.SetCommentInvalid();
  else if (!string_is_empty(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget))
    infobox.SetComment(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget);
  else
    infobox.SetComment(_T("???"));

  if (XCSoarInterface::Basic().flarm.FindTraffic(
      XCSoarInterface::SettingsComputer().TeamFlarmIdTarget) != NULL)
    infobox.SetColorBottom(2);
  else
    infobox.SetColorBottom(1);
}
void
InfoBoxContentNextWaypoint::Update(InfoBoxWindow &infobox)
{
  // use proper non-terminal next task stats

  const Waypoint* way_point = protected_task_manager != NULL
    ? protected_task_manager->getActiveWaypoint()
    : NULL;

  if (!way_point) {
    infobox.SetTitle(_("Next"));
    infobox.SetInvalid();
    return;
  }
  SetTitleFromWaypointName(infobox, way_point);

  // Set Comment
  if (way_point->radio_frequency.IsDefined()) {
    StaticString<128> comment;
    const unsigned freq = way_point->radio_frequency.GetKiloHertz();
    _sntprintf(comment.buffer(), comment.MAX_SIZE, _T("%u.%03u %s"),
               freq / 1000, freq % 1000, way_point->Comment.c_str());
    infobox.SetComment(comment);
  }
  else
    infobox.SetComment(way_point->Comment.c_str());

  const GlideResult &solution_remaining =
    XCSoarInterface::Calculated().task_stats.current_leg.solution_remaining;
  if (!XCSoarInterface::Basic().track_available ||
      !XCSoarInterface::Calculated().task_stats.task_valid ||
      !solution_remaining.defined() ||
      solution_remaining.Vector.Distance <= fixed(10)) {
    infobox.SetValueInvalid();
    return;
  }

  // Set Value
  Angle Value =
    solution_remaining.Vector.Bearing - XCSoarInterface::Basic().track;

  SetValueBearingDifference(infobox, Value);

  // Set Color (blue/black)
  infobox.SetColor(solution_remaining.is_final_glide() ? 2 : 0);
}
Exemple #3
0
void
InfoBoxContentBattery::Update(InfoBoxWindow &infobox)
{
#ifdef HAVE_BATTERY
  TCHAR tmp[32];

  bool DisplaySupplyVoltageAsValue=false;
  switch (Power::External::Status) {
    case Power::External::OFF:
      infobox.SetComment(_("AC Off"));
      break;
    case Power::External::ON:
      if (!XCSoarInterface::Basic().voltage_available)
        infobox.SetComment(_("AC ON"));
      else{
        DisplaySupplyVoltageAsValue = true;
        SetValueFromFixed(infobox, _T("%2.1fV"),
                          XCSoarInterface::Basic().voltage);
      }
      break;
    case Power::External::UNKNOWN:
    default:
      infobox.SetCommentInvalid();
  }
#ifndef ANDROID
  switch (Power::Battery::Status){
    case Power::Battery::HIGH:
    case Power::Battery::LOW:
    case Power::Battery::CRITICAL:
    case Power::Battery::CHARGING:
      if (Power::Battery::RemainingPercentValid){
#endif
        _stprintf(tmp, _T("%d%%"), Power::Battery::RemainingPercent);
        if (!DisplaySupplyVoltageAsValue)
          infobox.SetValue(tmp);
        else
          infobox.SetComment(tmp);
#ifndef ANDROID
      }
      else
        if (!DisplaySupplyVoltageAsValue)
          infobox.SetValueInvalid();
        else
          infobox.SetCommentInvalid();
      break;
    case Power::Battery::NOBATTERY:
    case Power::Battery::UNKNOWN:
      if (!DisplaySupplyVoltageAsValue)
        infobox.SetValueInvalid();
      else
        infobox.SetCommentInvalid();
  }
#endif
  return;

#endif

  if (XCSoarInterface::Basic().voltage_available) {
    SetValueFromFixed(infobox, _T("%2.1fV"),
                      XCSoarInterface::Basic().voltage);
    return;
  }

  infobox.SetInvalid();
}