skip custom hardware ids
This commit is contained in:
1 parent
62f30f9285
commit
a54ef74ff5
3 files changed
+27
-29
No files matched your search
@@ -10,19 +10,16 @@ end
|
|||||||
|
|
||||||
-- add button with one event (press)
|
-- add button with one event (press)
|
||||||
function assign(buttonName, config)
|
function assign(buttonName, config)
|
||||||
local defaultHardwareId = arduino .. config.pin
|
local buttonNameWithPin = config.name .. " (Default Pin: " .. config.pin .. ")"
|
||||||
hw_id = user_prop_add_hardware_id("Button " .. tostring(buttonName), defaultHardwareId, tostring(buttonName))
|
hw_button_add(buttonNameWithPin, function()
|
||||||
hw_button_add(tostring(hw_id), function()
|
|
||||||
event(config.event)
|
event(config.event)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add button with two events (press/release)
|
-- add button with two events (press/release)
|
||||||
function assignClr(buttonName, config)
|
function assignClr(buttonName, config)
|
||||||
local defaultHardwareId = arduino .. config.pin
|
local buttonNameWithPin = config.name .. " (Default Pin: " .. config.pin .. ")"
|
||||||
hw_id = user_prop_add_hardware_id("Button " .. tostring(buttonName), defaultHardwareId, tostring(buttonName))
|
hw_button_add(buttonNameWithPin, function()
|
||||||
|
|
||||||
hw_button_add(tostring(hw_id), function()
|
|
||||||
timer_clear = timer_start(2000, function()
|
timer_clear = timer_start(2000, function()
|
||||||
event(config.event2)
|
event(config.event2)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
function logEncoder(knobName, config)
|
function logEncoder(knobName, config)
|
||||||
print(knobName)
|
print(knobName)
|
||||||
print("default hw id A: " .. arduino .. config.pinA)
|
print("default hw id A: " .. arduino .. config.pinA)
|
||||||
@@ -12,34 +11,17 @@ function leftRight(direction)
|
|||||||
return direction == 1 and "_Right" or "_Left"
|
return direction == 1 and "_Right" or "_Left"
|
||||||
end
|
end
|
||||||
|
|
||||||
local default_acceleration = 3
|
|
||||||
local default_debounce = 4
|
|
||||||
|
|
||||||
-- How to add Rotary Encoders:
|
-- How to add Rotary Encoders:
|
||||||
-- https://siminnovations.com/wiki/index.php?title=Rotary_encoder_connection_tutorial
|
-- https://siminnovations.com/wiki/index.php?title=Rotary_encoder_connection_tutorial
|
||||||
-- https://siminnovations.com/wiki/index.php?title=Hw_dial_add
|
-- https://siminnovations.com/wiki/index.php?title=Hw_dial_add
|
||||||
-- hw_dial_add(hw_id_a, hw_id_b, callback)
|
-- 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()
|
function setupEncoders()
|
||||||
-- Run the four encoders through the assignment function
|
-- Run the four encoders through the assignment function
|
||||||
for knobName, config in pairs(knobs) do
|
for knobName, config in pairs(knobs) do
|
||||||
logEncoder(knobName, config)
|
logEncoder(knobName, config)
|
||||||
encoder(knobName, config)
|
local knobNameWithPin = config.name .. " (Default Pins: " .. config.pinA .. ", " .. config.pinB .. ")"
|
||||||
|
hw_dial_add(knobNameWithPin, function(direction)
|
||||||
|
event(config.event .. leftRight(direction))
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -13,67 +13,82 @@ end
|
|||||||
buttons = {
|
buttons = {
|
||||||
-- Left side Buttons
|
-- Left side Buttons
|
||||||
COMSWAP = {
|
COMSWAP = {
|
||||||
|
name = "COM FlipFlop",
|
||||||
pin = "D2",
|
pin = "D2",
|
||||||
event = "H:AS430_COMSWAP_Push"
|
event = "H:AS430_COMSWAP_Push"
|
||||||
},
|
},
|
||||||
NAVSWAP = {
|
NAVSWAP = {
|
||||||
|
name = "NAV FlipFlop",
|
||||||
pin = "D3",
|
pin = "D3",
|
||||||
event = "H:AS430_NAVSWAP_Push"
|
event = "H:AS430_NAVSWAP_Push"
|
||||||
},
|
},
|
||||||
-- Lower Buttons
|
-- Lower Buttons
|
||||||
CDI = {
|
CDI = {
|
||||||
|
name = "CDI",
|
||||||
pin = "D4",
|
pin = "D4",
|
||||||
event = "TOGGLE_GPS_DRIVES_NAV1"
|
event = "TOGGLE_GPS_DRIVES_NAV1"
|
||||||
},
|
},
|
||||||
OBS = {
|
OBS = {
|
||||||
|
name = "OBS",
|
||||||
pin = "D5",
|
pin = "D5",
|
||||||
event = "H:AS430_OBS_Push"
|
event = "H:AS430_OBS_Push"
|
||||||
},
|
},
|
||||||
MSG = {
|
MSG = {
|
||||||
|
name = "MSG",
|
||||||
pin = "D6",
|
pin = "D6",
|
||||||
event = "H:AS430_MSG_Push"
|
event = "H:AS430_MSG_Push"
|
||||||
},
|
},
|
||||||
FPL = {
|
FPL = {
|
||||||
|
name = "FPL",
|
||||||
pin = "D7",
|
pin = "D7",
|
||||||
event = "H:AS430_FPL_Push"
|
event = "H:AS430_FPL_Push"
|
||||||
},
|
},
|
||||||
PROC = {
|
PROC = {
|
||||||
|
name = "PROC",
|
||||||
pin = "D8",
|
pin = "D8",
|
||||||
event = "H:AS430_PROC_Push"
|
event = "H:AS430_PROC_Push"
|
||||||
},
|
},
|
||||||
-- Right Side Buttons
|
-- Right Side Buttons
|
||||||
DCT = {
|
DCT = {
|
||||||
|
name = "DCT",
|
||||||
pin = "D9",
|
pin = "D9",
|
||||||
event = "H:AS430_DirectTo_Push"
|
event = "H:AS430_DirectTo_Push"
|
||||||
},
|
},
|
||||||
MENU = {
|
MENU = {
|
||||||
|
name = "MENU",
|
||||||
pin = "D10",
|
pin = "D10",
|
||||||
event = "H:AS430_MENU_Push"
|
event = "H:AS430_MENU_Push"
|
||||||
},
|
},
|
||||||
CLR = {
|
CLR = {
|
||||||
|
name = "CLR",
|
||||||
pin = "D11",
|
pin = "D11",
|
||||||
event = "H:AS430_CLR_Push",
|
event = "H:AS430_CLR_Push",
|
||||||
event2 = "H:AS430_CLR_Push_Long"
|
event2 = "H:AS430_CLR_Push_Long"
|
||||||
},
|
},
|
||||||
ENT = {
|
ENT = {
|
||||||
|
name = "ENT",
|
||||||
pin = "D12",
|
pin = "D12",
|
||||||
event = "H:AS430_ENT_Push"
|
event = "H:AS430_ENT_Push"
|
||||||
},
|
},
|
||||||
-- Zoom Buttons
|
-- Zoom Buttons
|
||||||
ZOOM = {
|
ZOOM = {
|
||||||
|
name = "Range +",
|
||||||
pin = "D13",
|
pin = "D13",
|
||||||
event = "H:AS430_RNG_Zoom"
|
event = "H:AS430_RNG_Zoom"
|
||||||
},
|
},
|
||||||
DEZOOM = {
|
DEZOOM = {
|
||||||
|
name = "Range -",
|
||||||
pin = "D14",
|
pin = "D14",
|
||||||
event = "H:AS430_RNG_Dezoom"
|
event = "H:AS430_RNG_Dezoom"
|
||||||
},
|
},
|
||||||
-- Knob Push Buttons
|
-- Knob Push Buttons
|
||||||
CVPUSH = {
|
CVPUSH = {
|
||||||
|
name = "C/V Push",
|
||||||
pin = "D15",
|
pin = "D15",
|
||||||
event = "H:AS430_LeftSmallKnob_Push"
|
event = "H:AS430_LeftSmallKnob_Push"
|
||||||
},
|
},
|
||||||
CRSRPUSH = {
|
CRSRPUSH = {
|
||||||
|
name = "CRSR Push",
|
||||||
pin = "D16",
|
pin = "D16",
|
||||||
event = "H:AS430_RightSmallKnob_Push"
|
event = "H:AS430_RightSmallKnob_Push"
|
||||||
}
|
}
|
||||||
@@ -81,21 +96,25 @@ buttons = {
|
|||||||
|
|
||||||
knobs = {
|
knobs = {
|
||||||
CVBig = {
|
CVBig = {
|
||||||
|
name = "C/V Large Knob",
|
||||||
pinA = "D17",
|
pinA = "D17",
|
||||||
pinB = "D18",
|
pinB = "D18",
|
||||||
event = "H:AS430_LeftLargeKnob"
|
event = "H:AS430_LeftLargeKnob"
|
||||||
},
|
},
|
||||||
CVSmall = {
|
CVSmall = {
|
||||||
|
name = "C/V Small Knob",
|
||||||
pinA = "D19",
|
pinA = "D19",
|
||||||
pinB = "D20",
|
pinB = "D20",
|
||||||
event = "H:AS430_LeftSmallKnob"
|
event = "H:AS430_LeftSmallKnob"
|
||||||
},
|
},
|
||||||
CRSRBig = {
|
CRSRBig = {
|
||||||
|
name = "CRSR Large Knob",
|
||||||
pinA = "D21",
|
pinA = "D21",
|
||||||
pinB = "D22",
|
pinB = "D22",
|
||||||
event = "H:AS430_RightLargeKnob"
|
event = "H:AS430_RightLargeKnob"
|
||||||
},
|
},
|
||||||
CRSRSmall = {
|
CRSRSmall = {
|
||||||
|
name = "CRSR Small Knob",
|
||||||
pinA = "D23",
|
pinA = "D23",
|
||||||
pinB = "D24",
|
pinB = "D24",
|
||||||
event = "H:AS430_RightSmallKnob"
|
event = "H:AS430_RightSmallKnob"
|
||||||
|
|||||||
Reference in new issue
Block a user