Original Author Paul Laughton, 2011
Page 146
De Re BASIC!
Value
Flag(s) Set
Meaning
Acquire causes wakeup Turn screen on when wakelock is acquired.
On after release
Reset screen timeout when wakelock is released.
3
Both
Other
Neither
Use the WakeLock only when you really need it. Acquiring a WakeLock increases power usage and
decreases battery life. The WakeLock is always released when the program stops running.
One of the common uses for WakeLock would be in a music player that needs to keep the music playing
after the system screen timeout interval. Implementing this requires that BASIC! be kept running. One
way to do this is to put BASIC! into an infinite loop:
Audio.load n,"B5b.mp3"
Audio.play n
WakeLock 1
Do
Pause 30000
Until 0
The screen will turn off when the system screen timeout expires but the music will continue to play.
WifiLock <code_nexp>
The WifiLock command allows your program to keep the WiFi connection awake when a time-out would
normally turn it off. The <code_nexp> may be one of four values. Values 1 through 3 acquire a WifiLock,
changing the way WiFi behaves when the screen turns off. Code value 4 releases the WifiLock and
restores the normal timeout behavior.
Code:
WiFiLock Type
WiFi Operation When Screen is Off
Scan Only
WiFi kept active, but only operation is initiating scan
and reporting scan results
Full
WiFi behaves normally
Full High-
Performance
WiFi operates at high performance with minimum
packet loss and low latency*
4
No WiFiLock
WiFi turns off (may be settable on some devices)
*Full Hi-Perf mode is not available on all Android devices. Devices running Android 3.0.x
or earlier, and devices without the necessary hardware, will run in Full mode instead.
Use WifiLock only when you really need it. Acquiring a WifiLock increases power usage and decreases
battery life. The WifiLock is always released when the program stops running.