Parameter btn represents A or B button, accepted values are a, b.
2. Light Sensor
sensor.getLight()
Returns a value 0~4095.
3. Temperature Sensor
sensor.getTemp()
Returns a degree in Celsius, FutureBoard can measure temperatures from -40 to 80 degrees.
Sample Program for 1~3
from future import *
from time import sleep
screen.fill((0, 0, 0))
while True:
if sensor.btnValue('a'):
screen.text(str("Light: ")+str(sensor.getLight()),5,10,1,(0, 119, 255))
sleep(0.5)
if sensor.btnValue('b'):
screen.text(str("Temp: ")+str(sensor.getTemp()),5,30,1,(0, 119, 255))
sleep(0.5)
4. Accelerometer
sensor.accX()
sensor.accY()
sensor.accZ()
Returns the accelerometer value of the 3 axis with G as the unit.
5. Tilt Angles
sensor.roll()
sensor.pitch()
Returns the roll and pitch angle of the FutureBoard.
Sample Program for 4~5
#The screen displays the readings of the accelerometer.
from future import *
from time import sleep
screen.sync = 0
while True:
screen.fill((0, 0, 0))
screen.text(str("X: ")+str(sensor.accX()),5,10,1,(0, 119, 255))
screen.text(str("Y: ")+str(sensor.accY()),5,25,1,(0, 119, 255))
screen.text(str("Z: ")+str(sensor.accZ()),5,40,1,(0, 119, 255))
screen.text(str("Roll: ")+str(sensor.roll()),5,55,1,(0, 119, 255))
screen.text(str("Pitch: ")+str(sensor.pitch()),5,70,1,(0, 119, 255))
screen.refresh()
sleep(0.2)
6. Gesture Detection
sensor.gesture(gesture)
8 kinds of gesture can be detected by the FutureBoard.
‘shake’
‘freefall’
‘tilt_up’
‘tilt_down’
‘tilt_left’
‘tilt_right’
‘face_up’
‘face_down’
7. Gesture Event Trigger
sensor.gesTrig[ges] = fn
sensor.startSchedule()
Sample Program for 6~7
# Futureboard plays a melody on shake.
# Futureboard shows the status of gestures face up and face down.
from future import *
from time import sleep
def onGesture_shake():
buzzer.melody(JUMP_UP)
sensor.gesTrig['shake']=onGesture_shake
sensor.startSchedule()
screen.sync = 0
while True:
screen.fill((0, 0, 0))
screen.text(str("Face Up: ")+str(sensor.gesture('face_up')),5,10,1,(0, 119, 255))
screen.text(str("Face Down: ")+str(sensor.gesture('face_down')),5,25,1,(0, 119, 255))
screen.refresh()
sleep(0.2)
8. Compass Calibration
calibrateCompass()
Magnetometer and compass requires calibration before using.