make airmanager instrument

This commit is contained in:
Christopher Costa Hardt committed 2022-12-26 16:19:15 +01:00
1 parent 9b2c46c776
commit 8aa3f2599d
8 files changed
+236 -387

No files matched your search

+44
View File
@@ -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