HMI - Long Press Button
Here's an example showing how to provide support for a long press button. In this example, the button has been hidden so the user isn't aware of it. The button has to be held for 3 seconds before the new screen will appear.
;create a "m"anual "h"idden "r"epeating button
;manual means it won't beep when pressed
;repeating 5 times/second so we can time a long press interval
#HMI ButtonEvent2( x:0px, y:0px, w:140px, h:45px, m:"mh1r5", ev:subBtnLongPress )
subBtnLongPress:
GoSub UIsubGetButton ;get extra info about the press, ref ui_utils.spt
Push ;copy the press/release state
GoIfXeq 1,_BtnStartTimer ;jump if this is the first press
GoIfXne 3,Return ;if the button is NOT being held, abort
LoopIfTiming 300,Return ;otherwise return if the long press time hasn't expired
KBeep ;long press time has expired, BEEP!
Goto subShowOtherScreen ;go display the screen
_BtnStartTimer
MarkTime ;start the timer
Return
Take care with the MarkTime is this is using the timer that belongs to the button task. The button task doesn't use it, but it is shared amongst all buttons.
