1
0
Fork 0

- new instruments : GPS zkv500 by Zakharov

This commit is contained in:
helijah 2008-06-28 19:38:32 +00:00
parent 04f75c9399
commit 7e81bb94ff
10 changed files with 6733 additions and 0 deletions

View file

@ -0,0 +1,127 @@
var screenAirportMain = {
pos: nil,
apt_coord: nil,
right : func {
},
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(apt.id);
gps_wp.getNode("wp[1]/name",1).setValue(apt.name);
mode = 2;
page = 1;
displayed_screen = 1; #screenNavigationMain
},
enter : func {
me.apt_to_waypoint();
},
escape : func {
},
start : func {
me.apt_to_waypoint();
},
lines : func (searched = nil) {
if (searched != nil)
apt = searched;
else
apt = airportinfo();
glide_slope_tunnel.complement_runways(apt);
var rwy = glide_slope_tunnel.best_runway(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;
display([
sprintf("%s APT: %s", searched != nil ? "SEARCHED" : "NEAREST", apt.id),
sprintf("ELEV: %d %s", 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),
sprintf("ETE: %s",seconds_to_string(ete))
]);
}
};
var screenAirportInfos = {
page : 0,
rwylist: [],
right : func {
me.page = 0;
displayed_screen = 4;# screenAirportMain
},
left : func {
np = int(size(me.rwylist) / 4) + (math.mod(size(me.rwylist),4) ? 1 : 0);
me.page = cycle(np, me.page, arg[0]);
},
enter : func {
},
escape : func {
},
start : func {
},
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
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",
me.rwylist[rwyindex][0],
me.rwylist[rwyindex][1],
me.rwylist[rwyindex][2]));
else
line[l].setValue("");
}
}
};
var screenSearchAirport = {
oaci : ["-","-","-","-"],
pointer: 0,
value: 0,
searched: nil,
right : func {
me.value = cycle(size(screenEdit.alphanum), me.value, arg[0]);
me.oaci[me.pointer] = screenEdit.alphanum[me.value];
},
enter : func {
if (me.pointer < 3) {
me.pointer += 1;
me.value = 0;
}
else
me.searched = airportinfo(me.oaci[0]~me.oaci[1]~me.oaci[2]~me.oaci[3]);
},
escape : func {
me.oaci = ["-","-","-","-"];
me.pointer = 0;
me.searched = nil;
},
start : func {
},
lines : func {
if (me.searched == nil)
display([
"SEARCH AIRPORT:",
sprintf("%s%s%s%s",me.oaci[0],me.oaci[1],me.oaci[2],me.oaci[3]),
"",
"",
""
]);
else {
screenAirportMain.lines(me.searched);
me.right();
}
}
};

View file

@ -0,0 +1,292 @@
var screenModeAndSettings = { # screen for changing the GPS mode and settings
help : 0,
mode_: 0,
quit_help : func {
me.help = 0;
me.lines();
},
right : func {
if (page == 1)
alt_unit = cycle(2, alt_unit, arg[0]);
elsif (page == 2)
dist_unit = cycle(2, dist_unit, arg[0]);
elsif (page == 3)
spd_unit = cycle(2, spd_unit, arg[0]);
elsif (page == 4)
thresold_alert_index = cycle(size(thresold_alert), thresold_alert_index, arg[0]);
elsif (page == 5)
thresold_next_waypoint = cycle(10, thresold_next_waypoint, arg[0]);
},
changemode : func {
if (page == 0) me.mode_ = cycle(4, me.mode_, arg[0]);
},
enter : func {
if (!me.help) {
display ([
"HERE THERE WILL SEAT",
"A SIMPLE EXPLANATION",
"TEXT ABOUT USE OF GPS",
"PRESS ANY OF THE",
"THREE BUTTONS"
]);
me.help = 1;
}
else me.quit_help();
},
escape : func {
if (me.help) me.quit_help();
else me.dispatch();
},
start : func {
if (me.help) me.quit_help();
else {
mode = me.mode_ + 1;
page = 0;
displayed_screen = page_list[mode][page];
}
},
lines : func {
if (page == 0) {
if (me.mode_ == 0) mode_str = "POSITION";
elsif (me.mode_ == 1) mode_str = "AIRPORT";
elsif (me.mode_ == 2) mode_str = "TURNPOINT";
else mode_str = "TASK";
l0 = " -- GPS STATUS : --";
l1 = sprintf("MODE: %s", mode_str);
}
else {
if (page < 4)
l0 = " -- SET UNITS --";
else
l0 = "- SET TIME THRESOLDS -";
if (page == 1)
l1 = sprintf("ALT: %s", alt_unit_full_name[alt_unit]);
elsif (page == 2)
l1 = sprintf("DIST: %s", dist_unit_full_name[dist_unit]);
elsif (page == 3)
l1 = sprintf("SPEED: %s", spd_unit_full_name[spd_unit]);
elsif (page == 4)
l1 = sprintf("ALERT: %d s", thresold_alert[thresold_alert_index]);
elsif (page == 5)
l1 = sprintf("NEXT WAYPOINT: %d s", thresold_next_waypoint);
}
display ([
l0,
l1,
"",
"ENTER -> HELP",
"START -> ENTER MODE"
]);
}
};
var screenPositionMain = { # screens for POSITION mode
right : func {
},
enter : func {
GPSPositionEdit();
},
escape : func {
},
start : func {
},
lines : func {
display ([
sprintf("LAT: %s",
props.globals.getNode("/position/latitude-string",1).getValue()),
sprintf("LON: %s",
props.globals.getNode("/position/longitude-string",1).getValue()),
sprintf("ALT: %d %s",
gps_data.getNode("indicated-altitude-ft").getValue() * alt_conv[0][alt_unit],
alt_unit_short_name[alt_unit]),
sprintf("HDG: %d°",
gps_data.getNode("indicated-track-true-deg").getValue()),
sprintf("SPD: %d %s",
gps_data.getNode("indicated-ground-speed-kt").getValue() * dist_conv[0][spd_unit],
spd_unit_short_name[spd_unit])
]);
}
};
var screenOdometers = {
begin_time : 0,
elapsed : 0,
odotime : func {
me.elapsed = props.globals.getNode("/sim/time/elapsed-sec",1).getValue() - me.begin_time;
seconds_to_string(me.elapsed);
},
right: func {
},
enter: func {
},
escape: func {
startpos = geo.Coord.new(geo.aircraft_position());
me.begin_time = props.globals.getNode("/sim/time/elapsed-sec",1).getValue();
gps_data.getNode("odometer",1).setDoubleValue(0.0);
},
start: func {
},
lines: func {
display ([
sprintf("ODO: %d %s",
gps_data.getNode("odometer",1).getValue() * dist_conv[0][dist_unit],
dist_unit_short_name[dist_unit]),
sprintf("TRIP: %d %s",
gps_data.getNode("trip-odometer",1).getValue() * dist_conv[0][dist_unit],
dist_unit_short_name[dist_unit]),
sprintf("TIME: %s",
me.odotime()),
sprintf("AVG HDG: %03d*",
startpos.course_to(geo.aircraft_position())),
sprintf("AVG SPD: %d %s",
gps_data.getNode("odometer",1).getValue() / me.elapsed * 3600 * dist_conv[0][spd_unit],
spd_unit_short_name[spd_unit])
]);
}
};
var screenWindInfos = {
right: func {
},
enter: func {
},
escape: func {
},
start: func {
},
lines: func {
if (gps_data.getNode("indicated-ground-speed-kt").getValue() > 10)
display ([
"WIND INFOS",
sprintf("SPEED: %d %s",
props.globals.getNode("/environment/wind-speed-kt",1).getValue() * dist_conv[0][dist_unit],
spd_unit_short_name[spd_unit]),
sprintf("FROM: %d*",
props.globals.getNode("/environment/wind-from-heading-deg",1).getValue()),
"",
""
]);
else
display ([
"WIND INFOS",
sprintf("SPEED: --- %s", spd_unit_short_name[spd_unit]),
"FROM: ---*",
"",
""
]);
}
};
var screenNavigationMain = {
nextWaypoint : func {
waypointindex += 1;
next = gps_data.getNode("route/Waypoint[" ~ waypointindex ~ "]/",1);
if (next != nil) {
gps_wp.getNode("wp/longitude-deg",1).setValue(gps_wp.getNode("wp[1]/longitude-deg",1).getValue());
gps_wp.getNode("wp/latitude-deg",1).setValue(gps_wp.getNode("wp[1]/latitude-deg",1).getValue());
gps_wp.getNode("wp/altitude-ft",1).setValue(gps_wp.getNode("wp[1]/altitude-ft",1).getValue());
gps_wp.getNode("wp/ID",1).setValue(gps_wp.getNode("wp[1]/ID",1).getValue());
#gps_wp.getNode("wp/name",1).setValue(gps_wp.getNode("wp[1]/name",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]/altitude-ft",1).setValue(next.getNode("altitude-ft",1).getValue());
gps_wp.getNode("wp[1]/ID",1).setValue(next.getNode("ID",1).getValue());
#gps_wp.getNode("wp[1]/name",1).setValue(next.getNode("name",1).getValue());
}
else {
page = 0; #screenTaskSelect
refresh_display();
}
},
right : func {
},
enter : func {
if (mode == 3) me.nextWaypoint();
},
escape : func {
},
start : func {
},
lines : func {
me.waypoint = gps_wp.getNode("wp[1]",1);
crs_deviation = gps_wp.getNode("leg-course-deviation-deg").getValue();
if (crs_deviation > 5)
me.graph = "[- - - - - ^ > > > > >]";
elsif (crs_deviation < -5)
me.graph = "[< < < < < ^ - - - - -]";
else {
me.graph = "[+ + + + + ^ + + + + +]";
cursor = int((crs_deviation * 2) + 11);
me.graph = substr(me.graph,0, cursor) ~ "|" ~ substr(me.graph, cursor+1, size(me.graph));
}
display ([
sprintf("ID: %s",
me.waypoint.getNode("ID",1).getValue() != nil ? me.waypoint.getNode("ID",1).getValue() : "WP NOT NAMED!"),
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],
dist_unit_short_name[dist_unit]),
sprintf("XCRS: %d* (%.1f %s)",
gps_wp.getNode("leg-course-deviation-deg").getValue(),
gps_wp.getNode("leg-course-error-nm").getValue() * dist_conv[0][dist_unit],
dist_unit_short_name[dist_unit]),
sprintf("TTW: %s",
me.waypoint.getNode("TTW").getValue()),
me.graph
]);
}
};
var screenEdit = {
previous_mode: 0,
previous_page: 0,
alphanum: ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
"Q","R","S","T","U","V","W","X","Y","Z",
"0","1","2","3","4","5","6","7","8","9"],
numeric: ["0","1","2","3","4","5","6","7","8","9"],
IDmap: ["-","-","-","-","-","-"],
pointer: 0,
value: 0,
coord: [0,0,0],
right : func {
me.value = cycle(size(me.alphanum), me.value, arg[0]);
me.IDmap[me.pointer] = me.alphanum[me.value];
},
enter : func {
me.pointer = cycle(size(me.IDmap), me.pointer, 1);
me.value = 0;
},
escape : func {
#save_bookmarks();
me.IDmap = ["-","-","-","-","-","-"];
me.pointer = 0;
me.value = 0;
mode = me.previous_mode;
page = me.previous_page;
left_knob(0);
},
start : func {
var ID = "";
for (var i = 0; i < size(me.IDmap); i += 1)
ID ~= me.IDmap[i] != "-" ? me.IDmap[i] : "";
var bookmark = gps_data.getNode("bookmarks/bookmark["~screenTurnpointSelect.n~"]/",1);
screenTurnpointSelect.n += 1;
bookmark.getNode("ID",1).setValue(ID);
bookmark.getNode("latitude-deg",1).setDoubleValue(me.coord[0]);
bookmark.getNode("longitude-deg",1).setDoubleValue(me.coord[1]);
bookmark.getNode("altitude-ft",1).setDoubleValue(me.coord[2]*alt_conv[1][0]);
bookmark.getNode("infos",1).setValue("no infos");
me.escape();
},
lines : func {
display([
"ENTER POINT ID",
sprintf("%s%s%s%s%s%s",me.IDmap[0],me.IDmap[1],me.IDmap[2],me.IDmap[3],me.IDmap[4],me.IDmap[5]),
"",
"ESC -> AVOID",
"START -> SAVE"
]);
}
};

View file

@ -0,0 +1,111 @@
var screenTaskSelect = {
page : 0,
pointer: 0,
n: 0,
loaded: 0,
right : func {
me.loaded = 0;
blocked = 1;
var t = browse(size(routes), me.pointer, me.page, arg[0]);
me.pointer = t[0];
me.page = t[1];
},
load : func {
screenWaypointsList.n = 0;
gps_data.getNode("route",1).removeChildren("Waypoint");
fgcommand("loadxml", props.Node.new({
"filename": getprop("/sim/fg-home") ~ "/Routes/" ~ routes[(me.page * 5) + me.pointer],
"targetnode": "/instrumentation/gps/route"
}));
foreach (var c; gps_data.getNode("route").getChildren("Waypoint"))
screenWaypointsList.n += 1;
gps_wp.getNode("wp/latitude-deg",1).setValue(gps_data.getNode("indicated-latitude-deg",1).getValue());
gps_wp.getNode("wp/longitude-deg",1).setValue(gps_data.getNode("indicated-longitude-deg",1).getValue());
gps_wp.getNode("wp/altitude-ft",1).setValue(gps_data.getNode("indicated-altitude-ft",1).getValue());
gps_wp.getNode("wp/ID").setValue("startpos");
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());
waypointindex = 0;
me.loaded = 1;
},
enter : func {
},
escape : func {
},
start : func {
me.n > 0 or return;
me.load();
blocked = 0;
left_knob(1);
},
lines : func {
if (me.loaded != 1) blocked = 1;
if (me.n == 0) {
display([
"",
"",
"NO ROUTE FOUND",
"",
""
]);
}
else for (var l = 0; l < 5; l += 1) {
if ((me.page * 5 + l) < me.n) {
name = routes[me.page * 5 + l];
if (substr(name, -4) == ".xml") name = substr(name, 0, size(name) - 4);
name = string.uc(name);
line[l].setValue(sprintf("%s %s",me.pointer == l ? ">" : " ", name));
}
else
line[l].setValue("");
}
}
};
var screenWaypointsList = {
n: 0,
page: 0,
pointer: 0,
right : func {
var t = browse(me.n, me.pointer, me.page, arg[0]);
me.pointer = t[0];
me.page = t[1];
},
enter : func {
},
escape : func {
},
start : func {
},
lines : func {
for (var l = 0; l < 5; l += 1) {
if ((me.page * 5 + l) < me.n) {
name = gps_data.getNode("route/Waypoint["~((me.page*5) + l)~"]/ID").getValue();
line[l].setValue(sprintf("%s %s",me.pointer == l ? ">" : " ", name));
}
else
line[l].setValue("");
}
}
};
var screenWaypointInfos = {
right : func {
},
enter : func {
},
escape : func {
},
start : func {
},
lines : func {
display(NOT_YET_IMPLEMENTED);
}
};

View file

@ -0,0 +1,68 @@
var screenTurnpointSelect = {
n: 0,
page: 0,
pointer: 0,
loaded: 0,
right : func {
me.loaded = 0;
blocked = 1;
var t = browse(me.n, me.pointer, me.page, arg[0]);
me.pointer = t[0];
me.page = t[1];
},
enter : func {
},
escape : func {
},
start : func {
me.n > 0 or return;
gps_wp.getNode("wp/latitude-deg",1).setValue(gps_data.getNode("indicated-latitude-deg",1).getValue());
gps_wp.getNode("wp/longitude-deg",1).setValue(gps_data.getNode("indicated-longitude-deg",1).getValue());
gps_wp.getNode("wp/altitude-ft",1).setValue(gps_data.getNode("indicated-altitude-ft",1).getValue());
gps_wp.getNode("wp/ID").setValue("startpos");
var bookmark = gps_data.getNode("bookmarks/bookmark["~((me.page*5)+me.pointer)~"]/");
gps_wp.getNode("wp[1]/latitude-deg",1).setValue(bookmark.getNode("latitude-deg",1).getValue());
gps_wp.getNode("wp[1]/longitude-deg",1).setValue(bookmark.getNode("longitude-deg",1).getValue());
gps_wp.getNode("wp[1]/altitude-ft",1).setValue(bookmark.getNode("altitude-ft",1).getValue());
gps_wp.getNode("wp[1]/ID").setValue(bookmark.getNode("ID",1).getValue());
blocked = 0;
page = 1;
mode = 3;
left_knob(0);
},
lines : func {
if (me.loaded != 1) blocked = 1;
if (me.n > 0)
for (var l = 0; l < 5; l += 1) {
if ((me.page * 5 + l) < me.n) {
name = gps_data.getNode("bookmarks/bookmark["~((me.page * 5) + l)~"]/ID").getValue();
line[l].setValue(sprintf("%s %s",me.pointer == l ? ">" : " ", name));
}
else
line[l].setValue("");
}
else
display([
" ",
" ",
" NO BOOKMARKS",
" ",
" "
]);
}
};
var screenTurnpointInfos = {
right : func {
},
enter : func {
},
escape : func {
},
start : func {
},
lines : func {
display(NOT_YET_IMPLEMENTED);
}
};

View file

@ -0,0 +1,235 @@
<?xml version="1.0"?>
<PropertyList>
<name>LCD GPS display</name>
<w-base>1024</w-base>
<h-base>1024</h-base>
<layers>
<!-- Line 0, top of screen -->
<layer>
<name>line 0</name>
<condition>
<equals>
<property>/instrumentation/gps/serviceable</property>
<value>1</value>
</equals>
</condition>
<type>text</type>
<font>lcd</font>
<point-size>6</point-size>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
<chunks>
<chunk>
<type>text-value</type>
<property>/instrumentation/zkv500/line[0]</property>
<format>%s</format>
</chunk>
</chunks>
</layer>
<!-- Line 1 -->
<layer>
<name>line 1</name>
<condition>
<equals>
<property>/instrumentation/gps/serviceable</property>
<value>1</value>
</equals>
</condition>
<type>text</type>
<font>lcd</font>
<point-size>6</point-size>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
<chunks>
<chunk>
<type>text-value</type>
<property>/instrumentation/zkv500/line[1]</property>
<format>%s</format>
</chunk>
</chunks>
<transformations>
<transformation>
<type>y-shift</type>
<offset>-13</offset>
</transformation>
</transformations>
</layer>
<!-- line 2 -->
<layer>
<name>line 2</name>
<condition>
<equals>
<property>/instrumentation/gps/serviceable</property>
<value>1</value>
</equals>
</condition>
<type>text</type>
<font>lcd</font>
<point-size>6</point-size>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
<chunks>
<chunk>
<type>text-value</type>
<property>/instrumentation/zkv500/line[2]</property>
<format>%s</format>
</chunk>
</chunks>
<transformations>
<transformation>
<type>y-shift</type>
<offset>-26</offset>
</transformation>
</transformations>
</layer>
<!-- line 3 -->
<layer>
<name>line 3</name>
<condition>
<equals>
<property>/instrumentation/gps/serviceable</property>
<value>1</value>
</equals>
</condition>
<type>text</type>
<font>lcd</font>
<point-size>6</point-size>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
<chunks>
<chunk>
<type>text-value</type>
<property>/instrumentation/zkv500/line[3]</property>
<format>%s</format>
</chunk>
</chunks>
<transformations>
<transformation>
<type>y-shift</type>
<offset>-39</offset>
</transformation>
</transformations>
</layer>
<!-- line 4 -->
<layer>
<name>line 4</name>
<condition>
<equals>
<property>/instrumentation/gps/serviceable</property>
<value>1</value>
</equals>
</condition>
<type>text</type>
<font>lcd</font>
<point-size>6</point-size>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
<chunks>
<chunk>
<type>text-value</type>
<property>/instrumentation/zkv500/line[4]</property>
<format>%s</format>
</chunk>
</chunks>
<transformations>
<transformation>
<type>y-shift</type>
<offset>-52</offset>
</transformation>
</transformations>
</layer>
<!-- line 5->
<layer>
<name>line 5</name>
<condition>
<equals>
<property>/instrumentation/gps/serviceable</property>
<value>1</value>
</equals>
</condition>
<type>text</type>
<font>lcd</font>
<point-size>6</point-size>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
<chunks>
<chunk>
<type>text-value</type>
<property>/instrumentation/zkv500/line[5]</property>
<format>%s</format>
</chunk>
</chunks>
<transformations>
<transformation>
<type>x-shift</type>
<offset>0</offset>
</transformation>
<transformation>
<type>y-shift</type>
<offset>-60</offset>
</transformation>
</transformations>
</layer>
<!-line 6, screen bottom->
<layer>
<name>line 6</name>
<condition>
<equals>
<property>/instrumentation/gps/serviceable</property>
<value>1</value>
</equals>
</condition>
<type>text</type>
<font>lcd</font>
<point-size>6</point-size>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
<chunks>
<chunk>
<type>text-value</type>
<property>/instrumentation/zkv500/line[6]</property>
<format>%s</format>
</chunk>
</chunks>
<transformations>
<transformation>
<type>x-shift</type>
<offset>0</offset>
</transformation>
<transformation>
<type>y-shift</type>
<offset>0</offset>
</transformation>
</transformations>
</layer> -->
</layers>
</PropertyList>

View file

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<PropertyList>
<name>GPS panel</name>
<background>Aircraft/Instruments-3d/zkv500/transparent-bg.rgb</background>
<w>256</w>
<h>256</h>
<instruments>
<instrument include="ZKV500-display.xml">
<name>LCD GPS Display</name>
<x>0</x>
<y>0</y>
<w>1024</w>
<h>1024</h>
</instrument>
</instruments>
</PropertyList>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,253 @@
var mode = 0;
var displayed_screen = 0; #screenModeAndSettings
var page = 0;
var blocked = 0;
var isOn = 0;
var freq = 1;
var screen = [];
var line = [];
var routes = [];
var alt_unit_full_name = ["Feet", "Meters"];
var dist_unit_full_name = ["Nautic Miles", "Kilometers"];
var spd_unit_full_name = ["Knots", "KM/H"];
var alt_unit_short_name = ["ft", "m"];
var dist_unit_short_name = ["nm", "km"];
var spd_unit_short_name = ["kt", "km/h"];
var spd_unit = 0;
var dist_unit = 0;
var alt_unit = 0;
var apt = nil;
var startpos = nil;
var waypointindex = 0;
var thresold_alert = [120, 60, 30, 15];
var thresold_alert_index = 1;
var thresold_next_waypoint = 5;
NOT_YET_IMPLEMENTED = [
"",
" NOT",
" YET",
"IMPLEMENTED",
""
];
var page = 0;
var page_list = [
[0,0,0,0,0,0], #0 ModeAndSettings: 1 page for mode, 5 pages for settings
[1,2,3], #1 PositionMain, Odometers, WindInfos
[5,4,1,2,3,6,7], #2 AirportMain, NavigationMain, PositionMain, Odometers, WindInfos, AirportInfos, SearchAirport
[8,4,1,2,3,9], #3 TurnpointSelect, NavigationMain, PositionMain, Odometers, WindInfos, TurnpointInfos
[10,4,1,2,3,11,12], #4 TaskSelect, NavigationMain, PositionMain, Odometers, WindInfos, WaypointInfos, WaypointsList
[13] #5 Edit (special mode for editing waypoint, called from other modes)
];
#to ft m
var alt_conv = [[1.0000,0.3048], #from ft
[3.2808,1.0000]]; #from m
#to nm km m
var dist_conv = [[1.00000 ,1.852, 1852], #from nm
[0.53996 ,1.000, 1000], #from km
[0.00053996,0.001, 1.00]]; #from m
var gps_data = props.globals.getNode("/instrumentation/gps",1);
var gps_wp = gps_data.getNode("wp",1);
#### warps for buttons and knobs ########################################"
var right_knob = func(dir) {
isOn == 1 or return;
screen[displayed_screen].right(dir);
refresh_display();
}
var enter_button = func() {
isOn == 1 or return;
screen[displayed_screen].enter();
refresh_display();
}
var escape_button = func() {
isOn == 1 or return;
screen[displayed_screen].escape();
refresh_display();
}
var start_button = func() {
isOn == 1 or return;
screen[displayed_screen].start();
refresh_display();
}
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];
refresh_display();
}
var select_mode = func(dir) {
isOn == 1 or return;
blocked = 0;
if (displayed_screen != 0) {
displayed_screen = 0; #screenModeAndSettings
page = 0;
screen[displayed_screen].changemode(0);
}
else
screen[displayed_screen].changemode(dir);
refresh_display();
}
var switch_ON_OFF = func() {
if (isOn) {
isOn = 0;
for (var i = 0; i < 5; i += 1) line[i].setValue("");
}
else {
isOn = 1;
screenTaskSelect.n = list_routes();
screenTurnpointSelect.n = load_bookmarks();
refresh_display();
}
props.globals.getNode("/instrumentation/gps/serviceable",1).setBoolValue(isOn);
}
### useful funcs #########################################################
var display = func () {
for (var i = 0; i < 5; i += 1) line[i].setValue(arg[0][i]);
}
var browse = func (entries_nbr, index_pointer, index_page,dir) {
nl = entries_nbr - (index_page * 5) > 5 ? 5 : math.mod(entries_nbr - (index_page * 5), 5);
if (index_pointer + 1 == nl) {
np = int(entries_nbr / 5) + (math.mod(entries_nbr,5) ? 1 : 0);
index_page = cycle(np, index_page, dir);
}
index_pointer = cycle(nl, index_pointer, dir);
return [index_pointer, index_page];
}
var cycle = func (entries_nbr, actual_entrie, dir) {
entries_nbr -= 1;
if (dir == 1 and actual_entrie == entries_nbr) return 0;
elsif (dir == -1 and actual_entrie == 0) return entries_nbr;
else return actual_entrie + dir;
}
var refresh_display = func() {
screen[displayed_screen].lines();
if (isOn and 0 < displayed_screen < 5 ) settimer(func { refresh_display() }, freq, 1);
}
var seconds_to_string = func (time) {
var hh = int(time / 3600);
if (hh > 100) return "--:--:--";
var mm = int((time - (hh * 3600)) / 60);
var ss = int(time - (hh * 3600 + mm * 60));
return sprintf("%02d:%02d:%02d", hh, mm, ss);
}
### route management ######################################################
var list_routes = func {
routes = [];
var path = getprop("/sim/fg-home") ~ "/Routes";
var s = io.stat(path);
if (s != nil and io.isdir(s[2])) {
foreach (var file; directory(path))
if (file[0] != 46) append(routes, file);
# size(routes) != 0 or return;
# routes = sort(routes, func(a,b) {
# num(a[1]) == nil or num(b[1]) == nil ? cmp(a[1], b[1]) : a[1] - b[1];
# });
# print(size(routes));
# foreach (var r; routes) print (r ~ ":" ~ r[0]);
}
return size(routes);
}
var waypointAlert = func {
mode > 0 or return;
var ttw = gps_wp.getNode("wp[1]/TTW",1).getValue();
var ttw_secs = 9999;
if (string.isdigit(ttw[0]))
ttw_secs = num(substr(ttw,0,2))*3600 + num(substr(ttw,3,2))*60 + num(substr(ttw,6,2));
if (ttw_secs < thresold_alert[thresold_alert_index])
gps_data.getNode("waypoint-alert",1).setBoolValue(1);
else
gps_data.getNode("waypoint-alert",1).setBoolValue(0);
if (mode == 3 and ttw_secs < thresold_next_waypoint)
screenNavigationMain.nextWaypoint();
}
### turnpoints management ######################################################
var load_bookmarks = func {
var n = 0;
gps_data.getNode("bookmarks",1).removeChildren("bookmark");
var file = getprop("/sim/fg-home") ~ "/bookmarks.xml";
var s = io.stat(file);
if (s != nil) {
fgcommand("loadxml", props.Node.new({
"filename": file,
"targetnode": "/instrumentation/gps/bookmarks"
}));
foreach (var c ;props.globals.getNode("/instrumentation/gps/bookmarks").getChildren("bookmark")) n += 1;
}
return n;
}
var save_bookmarks = func {
var path = getprop("/sim/fg-home") ~ "/Export/bookmarks.xml";
var args = props.Node.new({ filename : path });
var export = args.getNode("/instrumentation/gps/bookmarks", 1);
foreach (var c; gps_data.getNode("bookmarks").getChildren("bookmark")) {
var b = export.getChild("bookmark",1);
b.getNode("ID", 1).setValue(c.getNode("ID").getValue());
b.getNode("latitude-deg", 1).setValue(c.getNode("latitude-deg").getValue());
b.getNode("longitude-deg", 1).setValue(c.getNode("longitude-deg").getValue());
b.getNode("altitude-ft", 1).setValue(c.getNode("altitude-ft").getValue());
b.getNode("infos", 1).setValue(c.getNode("infos").getValue());
}
fgcommand("savexml", args);
}
var GPSPositionEdit = func {
screenEdit.previous_mode = mode;
screenEdit.previous_page = page;
mode = 5; #ID edition
page = 0;
var ac = geo.aircraft_position();
screenEdit.coord = [ac.lat(), ac.lon(), ac.alt()];
left_knob(0);
}
### initialisation stuff ###################################################
var init = func() {
for (var i = 0; i < 5; i += 1) {
append(line, props.globals.getNode("/instrumentation/zkv500/line[" ~ i ~ "]", 1));
line[i].setValue("");
}
props.globals.getNode("/instrumentation/gps/serviceable",1).setBoolValue(0);
append(screen, zkv500.screenModeAndSettings); #0
append(screen, zkv500.screenPositionMain); #1
append(screen, zkv500.screenOdometers); #2
append(screen, zkv500.screenWindInfos); #3
append(screen, zkv500.screenNavigationMain); #4
append(screen, zkv500.screenAirportMain); #5
append(screen, zkv500.screenAirportInfos); #6
append(screen, zkv500.screenSearchAirport); #7
append(screen, zkv500.screenTurnpointSelect); #8
append(screen, zkv500.screenTurnpointInfos); #9
append(screen, zkv500.screenTaskSelect); #10
append(screen, zkv500.screenWaypointInfos); #11
append(screen, zkv500.screenWaypointsList); #12
append(screen, zkv500.screenEdit); #13
aircraft.light.new("/sim/model/gps/redled", [0.1, 0.1, 0.1, 0.7], "/instrumentation/gps/waypoint-alert");
aircraft.light.new("/sim/model/gps/greenled", [0.6, 0.3], "/instrumentation/gps/message-alert");
startpos = geo.Coord.new(geo.aircraft_position());
screenPositionMain.begin_time = props.globals.getNode("/sim/time/elapsed-sec",1).getValue();
setlistener("/instrumentation/gps/wp/wp[1]/TTW", waypointAlert, 0, 0);
#setlistener("/instrumentation/gps/wp/wp[1]/desired-course", obsMode, 0, 0);
print("GPS... initialized");
}
setlistener("/sim/signals/fdm-initialized",init);

View file

@ -0,0 +1,174 @@
<?xml version="1.0"?>
<PropertyList>
<path>ZKV500.ac</path>
<panel>
<path>Aircraft/Instruments-3d/zkv500/ZKV500-panel.xml</path>
<bottom-left>
<x-m>-0.002</x-m>
<y-m>-0.027</y-m>
<z-m>0.012</z-m>
</bottom-left>
<bottom-right>
<x-m>-0.002</x-m>
<y-m>0.06</y-m>
<z-m>0.012</z-m>
</bottom-right>
<top-left>
<x-m>-0.002</x-m>
<y-m>-0.027</y-m>
<z-m>0.15</z-m>
</top-left>
</panel>
<animation>
<type>select</type>
<condition>
<property>/sim/model/gps/redled/state</property>
</condition>
<object-name>LED.0_ON</object-name>
</animation>
<animation>
<type>select</type>
<condition>
<property>/sim/model/gps/greenled/state</property>
</condition>
<object-name>LED.1_ON</object-name>
</animation>
<animation>
<type>pick</type>
<object-name>knob.ONOFF</object-name>
<visible>true</visible>
<action>
<name>switch on and off</name>
<!-- this one will manage volume control soon too,
but for now keep it simple -->
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.switch_ON_OFF()</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>knob.LEFT</object-name>
<visible>true</visible>
<action>
<name>next menu</name>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.left_knob(1)</script>
</binding>
</action>
<action>
<name>previous menu</name>
<button>2</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.left_knob(-1)</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>knob.RIGHT</object-name>
<visible>true</visible>
<action>
<name>next item</name>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.right_knob(1)</script>
</binding>
</action>
<action>
<name>previous item</name>
<button>2</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.right_knob(-1)</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>knob.MODE</object-name>
<visible>true</visible>
<action>
<name>select next mode</name>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.select_mode(1)</script>
</binding>
</action>
<action>
<name>select previous mode</name>
<button>2</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.select_mode(-1)</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>button.ENTER</object-name>
<visible>true</visible>
<action>
<name>manage ENTER button (top left)</name>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.enter_button()</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>button.ESCAPE</object-name>
<visible>true</visible>
<action>
<name>manage ESCAPE button (top middle)</name>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.escape_button()</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>button.START</object-name>
<visible>true</visible>
<action>
<name>manage START button (top right)</name>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>zkv500.start_button()</script>
</binding>
</action>
</animation>
</PropertyList>

Binary file not shown.