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: nil,
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 {
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
right : func {
},
enter : func { #add to route
add_waypoint(me.apt.id, me.apt.name, "APT",
@ -27,6 +21,8 @@ var screenAirportMain = {
me.apt_coord.alt()*alt_conv[1][0]]);
},
escape : func {
me.searched = 0;
me.oaci = nil;
},
start : func { #add bookmark, enter turnpoint mode
add_bookmark(me.apt.id, me.apt.name, "APT",
@ -36,21 +32,16 @@ var screenAirportMain = {
screenTurnpointSelect.start();
},
lines : func {
if (me.apt == nil) {
me.apt = airportinfo();
print("youpi ", me.count);
me.searched = 0;
}
if (me.apt != nil) {
glide_slope_tunnel.complement_runways(me.apt);
if (me.search() == 1) { #FIXME: THE SEARCH SHOULD BE DONE ONLY ONE TIME,
# BUT IT SEEMS TO BE EXECUTED 3 TIMES/SEC
# I DON'T KNOW YET WHY... :/
var rwy = glide_slope_tunnel.best_runway(me.apt);
me.pos = geo.Coord.new(geo.aircraft_position());
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 ete = ac_to_apt[0] / getprop("instrumentation/gps/indicated-ground-speed-kt") * 3600 * 1852;
print ("me.searched: ",me.searched);
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("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),
@ -60,9 +51,9 @@ var screenAirportMain = {
else
display([
"",
"",
"NO AIRPORT FOUND",
"",
" ! ERROR !",
"NO AIRPORT",
" FOUND",
""
]);
}
@ -87,14 +78,15 @@ var screenAirportInfos = {
},
lines : func {
me.rwylist = [];
foreach (var r; keys(apt.runways))
append(me.rwylist, [r, apt.runways[r].length, apt.runways[r].width]);
line[0].setValue(sprintf("%s", apt.name)); #TODO check length to truncate if too long
foreach (var r; keys(screenAirportMain.apt.runways))
append(me.rwylist, [r, screenAirportMain.apt.runways[r].length,
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;
for (var l = 1; l < 5; l += 1) {
rwyindex += 1;
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][1],
me.rwylist[rwyindex][2]));
@ -112,9 +104,9 @@ var screenSearchAirport = {
escape : func {
},
start : func {
var searched = airportinfo(arg[0]);
if (searched != nil) {
screenAirportMain.apt = searched;
screenAirportMain.oaci = arg[0];
var found = screenAirportMain.search();
if (found != 0) {
screenAirportMain.searched = 1;
return 1;
}
@ -122,7 +114,7 @@ var screenSearchAirport = {
return 0;
},
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 {
var ac = geo.aircraft_position();
me.coord = [ac.lat(), ac.lon(), ac.alt()];
EditMode(6, "EDIT WAYPOINT ID", "SAVE");
EditMode(6, "EDIT WAYPOINT ID", "SAVE", mode, page);
},
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]/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]/waypoint-type",1).setValue(next.getNode("waypoint-type",1).getValue());
gps_wp.getNode("wp[1]/ID",1).setValue(next.getNode("ID",1).getValue());
}
else {
page = 0; #screenTaskSelect
@ -221,7 +223,7 @@ var screenNavigationMain = {
if (mode != 4) save_route();
},
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();
if (crs_deviation > 5)
me.graph = "[- - - - - ^ > > > > >]";
@ -234,8 +236,8 @@ var screenNavigationMain = {
}
display ([
sprintf("ID: %s [%s]",
me.waypoint.getNode("ID",1).getValue() != nil ? me.waypoint.getNode("ID",1).getValue() : "WP NOT NAMED!",
me.waypoint.getNode("type",1).getValue() != nil ? me.waypoint.getNode("type").getValue() : "---"),
me.waypoint.getNode("ID",1).getValue() != nil ? me.waypoint.getNode("ID",1).getValue() : "-----",
me.waypoint.getNode("waypoint-type",1).getValue() != nil ? me.waypoint.getNode("waypoint-type").getValue() : "---"),
sprintf("BRG: %d° DST: %d %s",
me.waypoint.getNode("bearing-mag-deg",1).getValue(),
me.waypoint.getNode("distance-nm",1).getValue() * dist_conv[0][dist_unit],
@ -266,11 +268,13 @@ var screenEdit = {
map: [],
pointer: 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, "-");
me.edit_title = title;
me.start_command = start_command;
me.carset = set != 0 ? me.numeric : me.alphanum;
me.previous_mode = backmode;
me.previous_page = backpage;
left_knob(0); # force display
},
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]/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]/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;
me.loaded = 1;

View file

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