3.1 BGScript Scripting Language _________________________________________________________ 7
3.2 BGScript vs. BGAPI ________________________________________________________________ 8
4 BGScript Syntax _______________________________________________________________________ 9
4.1 Comments _______________________________________________________________________ 9
4.2 Variables and Values _______________________________________________________________ 9
4.2.1 Values ____________________________________________________________________ 9
4.2.2 Variables __________________________________________________________________ 9
4.2.3 Global Variables ___________________________________________________________ 11
4.2.4 Constant Values ___________________________________________________________ 11
4.2.5 Buffers ___________________________________________________________________ 11
4.2.6 Strings ___________________________________________________________________ 12
4.2.7 Constant Strings ___________________________________________________________ 12
4.3 Expressions _____________________________________________________________________ 14
4.4 Commands ______________________________________________________________________ 15
4.4.1 event <event_name> (< event_parameters >) ____________________________________ 15
4.4.2 if <expression> then [else] end if _______________________________________________ 15
4.4.3 while <expression> end while _________________________________________________ 16
4.4.4 call <command name>(<command parameters>..)[(response parameters)] _____________ 16
4.4.5 let <variable> = <expression> _________________________________________________ 16
4.4.6 return ____________________________________________________________________ 17
4.4.7 sfloat( mantissa , exponent) __________________________________________________ 17
4.4.8 float( mantissa , exponent) ___________________________________________________ 18
4.4.9 memcpy(destination, source , length ) __________________________________________ 18
4.4.10 memcmp( buffer1 , buffer2 , length ) ___________________________________________ 18
4.4.11 memset( buffer , value , length) _______________________________________________ 19
4.5 Procedures ______________________________________________________________________ 20
4.6 Using multiple script files ___________________________________________________________ 21
4.6.1 import ___________________________________________________________________ 21
4.6.2 export ___________________________________________________________________ 21
5 BGScript Limitations ___________________________________________________________________ 23
5.1 32-bit resolution __________________________________________________________________ 23
5.2 Declaration required before use ______________________________________________________ 23
5.3 Reading internal temperature meter disabled IO interrupts _________________________________ 23
5.4 Writing data to an endpoint, which is not read ___________________________________________ 23
5.5 No interrupts on Port 2 _____________________________________________________________ 23
5.6 Performance _____________________________________________________________________ 23
5.7 RAM ___________________________________________________________________________ 23
5.8 Flash ___________________________________________________________________________ 24
5.9 Stack ___________________________________________________________________________ 24
5.9.1 Interface drivers ____________________________________________________________ 24
5.10 Debugging _____________________________________________________________________ 24
6 Example BGscripts ____________________________________________________________________ 25
6.1 Basics __________________________________________________________________________ 25
6.1.1 Catching system start-up _____________________________________________________ 25
6.1.2 Catching Bluetooth connection event ___________________________________________ 26
6.1.3 Catching Bluetooth disconnection event _________________________________________ 27
6.2 Hardware interfaces _______________________________________________________________ 28
6.2.1