* rename "microbit" package to "core" #414 * shouldn't edit the package id. * updating package.json * updated the wrong version * missed updating pxt.json of tests
This commit is contained in:
committed by
Peli de Halleux
parent
80131f2928
commit
277d5a721c
50
libs/core/input.ts
Normal file
50
libs/core/input.ts
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Events and data from sensors
|
||||
*/
|
||||
//% color=#B4009E weight=99
|
||||
namespace input {
|
||||
/**
|
||||
* Attaches code to run when the screen is facing up.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-screen-up
|
||||
export function onScreenUp(body: Action): void {
|
||||
onGesture(Gesture.ScreenUp, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the screen is facing down.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-screen-down
|
||||
export function onScreenDown(body: Action): void {
|
||||
onGesture(Gesture.ScreenDown, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the device is shaken.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-shake
|
||||
export function onShake(body: Action): void {
|
||||
onGesture(Gesture.Shake, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the logo is oriented upwards and the board is vertical.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-logo-up
|
||||
export function onLogoUp(body: Action): void {
|
||||
onGesture(Gesture.LogoUp, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the logo is oriented downwards and the board is vertical.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-logo-down
|
||||
export function onLogoDown(body: Action): void {
|
||||
onGesture(Gesture.LogoDown, body);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user