2016-04-06 00:59:25 +02:00
|
|
|
/**
|
|
|
|
* Events and data from sensors
|
|
|
|
*/
|
2018-10-02 18:32:08 +02:00
|
|
|
//% color=#D400D4 weight=111 icon="\uf192"
|
2016-03-10 23:01:04 +01:00
|
|
|
namespace input {
|
|
|
|
/**
|
|
|
|
* Attaches code to run when the screen is facing up.
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/on-screen-up
|
2018-05-14 20:05:47 +02:00
|
|
|
export function onScreenUp(body: () => void): void {
|
2016-03-24 16:26:55 +01:00
|
|
|
onGesture(Gesture.ScreenUp, body);
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attaches code to run when the screen is facing down.
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/on-screen-down
|
2018-05-14 20:05:47 +02:00
|
|
|
export function onScreenDown(body: () => void): void {
|
2016-03-24 16:26:55 +01:00
|
|
|
onGesture(Gesture.ScreenDown, body);
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attaches code to run when the device is shaken.
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/on-shake
|
2018-05-14 20:05:47 +02:00
|
|
|
export function onShake(body: () => void): void {
|
2016-03-24 16:26:55 +01:00
|
|
|
onGesture(Gesture.Shake, body);
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attaches code to run when the logo is oriented upwards and the board is vertical.
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/on-logo-up
|
2018-05-14 20:05:47 +02:00
|
|
|
export function onLogoUp(body: () => void): void {
|
2016-03-24 16:26:55 +01:00
|
|
|
onGesture(Gesture.LogoUp, body);
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attaches code to run when the logo is oriented downwards and the board is vertical.
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/on-logo-down
|
2018-05-14 20:05:47 +02:00
|
|
|
export function onLogoDown(body: () => void): void {
|
2016-03-24 16:26:55 +01:00
|
|
|
onGesture(Gesture.LogoDown, body);
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|
2017-04-25 19:46:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Obsolete, use input.calibrateCompass instead.
|
|
|
|
*/
|
|
|
|
//% weight=0 help=input/calibrate-compass
|
|
|
|
export function calibrate() {
|
|
|
|
input.calibrateCompass();
|
|
|
|
}
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|