* added missing conversion from Fahrenheit to Celsius
  * allow English and/or Metric units in report
pull/2/head
David Freese 2012-01-24 15:40:12 -06:00
rodzic 62d9f428d6
commit 2af9ebcf4c
5 zmienionych plików z 114 dodań i 93 usunięć

Wyświetl plik

@ -3075,10 +3075,10 @@ static void cb_btn_wx_condx(Fl_Check_Button* o, void*) {
progdefaults.changed = true;
}
Fl_Check_Button *btn_wx_temp=(Fl_Check_Button *)0;
Fl_Check_Button *btn_wx_fahrenheit=(Fl_Check_Button *)0;
static void cb_btn_wx_temp(Fl_Check_Button* o, void*) {
progdefaults.wx_temp=o->value();
static void cb_btn_wx_fahrenheit(Fl_Check_Button* o, void*) {
progdefaults.wx_fahrenheit=o->value();
progdefaults.changed = true;
}
@ -3089,10 +3089,10 @@ static void cb_btn_wx_celsius(Fl_Check_Button* o, void*) {
progdefaults.changed = true;
}
Fl_Check_Button *btn_wx_wind=(Fl_Check_Button *)0;
Fl_Check_Button *btn_wx_mph=(Fl_Check_Button *)0;
static void cb_btn_wx_wind(Fl_Check_Button* o, void*) {
progdefaults.wx_wind = o->value();
static void cb_btn_wx_mph(Fl_Check_Button* o, void*) {
progdefaults.wx_mph=o->value();
progdefaults.changed = true;
}
@ -3103,10 +3103,10 @@ static void cb_btn_wx_kph(Fl_Check_Button* o, void*) {
progdefaults.changed = true;
}
Fl_Check_Button *btn_wx_baro=(Fl_Check_Button *)0;
Fl_Check_Button *btn_wx_inches=(Fl_Check_Button *)0;
static void cb_btn_wx_baro(Fl_Check_Button* o, void*) {
progdefaults.wx_baro = o->value();
static void cb_btn_wx_inches(Fl_Check_Button* o, void*) {
progdefaults.wx_inches=o->value();
progdefaults.changed = true;
}
@ -3323,7 +3323,6 @@ Fl_Double_Window* ConfigureDialog() {
tabOperator->tooltip(_("Operator information"));
tabOperator->callback((Fl_Callback*)cb_tabOperator);
tabOperator->when(FL_WHEN_CHANGED);
tabOperator->hide();
{ Fl_Group* o = new Fl_Group(5, 35, 490, 165, _("Station"));
o->box(FL_ENGRAVED_FRAME);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE));
@ -6517,10 +6516,10 @@ d frequency"));
tabID->end();
} // Fl_Group* tabID
{ tabMisc = new Fl_Group(0, 25, 500, 345, _("Misc"));
tabMisc->hide();
{ tabsMisc = new Fl_Tabs(0, 25, 500, 345);
tabsMisc->selection_color(FL_LIGHT1);
{ tabCPUspeed = new Fl_Group(0, 50, 500, 320, _("CPU"));
tabCPUspeed->hide();
{ Fl_Group* o = new Fl_Group(5, 60, 490, 51);
o->box(FL_ENGRAVED_FRAME);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE));
@ -6889,57 +6888,67 @@ d frequency"));
tabDTMF->end();
} // Fl_Group* tabDTMF
{ tabWX = new Fl_Group(0, 50, 500, 320, _("WX"));
{ Fl_Group* o = new Fl_Group(5, 60, 490, 300, _("Weather feed specification"));
tabWX->hide();
{ Fl_Group* o = new Fl_Group(5, 60, 490, 300, _("Weather query specification"));
o->box(FL_ENGRAVED_FRAME);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE));
{ Fl_Input* o = inpWXsta = new Fl_Input(150, 85, 43, 24, _("Airport ID code"));
{ Fl_Input* o = inpWXsta = new Fl_Input(197, 92, 43, 24, _("Airport ID code"));
inpWXsta->tooltip(_("for example KMDQ for \nHuntsville-Madison Executive Airport, AL"));
inpWXsta->callback((Fl_Callback*)cb_inpWXsta);
inpWXsta->align(Fl_Align(FL_ALIGN_RIGHT));
o->value(progdefaults.wx_sta.c_str());
} // Fl_Input* inpWXsta
{ Fl_Check_Button* o = btn_wx_condx = new Fl_Check_Button(150, 125, 70, 15, _("Conditions"));
{ Fl_Check_Button* o = btn_wx_condx = new Fl_Check_Button(205, 135, 70, 15, _("Conditions"));
btn_wx_condx->tooltip(_("current wx conditions"));
btn_wx_condx->down_box(FL_DOWN_BOX);
btn_wx_condx->callback((Fl_Callback*)cb_btn_wx_condx);
o->value(progdefaults.wx_condx);
} // Fl_Check_Button* btn_wx_condx
{ Fl_Check_Button* o = btn_wx_temp = new Fl_Check_Button(150, 156, 70, 15, _("Temp"));
btn_wx_temp->tooltip(_("temperature"));
btn_wx_temp->down_box(FL_DOWN_BOX);
btn_wx_temp->callback((Fl_Callback*)cb_btn_wx_temp);
o->value(progdefaults.wx_temp);
} // Fl_Check_Button* btn_wx_temp
{ Fl_Check_Button* o = btn_wx_celsius = new Fl_Check_Button(258, 156, 70, 15, _("Celsius"));
btn_wx_celsius->tooltip(_("display as Celsius"));
{ Fl_Check_Button* o = btn_wx_fahrenheit = new Fl_Check_Button(205, 166, 70, 15, _("Fahrenheit"));
btn_wx_fahrenheit->tooltip(_("report Fahrenheit"));
btn_wx_fahrenheit->down_box(FL_DOWN_BOX);
btn_wx_fahrenheit->callback((Fl_Callback*)cb_btn_wx_fahrenheit);
o->value(progdefaults.wx_fahrenheit);
} // Fl_Check_Button* btn_wx_fahrenheit
{ Fl_Check_Button* o = btn_wx_celsius = new Fl_Check_Button(336, 166, 70, 15, _("Celsius"));
btn_wx_celsius->tooltip(_("report Celsius"));
btn_wx_celsius->down_box(FL_DOWN_BOX);
btn_wx_celsius->callback((Fl_Callback*)cb_btn_wx_celsius);
o->value(progdefaults.wx_celsius);
} // Fl_Check_Button* btn_wx_celsius
{ Fl_Check_Button* o = btn_wx_wind = new Fl_Check_Button(150, 187, 70, 15, _("Wind dir/spd"));
btn_wx_wind->tooltip(_("wind direction in degrees\nspeed in mph"));
btn_wx_wind->down_box(FL_DOWN_BOX);
btn_wx_wind->callback((Fl_Callback*)cb_btn_wx_wind);
o->value(progdefaults.wx_wind);
} // Fl_Check_Button* btn_wx_wind
{ Fl_Check_Button* o = btn_wx_kph = new Fl_Check_Button(258, 187, 70, 15, _("kilometers / hour"));
btn_wx_kph->tooltip(_("display wind speed in kph"));
{ Fl_Check_Button* o = btn_wx_mph = new Fl_Check_Button(205, 197, 70, 15, _("Miles / Hour"));
btn_wx_mph->tooltip(_("report miles per hour"));
btn_wx_mph->down_box(FL_DOWN_BOX);
btn_wx_mph->callback((Fl_Callback*)cb_btn_wx_mph);
o->value(progdefaults.wx_mph);
} // Fl_Check_Button* btn_wx_mph
{ Fl_Check_Button* o = btn_wx_kph = new Fl_Check_Button(336, 197, 70, 15, _("kilometers / hour"));
btn_wx_kph->tooltip(_("report kilometers per hour"));
btn_wx_kph->down_box(FL_DOWN_BOX);
btn_wx_kph->callback((Fl_Callback*)cb_btn_wx_kph);
o->value(progdefaults.wx_kph);
} // Fl_Check_Button* btn_wx_kph
{ Fl_Check_Button* o = btn_wx_baro = new Fl_Check_Button(150, 219, 70, 15, _("Baro Press"));
btn_wx_baro->tooltip(_("barometric pressure in inches of mercury"));
btn_wx_baro->down_box(FL_DOWN_BOX);
btn_wx_baro->callback((Fl_Callback*)cb_btn_wx_baro);
o->value(progdefaults.wx_baro);
} // Fl_Check_Button* btn_wx_baro
{ Fl_Check_Button* o = btn_wx_mbars = new Fl_Check_Button(258, 219, 70, 15, _("mbars"));
btn_wx_mbars->tooltip(_("display baro in millibars"));
{ Fl_Check_Button* o = btn_wx_inches = new Fl_Check_Button(205, 229, 70, 15, _("Inches Mg."));
btn_wx_inches->tooltip(_("report inches mercury"));
btn_wx_inches->down_box(FL_DOWN_BOX);
btn_wx_inches->callback((Fl_Callback*)cb_btn_wx_inches);
o->value(progdefaults.wx_inches);
} // Fl_Check_Button* btn_wx_inches
{ Fl_Check_Button* o = btn_wx_mbars = new Fl_Check_Button(336, 229, 70, 15, _("mbars"));
btn_wx_mbars->tooltip(_("report millibars"));
btn_wx_mbars->down_box(FL_DOWN_BOX);
btn_wx_mbars->callback((Fl_Callback*)cb_btn_wx_mbars);
o->value(progdefaults.wx_mbars);
} // Fl_Check_Button* btn_wx_mbars
{ Fl_Box* o = new Fl_Box(45, 164, 156, 19, _("Temperature"));
o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
} // Fl_Box* o
{ Fl_Box* o = new Fl_Box(45, 195, 156, 19, _("Wind speed/dir"));
o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
} // Fl_Box* o
{ Fl_Box* o = new Fl_Box(45, 227, 156, 19, _("Barometric pressure"));
o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
} // Fl_Box* o
o->end();
} // Fl_Group* o
tabWX->end();

Wyświetl plik

@ -136,8 +136,8 @@ static const char szProsigns[] = "~|%|&|+|=|{|}|<|>|[|]| ";} {}
} {
Fl_Group tabOperator {
label Operator
callback {progdefaults.changed = true;}
tooltip {Operator information} xywh {0 25 500 345} when 1 hide
callback {progdefaults.changed = true;} selected
tooltip {Operator information} xywh {0 25 500 345} when 1
} {
Fl_Group {} {
label Station open
@ -3540,14 +3540,14 @@ progdefaults.changed = true;}
}
Fl_Group tabMisc {
label Misc open
xywh {0 25 500 345}
xywh {0 25 500 345} hide
} {
Fl_Tabs tabsMisc {open
xywh {0 25 500 345} selection_color 50
} {
Fl_Group tabCPUspeed {
label CPU open
xywh {0 50 500 320} hide
xywh {0 50 500 320}
} {
Fl_Group {} {open
xywh {5 60 490 51} box ENGRAVED_FRAME align 21
@ -3870,10 +3870,10 @@ progdefaults.changed = true;}
}
Fl_Group tabWX {
label WX open
xywh {0 50 500 320}
xywh {0 50 500 320} hide
} {
Fl_Group {} {
label {Weather feed specification} open
label {Weather query specification} open
xywh {5 60 490 300} box ENGRAVED_FRAME align 21
} {
Fl_Input inpWXsta {
@ -3881,59 +3881,70 @@ progdefaults.changed = true;}
callback {progdefaults.wx_sta = o->value();
progdefaults.changed = true;}
tooltip {for example KMDQ for
Huntsville-Madison Executive Airport, AL} xywh {150 85 43 24} align 8
Huntsville-Madison Executive Airport, AL} xywh {197 92 43 24} align 8
code0 {o->value(progdefaults.wx_sta.c_str());}
}
Fl_Check_Button btn_wx_condx {
label Conditions
callback {progdefaults.wx_condx=o->value();
progdefaults.changed = true;}
tooltip {current wx conditions} xywh {150 125 70 15} down_box DOWN_BOX
tooltip {current wx conditions} xywh {205 135 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_condx);}
}
Fl_Check_Button btn_wx_temp {
label Temp
callback {progdefaults.wx_temp=o->value();
Fl_Check_Button btn_wx_fahrenheit {
label Fahrenheit
callback {progdefaults.wx_fahrenheit=o->value();
progdefaults.changed = true;}
tooltip temperature xywh {150 156 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_temp);}
tooltip {report Fahrenheit} xywh {205 166 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_fahrenheit);}
}
Fl_Check_Button btn_wx_celsius {
label Celsius
callback {progdefaults.wx_celsius=o->value();
progdefaults.changed = true;}
tooltip {display as Celsius} xywh {258 156 70 15} down_box DOWN_BOX
tooltip {report Celsius} xywh {336 166 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_celsius);}
}
Fl_Check_Button btn_wx_wind {
label {Wind dir/spd}
callback {progdefaults.wx_wind = o->value();
Fl_Check_Button btn_wx_mph {
label {Miles / Hour}
callback {progdefaults.wx_mph=o->value();
progdefaults.changed = true;}
tooltip {wind direction in degrees
speed in mph} xywh {150 187 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_wind);}
tooltip {report miles per hour} xywh {205 197 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_mph);}
}
Fl_Check_Button btn_wx_kph {
label {kilometers / hour}
callback {progdefaults.wx_kph=o->value();
progdefaults.changed = true;}
tooltip {display wind speed in kph} xywh {258 187 70 15} down_box DOWN_BOX
tooltip {report kilometers per hour} xywh {336 197 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_kph);}
}
Fl_Check_Button btn_wx_baro {
label {Baro Press}
callback {progdefaults.wx_baro = o->value();
Fl_Check_Button btn_wx_inches {
label {Inches Mg.}
callback {progdefaults.wx_inches=o->value();
progdefaults.changed = true;}
tooltip {barometric pressure in inches of mercury} xywh {150 219 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_baro);}
tooltip {report inches mercury} xywh {205 229 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_inches);}
}
Fl_Check_Button btn_wx_mbars {
label mbars
callback {progdefaults.wx_mbars=o->value();
progdefaults.changed = true;} selected
tooltip {display baro in millibars} xywh {258 219 70 15} down_box DOWN_BOX
progdefaults.changed = true;}
tooltip {report millibars} xywh {336 229 70 15} down_box DOWN_BOX
code0 {o->value(progdefaults.wx_mbars);}
}
Fl_Box {} {
label Temperature
xywh {45 164 156 19} align 20
}
Fl_Box {} {
label {Wind speed/dir}
xywh {45 195 156 19} align 20
}
Fl_Box {} {
label {Barometric pressure}
xywh {45 227 156 19} align 20
}
}
}
}

Wyświetl plik

@ -419,11 +419,11 @@ extern Fl_Check_Button *chkDTMFdecode;
extern Fl_Group *tabWX;
extern Fl_Input *inpWXsta;
extern Fl_Check_Button *btn_wx_condx;
extern Fl_Check_Button *btn_wx_temp;
extern Fl_Check_Button *btn_wx_fahrenheit;
extern Fl_Check_Button *btn_wx_celsius;
extern Fl_Check_Button *btn_wx_wind;
extern Fl_Check_Button *btn_wx_mph;
extern Fl_Check_Button *btn_wx_kph;
extern Fl_Check_Button *btn_wx_baro;
extern Fl_Check_Button *btn_wx_inches;
extern Fl_Check_Button *btn_wx_mbars;
extern Fl_Group *tabQRZ;
extern Fl_Round_Button *btnQRZWEBnotavailable;

Wyświetl plik

@ -1297,24 +1297,24 @@
ELEM_(bool, wx_condx, "WX_CONDX", \
"weather conditions", \
true) \
ELEM_(bool, wx_temp, "WX_TEMP", \
"temperature", \
ELEM_(bool, wx_fahrenheit, "WX_FAHRENHEIT", \
"report in Fahrenheit", \
true) \
ELEM_(bool, wx_celsius, "WX_CELSIUS", \
"report in Celsius", \
false) \
ELEM_(bool, wx_wind, "WX_WIND", \
"wind direction/speed", \
true) \
ELEM_(bool, wx_mph, "WX_MPH", \
"report speed in miles per hour", \
true) \
ELEM_(bool, wx_kph, "WX_KPH", \
"report speed in kilometers per hour", \
false) \
ELEM_(bool, wx_baro, "WX_BARO", \
"barometric pressure", \
true) \
ELEM_(bool, wx_inches, "WX_INCHES", \
"report pressure in inches of mercury", \
true) \
ELEM_(bool, wx_mbars, "WX_MBARS", \
"report pressure in millibars", \
false) \
true) \
// declare the struct

Wyświetl plik

@ -84,24 +84,25 @@ void getwx(std::string& wx, const char *metar)
if (p2 != std::string::npos)
wx.append("WX: ").append(retxml.substr(p1, p2 - p1)).append("\n");
}
if (progdefaults.wx_temp &&
if ((progdefaults.wx_fahrenheit || progdefaults.wx_celsius) &&
(p1 = retxml.find("<temp_f>")) != std::string::npos) {
p1 += 8;
p2 = retxml.find("</temp_f>", p1);
if (p2 != std::string::npos) {
wx.append("Temp: ");
if (!progdefaults.wx_celsius)
wx.append(retxml.substr(p1, p2 - p1)).append(" F\n");
else {
if (progdefaults.wx_fahrenheit)
wx.append(retxml.substr(p1, p2 - p1)).append(" F ");
if (progdefaults.wx_celsius) {
float temp;
sscanf(retxml.substr(p1, p2 - p1).c_str(), "%f", &temp);
char ctemp[10];
snprintf(ctemp, sizeof(ctemp), "%.1f C\n", temp);
snprintf(ctemp, sizeof(ctemp), "%.1f C", (temp - 32)/2.12);
wx.append(ctemp);
}
wx.append("\n");
}
}
if (progdefaults.wx_wind &&
if ((progdefaults.wx_mph || progdefaults.wx_kph) &&
(p1 = retxml.find("<wind_degrees>")) != std::string::npos) {
p1 += 14;
p2 = retxml.find("</wind_degrees>", p1);
@ -112,13 +113,13 @@ void getwx(std::string& wx, const char *metar)
p2 = retxml.find("</wind_mph>");
if (p2 != std::string::npos) {
wx.append(" at ");
if (!progdefaults.wx_kph)
wx.append(retxml.substr(p1, p2 - p1)).append(" mph");
else {
if (progdefaults.wx_mph)
wx.append(retxml.substr(p1, p2 - p1)).append(" mph ");
if (progdefaults.wx_kph) {
float mph;
sscanf(retxml.substr(p1, p2 - p1).c_str(), "%f", &mph);
char ckph[10];
snprintf(ckph, sizeof(ckph), "%.1f kph",
snprintf(ckph, sizeof(ckph), "%.1f kph",
mph * 1.8288);
wx.append(ckph);
}
@ -127,19 +128,19 @@ void getwx(std::string& wx, const char *metar)
wx.append("\n");
}
}
if (progdefaults.wx_baro &&
if ((progdefaults.wx_inches || progdefaults.wx_mbars) &&
(p1 = retxml.find("<pressure_in>")) != std::string::npos) {
p1 += 13;
p2 = retxml.find("</pressure_in>", p1);
if (p2 != std::string::npos) {
wx.append("Baro: ");
if (!progdefaults.wx_mbars)
wx.append(retxml.substr(p1, p2 - p1)).append(" in.");
else {
if (progdefaults.wx_inches)
wx.append(retxml.substr(p1, p2 - p1)).append(" in. ");
if (progdefaults.wx_mbars) {
float inches;
sscanf(retxml.substr(p1, p2 - p1).c_str(), "%f", &inches);
char cmbar[10];
snprintf(cmbar, sizeof(cmbar), "%.0f mbar",
snprintf(cmbar, sizeof(cmbar), "%.0f mbar",
inches * 33.87);
wx.append(cmbar);
}