1
0
Fork 0

- Update GPS zkv500 by Zakharov

This commit is contained in:
helijah 2008-06-30 16:31:48 +00:00
parent 5e9df124b6
commit bdf204bcc1
4 changed files with 46 additions and 49 deletions

View file

@ -3,23 +3,17 @@ var screenAirportMain = {
apt_coord: nil, apt_coord: nil,
apt: nil, apt: nil,
searched: 0, searched: 0,
right : func { oaci: nil,
search: func {
me.apt = me.oaci != nil ? airportinfo(me.oaci) : airportinfo();
if (me.apt != nil) {
glide_slope_tunnel.complement_runways(me.apt);
return 1;
}
else
return 0;
}, },
apt_to_waypoint : func { right : func {
gps_wp.getNode("wp/longitude-deg",1).setValue(me.pos.lat());
gps_wp.getNode("wp/latitude-deg",1).setValue(me.pos.lon());
gps_wp.getNode("wp/altitude-ft",1).setValue(me.pos.alt()*alt_conv[1][0]);
gps_wp.getNode("wp/ID",1).setValue("STARTPOS");
gps_wp.getNode("wp/name",1).setValue("start position");
gps_wp.getNode("wp[1]/longitude-deg",1).setValue(me.apt_coord.lat());
gps_wp.getNode("wp[1]/latitude-deg",1).setValue(me.apt_coord.lon());
gps_wp.getNode("wp[1]/altitude-ft",1).setValue(me.apt_coord.alt()*alt_conv[1][0]);
gps_wp.getNode("wp[1]/ID",1).setValue(me.apt.id);
gps_wp.getNode("wp[1]/name",1).setValue(me.apt.name);
mode = 2;
page = 1;
displayed_screen = 1; #screenNavigationMain
}, },
enter : func { #add to route enter : func { #add to route
add_waypoint(me.apt.id, me.apt.name, "APT", add_waypoint(me.apt.id, me.apt.name, "APT",
@ -27,6 +21,8 @@ var screenAirportMain = {
me.apt_coord.alt()*alt_conv[1][0]]); me.apt_coord.alt()*alt_conv[1][0]]);
}, },
escape : func { escape : func {
me.searched = 0;
me.oaci = nil;
}, },
start : func { #add bookmark, enter turnpoint mode start : func { #add bookmark, enter turnpoint mode
add_bookmark(me.apt.id, me.apt.name, "APT", add_bookmark(me.apt.id, me.apt.name, "APT",
@ -36,21 +32,16 @@ var screenAirportMain = {
screenTurnpointSelect.start(); screenTurnpointSelect.start();
}, },
lines : func { lines : func {
if (me.apt == nil) { if (me.search() == 1) { #FIXME: THE SEARCH SHOULD BE DONE ONLY ONE TIME,
me.apt = airportinfo(); # BUT IT SEEMS TO BE EXECUTED 3 TIMES/SEC
print("youpi ", me.count); # I DON'T KNOW YET WHY... :/
me.searched = 0;
}
if (me.apt != nil) {
glide_slope_tunnel.complement_runways(me.apt);
var rwy = glide_slope_tunnel.best_runway(me.apt); var rwy = glide_slope_tunnel.best_runway(me.apt);
me.pos = geo.Coord.new(geo.aircraft_position()); me.pos = geo.Coord.new(geo.aircraft_position());
me.apt_coord = geo.Coord.new().set_latlon(rwy.lat, rwy.lon); me.apt_coord = geo.Coord.new().set_latlon(rwy.lat, rwy.lon);
var ac_to_apt = [me.pos.distance_to(me.apt_coord), me.pos.course_to(me.apt_coord)]; var ac_to_apt = [me.pos.distance_to(me.apt_coord), me.pos.course_to(me.apt_coord)];
var ete = ac_to_apt[0] / getprop("instrumentation/gps/indicated-ground-speed-kt") * 3600 * 1852; var ete = ac_to_apt[0] / getprop("instrumentation/gps/indicated-ground-speed-kt") * 3600 * 1852;
print ("me.searched: ",me.searched);
display([ display([
sprintf("%s APT: %s", me.searched != nil ? "SEARCHED" : "NEAREST", me.apt.id), sprintf("%s APT: %s", me.searched != 0 ? "SEARCHED" : "NEAREST", me.apt.id),
sprintf("ELEV: %d %s", me.apt.elevation * alt_conv[1][alt_unit],alt_unit_short_name[alt_unit]), sprintf("ELEV: %d %s", me.apt.elevation * alt_conv[1][alt_unit],alt_unit_short_name[alt_unit]),
sprintf("DIST: %d %s",ac_to_apt[0] * dist_conv[2][dist_unit],dist_unit_short_name[dist_unit]), sprintf("DIST: %d %s",ac_to_apt[0] * dist_conv[2][dist_unit],dist_unit_short_name[dist_unit]),
sprintf("BRG: %d° RWY: %02d",ac_to_apt[1], int(rwy.heading) / 10), sprintf("BRG: %d° RWY: %02d",ac_to_apt[1], int(rwy.heading) / 10),
@ -60,9 +51,9 @@ var screenAirportMain = {
else else
display([ display([
"", "",
"", " ! ERROR !",
"NO AIRPORT FOUND", "NO AIRPORT",
"", " FOUND",
"" ""
]); ]);
} }
@ -87,14 +78,15 @@ var screenAirportInfos = {
}, },
lines : func { lines : func {
me.rwylist = []; me.rwylist = [];
foreach (var r; keys(apt.runways)) foreach (var r; keys(screenAirportMain.apt.runways))
append(me.rwylist, [r, apt.runways[r].length, apt.runways[r].width]); append(me.rwylist, [r, screenAirportMain.apt.runways[r].length,
line[0].setValue(sprintf("%s", apt.name)); #TODO check length to truncate if too long screenAirportMain.apt.runways[r].width]);
line[0].setValue(sprintf("%s", screenAirportMain.apt.name)); #TODO check length to truncate if too long
rwyindex = me.page * 4; rwyindex = me.page * 4;
for (var l = 1; l < 5; l += 1) { for (var l = 1; l < 5; l += 1) {
rwyindex += 1; rwyindex += 1;
if (rwyindex < size(me.rwylist)) if (rwyindex < size(me.rwylist))
line[l].setValue(sprintf("R:%s L:%dm W:%dm", line[l].setValue(sprintf("%s [%dm / %dm]",
me.rwylist[rwyindex][0], me.rwylist[rwyindex][0],
me.rwylist[rwyindex][1], me.rwylist[rwyindex][1],
me.rwylist[rwyindex][2])); me.rwylist[rwyindex][2]));
@ -112,9 +104,9 @@ var screenSearchAirport = {
escape : func { escape : func {
}, },
start : func { start : func {
var searched = airportinfo(arg[0]); screenAirportMain.oaci = arg[0];
if (searched != nil) { var found = screenAirportMain.search();
screenAirportMain.apt = searched; if (found != 0) {
screenAirportMain.searched = 1; screenAirportMain.searched = 1;
return 1; return 1;
} }
@ -122,7 +114,7 @@ var screenSearchAirport = {
return 0; return 0;
}, },
lines : func { lines : func {
EditMode(4, "AIRPORT CODE", "SEARCH"); EditMode(4, "AIRPORT CODE", "SEARCH", 2, 0);
} }
}; };

View file

@ -87,7 +87,7 @@ var screenPositionMain = { # screens for POSITION mode
enter : func { enter : func {
var ac = geo.aircraft_position(); var ac = geo.aircraft_position();
me.coord = [ac.lat(), ac.lon(), ac.alt()]; me.coord = [ac.lat(), ac.lon(), ac.alt()];
EditMode(6, "EDIT WAYPOINT ID", "SAVE"); EditMode(6, "EDIT WAYPOINT ID", "SAVE", mode, page);
}, },
escape : func { escape : func {
}, },
@ -197,7 +197,9 @@ var screenNavigationMain = {
gps_wp.getNode("wp[1]/longitude-deg",1).setValue(next.getNode("longitude-deg",1).getValue()); gps_wp.getNode("wp[1]/longitude-deg",1).setValue(next.getNode("longitude-deg",1).getValue());
gps_wp.getNode("wp[1]/latitude-deg",1).setValue(next.getNode("latitude-deg",1).getValue()); gps_wp.getNode("wp[1]/latitude-deg",1).setValue(next.getNode("latitude-deg",1).getValue());
gps_wp.getNode("wp[1]/altitude-ft",1).setValue(next.getNode("altitude-ft",1).getValue()); gps_wp.getNode("wp[1]/altitude-ft",1).setValue(next.getNode("altitude-ft",1).getValue());
gps_wp.getNode("wp[1]/waypoint-type",1).setValue(next.getNode("waypoint-type",1).getValue());
gps_wp.getNode("wp[1]/ID",1).setValue(next.getNode("ID",1).getValue()); gps_wp.getNode("wp[1]/ID",1).setValue(next.getNode("ID",1).getValue());
} }
else { else {
page = 0; #screenTaskSelect page = 0; #screenTaskSelect
@ -221,7 +223,7 @@ var screenNavigationMain = {
if (mode != 4) save_route(); if (mode != 4) save_route();
}, },
lines : func { lines : func {
me.waypoint = gps_wp.getNode("wp[1]",1); me.waypoint = gps_wp.getNode("wp[1]");
crs_deviation = gps_wp.getNode("leg-course-deviation-deg").getValue(); crs_deviation = gps_wp.getNode("leg-course-deviation-deg").getValue();
if (crs_deviation > 5) if (crs_deviation > 5)
me.graph = "[- - - - - ^ > > > > >]"; me.graph = "[- - - - - ^ > > > > >]";
@ -234,8 +236,8 @@ var screenNavigationMain = {
} }
display ([ display ([
sprintf("ID: %s [%s]", sprintf("ID: %s [%s]",
me.waypoint.getNode("ID",1).getValue() != nil ? me.waypoint.getNode("ID",1).getValue() : "WP NOT NAMED!", me.waypoint.getNode("ID",1).getValue() != nil ? me.waypoint.getNode("ID",1).getValue() : "-----",
me.waypoint.getNode("type",1).getValue() != nil ? me.waypoint.getNode("type").getValue() : "---"), me.waypoint.getNode("waypoint-type",1).getValue() != nil ? me.waypoint.getNode("waypoint-type").getValue() : "---"),
sprintf("BRG: %d° DST: %d %s", sprintf("BRG: %d° DST: %d %s",
me.waypoint.getNode("bearing-mag-deg",1).getValue(), me.waypoint.getNode("bearing-mag-deg",1).getValue(),
me.waypoint.getNode("distance-nm",1).getValue() * dist_conv[0][dist_unit], me.waypoint.getNode("distance-nm",1).getValue() * dist_conv[0][dist_unit],
@ -266,11 +268,13 @@ var screenEdit = {
map: [], map: [],
pointer: 0, pointer: 0,
value: 0, value: 0,
init: func (length, title, start_command, set = 0) { init: func (length, title, start_command, backmode, backpage, set = 0) {
for (var i = 0; i < length; i += 1) append(me.map, "-"); for (var i = 0; i < length; i += 1) append(me.map, "-");
me.edit_title = title; me.edit_title = title;
me.start_command = start_command; me.start_command = start_command;
me.carset = set != 0 ? me.numeric : me.alphanum; me.carset = set != 0 ? me.numeric : me.alphanum;
me.previous_mode = backmode;
me.previous_page = backpage;
left_knob(0); # force display left_knob(0); # force display
}, },
right : func { right : func {

View file

@ -27,7 +27,8 @@ var screenTaskSelect = {
gps_wp.getNode("wp[1]/latitude-deg",1).setValue(gps_data.getNode("route/Waypoint/latitude-deg",1).getValue()); gps_wp.getNode("wp[1]/latitude-deg",1).setValue(gps_data.getNode("route/Waypoint/latitude-deg",1).getValue());
gps_wp.getNode("wp[1]/longitude-deg",1).setValue(gps_data.getNode("route/Waypoint/longitude-deg",1).getValue()); gps_wp.getNode("wp[1]/longitude-deg",1).setValue(gps_data.getNode("route/Waypoint/longitude-deg",1).getValue());
gps_wp.getNode("wp[1]/altitude-ft",1).setValue(gps_data.getNode("route/Waypoint/altitude-ft",1).getValue()); gps_wp.getNode("wp[1]/altitude-ft",1).setValue(gps_data.getNode("route/Waypoint/altitude-ft",1).getValue());
gps_wp.getNode("wp[1]/ID").setValue(gps_data.getNode("route/Waypoint/ID",1).getValue()); gps_wp.getNode("wp[1]/waypoint-type",1).setValue(gps_data.getNode("route/Waypoint/waypoint-type",1).getValue());
gps_wp.getNode("wp[1]/ID",1).setValue(gps_data.getNode("route/Waypoint/ID",1).getValue());
waypointindex = 0; waypointindex = 0;
me.loaded = 1; me.loaded = 1;

View file

@ -16,7 +16,7 @@ var spd_unit_short_name = ["kt", "km/h"];
var spd_unit = 0; var spd_unit = 0;
var dist_unit = 0; var dist_unit = 0;
var alt_unit = 0; var alt_unit = 0;
var apt = nil; #var apt = nil;
var startpos = nil; var startpos = nil;
var waypointindex = 0; var waypointindex = 0;
var thresold_alert = [120, 60, 30, 15]; var thresold_alert = [120, 60, 30, 15];
@ -79,7 +79,7 @@ var start_button = func() {
var left_knob = func(dir) { var left_knob = func(dir) {
isOn == 1 or return; isOn == 1 or return;
page = cycle(size(page_list[mode]), page, dir); page = cycle(size(page_list[mode]), page, dir);
if (displayed_screen != 0 and blocked == 0) displayed_screen = page_list[mode][page]; if (blocked == 0) displayed_screen = page_list[mode][page];
refresh_display(); refresh_display();
} }
@ -134,7 +134,7 @@ var cycle = func (entries_nbr, actual_entrie, dir) {
var refresh_display = func() { var refresh_display = func() {
screen[displayed_screen].lines(); screen[displayed_screen].lines();
if (isOn and 0 < displayed_screen < 5 ) settimer(func { refresh_display() }, freq, 1); if (isOn and 0 < displayed_screen < 5 ) settimer(func { refresh_display(); }, freq, 1);
} }
var seconds_to_string = func (time) { var seconds_to_string = func (time) {
@ -238,12 +238,12 @@ var add_bookmark = func (ID, name, type, coord) {
save_bookmarks(); save_bookmarks();
} }
var EditMode = func (length, start_command, start_func, numcar = 0) { var EditMode = func (length, start_command, start_func, backmode, backpage, numcar = 0) {
screenEdit.previous_mode = mode; #screenEdit.previous_mode = backmode;
screenEdit.previous_page = page; #screenEdit.previous_page = backpage;
mode = 5; #ID edition mode = 5; #ID edition
page = 0; page = 0;
screenEdit.init(length, start_command, start_func, numcar = 0); screenEdit.init(length, start_command, start_func, backmode, backpage, numcar = 0);
} }
### initialisation stuff ################################################### ### initialisation stuff ###################################################