Is there a way to have a button press auto repeat if the user keeps the button pressed?
I have tried with a timer inside the button_click (or down) sub, but it seems that the sub does not exit until the button is released. And it does not re-enter even if the button remains pressed.
Sub rf_inc_click
If old_repeat <> repeat Then
If selected_rf <= 95 Then
selected_rf = selected_rf + 5
rf_power_value.text = selected_rf & "%"
Play(11)
draw_rf_power
End If
old_repeat = repeat
End If
End Sub
Sub inc_dec_repeat_Tick
repeat = repeat + 1 ' increment repeat timer every 500 ms
End Sub
That does not work because the sub never returns until the button is released. It does not loop on itself, using log I was able to determine that it only goes through the loop 1 time. I placed a log("done") just before the button_click (or down) end sub and found that it returns to the sender but does not come back if the button remains pressed.
I have also tried to have this:
Sub rf_inc_down
pressed = True
Do While pressed = True
If old_repeat <> repeat Then
If selected_rf <= 95 Then
selected_rf = selected_rf + 5
rf_power_value.text = selected_rf & "%"
Play(11)
draw_rf_power
End If
old_repeat = repeat
End If
Loop
End Sub
Sub inc_dec_repeat_Tick
repeat = repeat + 1 ' increment repeat timer every 500 ms
End Sub
Sub rf_inc_up
pressed = False
End Sub
but it seems that even when I release the button, the up sub does not get called. The system gets stuck in the down sub and force closes.
How can I implement an auto repeat of the button_down every 500 ms?
I have tried with a timer inside the button_click (or down) sub, but it seems that the sub does not exit until the button is released. And it does not re-enter even if the button remains pressed.
Sub rf_inc_click
If old_repeat <> repeat Then
If selected_rf <= 95 Then
selected_rf = selected_rf + 5
rf_power_value.text = selected_rf & "%"
Play(11)
draw_rf_power
End If
old_repeat = repeat
End If
End Sub
Sub inc_dec_repeat_Tick
repeat = repeat + 1 ' increment repeat timer every 500 ms
End Sub
That does not work because the sub never returns until the button is released. It does not loop on itself, using log I was able to determine that it only goes through the loop 1 time. I placed a log("done") just before the button_click (or down) end sub and found that it returns to the sender but does not come back if the button remains pressed.
I have also tried to have this:
Sub rf_inc_down
pressed = True
Do While pressed = True
If old_repeat <> repeat Then
If selected_rf <= 95 Then
selected_rf = selected_rf + 5
rf_power_value.text = selected_rf & "%"
Play(11)
draw_rf_power
End If
old_repeat = repeat
End If
Loop
End Sub
Sub inc_dec_repeat_Tick
repeat = repeat + 1 ' increment repeat timer every 500 ms
End Sub
Sub rf_inc_up
pressed = False
End Sub
but it seems that even when I release the button, the up sub does not get called. The system gets stuck in the down sub and force closes.
How can I implement an auto repeat of the button_down every 500 ms?