Page 1 of 1

button state example

Posted: Thu Aug 24, 2017 3:59 pm
by TXBDan
Hi all,

Does anyone have a script example using the button state? I assume it'd have to be polled. Is any debouncing required?

I'd like to use the button to do something useful like switch dashboard screens or maybe toggle shiftlight/lap timing modes.

Thanks

Posted: Fri Aug 25, 2017 1:11 pm
by gizmodo
The example script has this implemented.

function sxOnBut(b)
--called if the button state changes
println('button: ' ..b)
end

This is where it is called:
function sxChkCan()
id,ext,data=rxCAN(sxCan,0)
if id==sxCanId then sxInit() end
if id==sxCanId+60 and sxOnBut~=nil then sxOnBut(data[1]) end
end