added "set accelerometer range"
This commit is contained in:
parent
1be364a364
commit
ac1b811942
@ -35,6 +35,29 @@ enum TouchPins {
|
|||||||
P2,
|
P2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum AcceleratorRange {
|
||||||
|
/**
|
||||||
|
* The accelerator measures forces up to 1 gravity
|
||||||
|
*/
|
||||||
|
//% blockId="1g" enumval=1
|
||||||
|
OneG,
|
||||||
|
/**
|
||||||
|
* The accelerator measures forces up to 2 gravity
|
||||||
|
*/
|
||||||
|
//% blockId="2g" enumval=2
|
||||||
|
TwoG,
|
||||||
|
/**
|
||||||
|
* The accelerator measures forces up to 4 gravity
|
||||||
|
*/
|
||||||
|
//% blockId="4g" enumval=4
|
||||||
|
FourG,
|
||||||
|
/**
|
||||||
|
* The accelerator measures forces up to 8 gravity
|
||||||
|
*/
|
||||||
|
//% blockId="8g" enumval=8
|
||||||
|
EightG
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
enum BasicGesture
|
enum BasicGesture
|
||||||
{
|
{
|
||||||
@ -207,7 +230,7 @@ namespace input {
|
|||||||
* Gets the number of milliseconds elapsed since power on.
|
* Gets the number of milliseconds elapsed since power on.
|
||||||
*/
|
*/
|
||||||
//% help=functions/running-time shim=micro_bit::getCurrentTime weight=50
|
//% help=functions/running-time shim=micro_bit::getCurrentTime weight=50
|
||||||
//% blockId=device_get_running_time block="running time (ms)" blockGap=8 icon="\uf017"
|
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||||
export function runningTime(): number {
|
export function runningTime(): number {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -271,4 +294,16 @@ namespace input {
|
|||||||
export function onLogoDown(body: Action): void {
|
export function onLogoDown(body: Action): void {
|
||||||
onGesture(Gestures.LogoDown, body);
|
onGesture(Gestures.LogoDown, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the accelerometer sample range in gravities.
|
||||||
|
* @param range a value describe the maximum strengh of acceleration measured
|
||||||
|
*/
|
||||||
|
//% help=functions/set-accelerator-range
|
||||||
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||||
|
//% weight=5
|
||||||
|
//% shim=micro_bit::setAccelerometerRange
|
||||||
|
export function setAccelerometerRange(range : AcceleratorRange) : void {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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]);
|
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 {
|
export function lightLevel(): number {
|
||||||
let b = board();
|
let b = board();
|
||||||
|
@ -167,6 +167,7 @@ namespace ks.rt.micro_bit {
|
|||||||
// sensors
|
// sensors
|
||||||
usesAcceleration = false;
|
usesAcceleration = false;
|
||||||
acceleration = [0, 0, -1023];
|
acceleration = [0, 0, -1023];
|
||||||
|
accelerometerRange = 2;
|
||||||
|
|
||||||
usesHeading = false;
|
usesHeading = false;
|
||||||
heading = 90;
|
heading = 90;
|
||||||
|
Loading…
Reference in New Issue
Block a user