skip custom hardware ids
This commit is contained in:
1 parent
62f30f9285
commit
a54ef74ff5
3 files changed
+29
-31
No files matched your search
@@ -1,4 +1,3 @@
|
||||
|
||||
function logEncoder(knobName, config)
|
||||
print(knobName)
|
||||
print("default hw id A: " .. arduino .. config.pinA)
|
||||
@@ -12,34 +11,17 @@ 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
|
||||
-- Run the four encoders through the assignment function
|
||||
for knobName, config in pairs(knobs) do
|
||||
logEncoder(knobName, config)
|
||||
encoder(knobName, config)
|
||||
logEncoder(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
|
||||
Reference in new issue
Block a user