make airmanager instrument
This commit is contained in:
1 parent
9b2c46c776
commit
8aa3f2599d
8 files changed
+236
-387
No files matched your search
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><pluginstrument><aircraft>Generic</aircraft><type>GNS430 Hardware</type><uuid>3e534a19-1714-4150-b1ec-4f760390ceec</uuid><author>Christopher Costa Hardt</author><description></description><compatibleFSX>false</compatibleFSX><compatibleP3D>false</compatibleP3D><compatibleXPL>false</compatibleXPL><compatibleFS2>false</compatibleFS2><compatibleFS2020>true</compatibleFS2020><version>1</version><configVersion>1</configVersion><pluginInterfaceVersion>100</pluginInterfaceVersion><prefWidth>0</prefWidth><prefHeight>0</prefHeight><source>PERSONAL</source><platforms><platform>WINDOWS</platform><platform>LINUX</platform><platform>RASPBERRY_PI</platform><platform>ANDROID</platform><platform>MAC</platform></platforms><tiers><tier>HOME_USE_STANDARD</tier></tiers></pluginstrument>
|
||||
@@ -0,0 +1,44 @@
|
||||
-- How to add Buttons:
|
||||
-- https://siminnovations.com/wiki/index.php?title=Hw_button_add
|
||||
-- hw_button_add(hw_id, pressed_callback, released_callback)
|
||||
function log(buttonName, config)
|
||||
print(buttonName)
|
||||
print("default hw id: " .. arduino .. config.pin)
|
||||
print("event: " .. config.event)
|
||||
print("- - - - - - - - - - -")
|
||||
end
|
||||
|
||||
-- add button with one event (press)
|
||||
function assign(buttonName, config)
|
||||
local defaultHardwareId = arduino .. config.pin
|
||||
hw_id = user_prop_add_hardware_id("Button " .. tostring(buttonName), defaultHardwareId, tostring(buttonName))
|
||||
hw_button_add(tostring(hw_id), function()
|
||||
event(config.event)
|
||||
end)
|
||||
end
|
||||
|
||||
-- add button with two events (press/release)
|
||||
function assignClr(buttonName, config)
|
||||
local defaultHardwareId = arduino .. config.pin
|
||||
hw_id = user_prop_add_hardware_id("Button " .. tostring(buttonName), defaultHardwareId, tostring(buttonName))
|
||||
|
||||
hw_button_add(tostring(hw_id), function()
|
||||
timer_clear = timer_start(2000, function()
|
||||
event(config.event2)
|
||||
end)
|
||||
end, function()
|
||||
timer_stop(timer_clear)
|
||||
event(config.event)
|
||||
end)
|
||||
end
|
||||
|
||||
function setupButtons()
|
||||
for buttonName, config in pairs(buttons) do
|
||||
log(buttonName, config)
|
||||
if (buttonName == "CLR") then
|
||||
assignClr(buttonName, config)
|
||||
else
|
||||
assign(buttonName, config)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
function logEncoder(knobName, config)
|
||||
print(knobName)
|
||||
print("default hw id A: " .. arduino .. config.pinA)
|
||||
print("default hw id B: " .. arduino .. config.pinB)
|
||||
print("event: " .. config.event)
|
||||
print("- - - - - - - - - - -")
|
||||
end
|
||||
|
||||
-- assign a string to a integer of encoder direction (0,1)
|
||||
function leftRight(direction)
|
||||
return direction == 1 and "_Right" or "_Left"
|
||||
end
|
||||
|
||||
local default_acceleration = 3
|
||||
local default_debounce = 4
|
||||
|
||||
-- How to add Rotary Encoders:
|
||||
-- https://siminnovations.com/wiki/index.php?title=Rotary_encoder_connection_tutorial
|
||||
-- https://siminnovations.com/wiki/index.php?title=Hw_dial_add
|
||||
-- hw_dial_add(hw_id_a, hw_id_b, callback)
|
||||
function encoder(knobName, config)
|
||||
|
||||
type = "TYPE_1_DETENT_PER_PULSE"
|
||||
|
||||
local defaultPinA = arduino .. config.pinA
|
||||
local hw_id_pin_a = user_prop_add_hardware_id("Encoder " .. knobName .. " pin A", defaultPinA, knobName .. " pin A")
|
||||
|
||||
local defaultPinB = arduino .. config.pinB
|
||||
local hw_id_pin_b = user_prop_add_hardware_id("Encoder " .. knobName .. " pin B", defaultPinB, knobName .. " pin B")
|
||||
|
||||
hw_dial_add(
|
||||
tostring(hw_id_pin_a),
|
||||
tostring(hw_id_pin_b), type, default_acceleration, default_debounce, function(direction)
|
||||
event(config.event .. leftRight(direction))
|
||||
end)
|
||||
end
|
||||
|
||||
function setupEncoders()
|
||||
-- Run the four encoders through the assignment function
|
||||
for knobName, config in pairs(knobs) do
|
||||
logEncoder(knobName, config)
|
||||
encoder(knobName, config)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,107 @@
|
||||
arduino = "ARDUINO_MEGA2560_B_"
|
||||
|
||||
function getHardwareId(pin)
|
||||
arduinoChannel = "B" -- <== Change Arduino Channel here (assigned in air manager setup -> Home -> Flash)
|
||||
return "ARDUINO_MEGA2560_" .. arduinoChannel .. "_" .. pin
|
||||
end
|
||||
|
||||
function event(id)
|
||||
print(id)
|
||||
fs2020_event(id)
|
||||
end
|
||||
|
||||
buttons = {
|
||||
-- Left side Buttons
|
||||
COMSWAP = {
|
||||
pin = "D2",
|
||||
event = "H:AS430_COMSWAP_Push"
|
||||
},
|
||||
NAVSWAP = {
|
||||
pin = "D3",
|
||||
event = "H:AS430_NAVSWAP_Push"
|
||||
},
|
||||
-- Lower Buttons
|
||||
CDI = {
|
||||
pin = "D4",
|
||||
event = "TOGGLE_GPS_DRIVES_NAV1"
|
||||
},
|
||||
OBS = {
|
||||
pin = "D5",
|
||||
event = "H:AS430_OBS_Push"
|
||||
},
|
||||
MSG = {
|
||||
pin = "D6",
|
||||
event = "H:AS430_MSG_Push"
|
||||
},
|
||||
FPL = {
|
||||
pin = "D7",
|
||||
event = "H:AS430_FPL_Push"
|
||||
},
|
||||
PROC = {
|
||||
pin = "D8",
|
||||
event = "H:AS430_PROC_Push"
|
||||
},
|
||||
-- Right Side Buttons
|
||||
DCT = {
|
||||
pin = "D9",
|
||||
event = "H:AS430_DirectTo_Push"
|
||||
},
|
||||
MENU = {
|
||||
pin = "D10",
|
||||
event = "H:AS430_MENU_Push"
|
||||
},
|
||||
CLR = {
|
||||
pin = "D11",
|
||||
event = "H:AS430_CLR_Push",
|
||||
event2 = "H:AS430_CLR_Push_Long"
|
||||
},
|
||||
ENT = {
|
||||
pin = "D12",
|
||||
event = "H:AS430_ENT_Push"
|
||||
},
|
||||
-- Zoom Buttons
|
||||
ZOOM = {
|
||||
pin = "D13",
|
||||
event = "H:AS430_RNG_Zoom"
|
||||
},
|
||||
DEZOOM = {
|
||||
pin = "D14",
|
||||
event = "H:AS430_RNG_Dezoom"
|
||||
},
|
||||
-- Knob Push Buttons
|
||||
CVPUSH = {
|
||||
pin = "D15",
|
||||
event = "H:AS430_LeftSmallKnob_Push"
|
||||
},
|
||||
CRSRPUSH = {
|
||||
pin = "D16",
|
||||
event = "H:AS430_RightSmallKnob_Push"
|
||||
}
|
||||
}
|
||||
|
||||
knobs = {
|
||||
CVBig = {
|
||||
pinA = "D17",
|
||||
pinB = "D18",
|
||||
event = "H:AS430_LeftLargeKnob"
|
||||
},
|
||||
CVSmall = {
|
||||
pinA = "D19",
|
||||
pinB = "D20",
|
||||
event = "H:AS430_LeftSmallKnob"
|
||||
},
|
||||
CRSRBig = {
|
||||
pinA = "D21",
|
||||
pinB = "D22",
|
||||
event = "H:AS430_RightLargeKnob"
|
||||
},
|
||||
CRSRSmall = {
|
||||
pinA = "D23",
|
||||
pinB = "D24",
|
||||
event = "H:AS430_RightSmallKnob"
|
||||
}
|
||||
}
|
||||
|
||||
-- run the setup
|
||||
setupButtons()
|
||||
setupEncoders()
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 121 KiB |
Reference in new issue
Block a user