added "set accelerometer range"

This commit is contained in:
Peli de Halleux
2016-03-16 14:56:50 -07:00
parent 1be364a364
commit ac1b811942
3 changed files with 43 additions and 1 deletions

View File

@ -289,6 +289,12 @@ namespace ks.rt.micro_bit {
default: return Math.sqrt(acc[0] * acc[0] + acc[1] * acc[1] + acc[2] * acc[2]);
}
}
export function setAccelerometerRange(range : number) {
let b = board();
b.accelerometerRange = Math.max(1, Math.min(8, range));
b.updateView();
}
export function lightLevel(): number {
let b = board();

View File

@ -167,6 +167,7 @@ namespace ks.rt.micro_bit {
// sensors
usesAcceleration = false;
acceleration = [0, 0, -1023];
accelerometerRange = 2;
usesHeading = false;
heading = 90;