-
Notifications
You must be signed in to change notification settings - Fork 2
_TIMER
TIMER <0-3>, <timeout in milliseconds> [REPEAT] GOSUB <line number>
TIMER <0-3> STOP
It's often useful to run bit of your program either at a particular time in the future, or repeatedly every so many miliseconds. This can be done using TIMERS. The BlueBasic parser currently supports 4 timers <0-3>. Each timer can be created to run a specific section of the Basic program after a given number of milliseconds has elapsed. A timer may choose to keep repeating (e.g. execute every 5 seconds) or just run once (e.g. execute after 5 seconds and then stop).
10 TIMER 1, 2000 REPEAT GOSUB 1020
...
1020 PRINT "Hello"
1030 RETURN
The above example sets up timer 1. Every 2000 milliseconds, repeatedly, it will run the subroutine at line 1020. This line simply prints "Hello" and then finishes. The timer can be stopped by executing:
TIMER 1 STOP
FOR
IF
GOSUB
DIM
LIST
MEM -
NEW
RUN
END
GOTO
REM
PRINT
REBOOT
RETURN
AUTORUN
CONFIG -
ABS
LEN !
RND
+
-
*
/
%
&
|
^
>
>=
<
<=
=
==
!=
<<
>>
//
TIMER
MILLIS -
DELAY
PINMODE
RISING -
FALLING -
INTERRUPT -
ATTACH -
DETACH -
SERIAL
SPI
ANALOG
I2C
WIRE
TIMEOUT -
WAIT -
PULSE -
BATTERY
GATT
WRITENORSP -
NOTIFY -
INDICATE -
GATT ONREAD -
GATT ONWRITE -
GATT ONCONNECT
GATT ONDISCOVER -
ADVERT
SCAN
ACTIVE -
DUPLICATES -
BTPOKE
BTPEEK