2014-05-13 10:34:28 +00:00
|
|
|
|
2014-05-12 19:15:12 +00:00
|
|
|
|
|
|
|
var GPSmap196 = {
|
2014-05-16 19:16:07 +00:00
|
|
|
|
|
|
|
id:0,
|
|
|
|
|
|
|
|
############
|
|
|
|
new: func(placement='gps196.screen') {
|
2014-05-13 10:34:28 +00:00
|
|
|
print("Load Garmin GPSmap196 canvas");
|
2014-05-12 19:15:12 +00:00
|
|
|
m = { parents : [GPSmap196] };
|
2014-05-16 19:16:07 +00:00
|
|
|
m.buttons = {};
|
|
|
|
m.pages = {panel:nil, map:nil, route:nil, position:nil};
|
2014-05-14 17:58:40 +00:00
|
|
|
m.gmt = props.globals.getNode("sim/time/gmt");
|
2014-05-16 19:16:07 +00:00
|
|
|
m.node = props.globals.initNode("/instrumentation/gps196",GPSmap196.id+=1);
|
|
|
|
|
|
|
|
m.selectedPage = m.node.initNode("selected-page", 0, "INT");
|
|
|
|
|
|
|
|
var buttons = [ 'rocker-up', 'button-in', 'button-dto', 'button-out',
|
|
|
|
'button-menu', 'button-nrst', 'button-page', 'button-quit',
|
|
|
|
'button-down', 'rocker-left', 'button-power', 'rocker-right',
|
|
|
|
'button-enter' ];
|
|
|
|
|
|
|
|
# to access, use: m.buttons['rocker-up']
|
|
|
|
foreach(var btn; buttons)
|
|
|
|
m.buttons[btn] = m.node.initNode("inputs/"~btn, 0, "BOOL");
|
|
|
|
|
2014-05-14 17:58:40 +00:00
|
|
|
m.gpsmap196Screen = canvas.new({
|
|
|
|
"name": "GPSmap196-screen",
|
|
|
|
"size": [512, 512],
|
|
|
|
"view": [320, 240],
|
|
|
|
"mipmapping": 1
|
|
|
|
});
|
2014-05-16 19:16:07 +00:00
|
|
|
|
|
|
|
m.gpsmap196Screen.addPlacement({"node": placement});
|
|
|
|
m.root = m.gpsmap196Screen.createGroup();
|
|
|
|
|
|
|
|
m.timers = [];
|
|
|
|
m.initMap();
|
|
|
|
m.initPanel();
|
|
|
|
if(0){
|
|
|
|
m.initRoute();
|
|
|
|
m.initPosition();
|
|
|
|
}
|
|
|
|
append( m.timers, var update_timer=maketimer(0.1, func m.update()) );
|
|
|
|
update_timer.start();
|
2014-05-13 10:34:28 +00:00
|
|
|
|
2014-05-12 19:15:12 +00:00
|
|
|
return m;
|
|
|
|
},
|
2014-05-16 19:16:07 +00:00
|
|
|
|
|
|
|
############
|
|
|
|
del: func {
|
|
|
|
foreach(var t; me.timers) {
|
|
|
|
t.stop();
|
|
|
|
t=nil;
|
|
|
|
}
|
|
|
|
print("GPSmap196: cleanup finished");
|
|
|
|
},
|
|
|
|
|
|
|
|
############
|
|
|
|
initRoute: func() {
|
|
|
|
canvas.parsesvg(var data = me.root.createChild("group", "page-route"), 'Aircraft/Instruments-3d/GPSmap196/pages/page-route.svg');
|
|
|
|
me.pages.route = data;
|
|
|
|
data.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
############
|
|
|
|
initPosition: func() {
|
|
|
|
canvas.parsesvg(var data = me.root.createChild("group", "page-position"), 'Aircraft/Instruments-3d/GPSmap196/pages/page-position.svg');
|
|
|
|
me.pages.position = data;
|
|
|
|
data.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
############
|
|
|
|
initPanel: func() {
|
|
|
|
canvas.parsesvg(var data = me.root.createChild("group", "page-panel"), 'Aircraft/Instruments-3d/GPSmap196/pages/page-panel.svg');
|
|
|
|
me.pages.panel = data;
|
|
|
|
data.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
############
|
|
|
|
initMap:func() {
|
|
|
|
me.pages.map = me.root.createChild("map").hide();
|
|
|
|
me.pages.map.setController("Aircraft position");
|
|
|
|
me.pages.map.setRange(10);
|
|
|
|
|
|
|
|
me.pages.map.setTranslation(
|
|
|
|
me.gpsmap196Screen.get("view[0]")/2,
|
|
|
|
me.gpsmap196Screen.get("view[1]")/2
|
|
|
|
);
|
|
|
|
var style = {scale_factor:0.3, line_width:2, animation_test:0, color_default:[1,0,0], color_tuned:[0,1,1]};
|
|
|
|
var r = func(name,vis=1,zindex=nil) return caller(0)[0];
|
|
|
|
foreach(var type; [r('DME',0),r('APT'), ] )
|
|
|
|
me.pages.map.addLayer(factory: canvas.SymbolLayer, type_arg: type.name, visible: type.vis, priority: type.zindex,style:style);
|
|
|
|
|
|
|
|
canvas.parsesvg( var symbol=me.pages.map.createChild("group","airplane-symbol"), 'Nasal/canvas/map/boeingAirplane.svg');
|
|
|
|
symbol.setScale( 0.25 );
|
|
|
|
},
|
|
|
|
|
|
|
|
############
|
2014-05-13 10:34:28 +00:00
|
|
|
update: func() {
|
2014-05-16 19:16:07 +00:00
|
|
|
|
|
|
|
if(me.buttons['button-page'].getBoolValue()){
|
|
|
|
me.selectedPage.setIntValue( me.selectedPage.getValue() + 1 );
|
|
|
|
if(me.selectedPage.getValue() > 3) me.selectedPage.setIntValue(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
me.pages.map.hide();
|
|
|
|
me.pages.panel.hide();
|
|
|
|
if(0){
|
|
|
|
me.pages.route.hide();
|
|
|
|
me.pages.position.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(me.selectedPage.getValue() == 0)
|
|
|
|
me.pages.map.show();
|
|
|
|
elsif(me.selectedPage.getValue() == 1)
|
|
|
|
me.pages.panel.show();
|
|
|
|
# elsif(me.selectedPage.getValue() == 2)
|
|
|
|
# me.pages.route.show();
|
|
|
|
# elsif(me.selectedPage.getValue() == 3)
|
|
|
|
# me.pages.position.show();
|
|
|
|
|
2014-05-12 19:15:12 +00:00
|
|
|
}
|
2014-05-16 19:16:07 +00:00
|
|
|
|
2014-05-12 19:15:12 +00:00
|
|
|
};
|
|
|
|
|
2014-05-13 10:34:28 +00:00
|
|
|
setlistener("sim/signals/fdm-initialized", func() {
|
2014-05-14 17:58:40 +00:00
|
|
|
gpsmap196Canvas = GPSmap196.new();
|
2014-05-12 19:15:12 +00:00
|
|
|
});
|
|
|
|
|