2016-03-10 23:01:04 +01:00
|
|
|
//% color=300 weight=99
|
|
|
|
namespace input {
|
|
|
|
/**
|
|
|
|
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
|
|
|
* @param button TODO
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/on-button-pressed weight=85
|
2016-03-10 23:01:04 +01:00
|
|
|
//% shim=micro_bit::onButtonPressed
|
|
|
|
//% blockId=device_button_event
|
|
|
|
//% block="on button|%NAME|pressed"
|
|
|
|
//% icon="\uf192"
|
|
|
|
export function onButtonPressed(button: Button, body: Action): void { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attaches code to run when the screen is facing up.
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/on-gesture shim=micro_bit::onGesture weight=84
|
2016-03-10 23:01:04 +01:00
|
|
|
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
2016-03-24 16:26:55 +01:00
|
|
|
export function onGesture(gesture: Gesture, body: Action): void { }
|
2016-03-10 23:01:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.
|
|
|
|
* @param name TODO
|
|
|
|
* @param body TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/on-pin-pressed weight=83 shim=micro_bit::onPinPressed
|
2016-03-10 23:01:04 +01:00
|
|
|
//% blockId=device_pin_event block="on pin|%NAME|pressed" icon="\uf094"
|
2016-03-24 16:26:55 +01:00
|
|
|
export function onPinPressed(name: TouchPin, body: Action): void { }
|
2016-03-10 23:01:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/button-is-pressed weight=57
|
2016-03-10 23:01:04 +01:00
|
|
|
//% shim=micro_bit::isButtonPressed
|
|
|
|
//% block="button|%NAME|is pressed"
|
|
|
|
//% blockId=device_get_button2
|
|
|
|
//% icon="\uf192" blockGap=8
|
|
|
|
export function buttonIsPressed(button: Button): boolean {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current compass compass heading in degrees.
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/compass-heading
|
2016-03-10 23:01:04 +01:00
|
|
|
//% weight=56 icon="\uf14e"
|
|
|
|
//% shim=micro_bit::compassHeading
|
|
|
|
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
|
|
|
export function compassHeading(): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the temperature in Celsius degrees (°C).
|
|
|
|
*/
|
|
|
|
//% weight=55 icon="\uf06d"
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/temperature shim=micro_bit::temperature
|
2016-03-10 23:01:04 +01:00
|
|
|
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
|
|
|
export function temperature(): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
|
|
|
* @param dimension TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/acceleration weight=54 icon="\uf135"
|
2016-03-10 23:01:04 +01:00
|
|
|
//% shim=micro_bit::getAcceleration
|
|
|
|
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
|
|
|
export function acceleration(dimension: Dimension): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright. In the simulator, the ``acceleration y`` is used to emulate this value.
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/light-level weight=53 shim=micro_bit::lightLevel
|
2016-03-10 23:01:04 +01:00
|
|
|
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
|
|
|
export function lightLevel(): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The pitch of the device, rotation along the ``x-axis``, in degrees.
|
|
|
|
* @param kind TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=/input/rotation weight=52 shim=micro_bit::getRotation
|
2016-03-10 23:01:04 +01:00
|
|
|
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
|
|
|
export function rotation(kind: Rotation): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
|
|
|
|
* @param dimension TODO
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/magnetic-force weight=51 shim=micro_bit::getMagneticForce
|
2016-03-10 23:01:04 +01:00
|
|
|
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
|
|
|
export function magneticForce(dimension: Dimension): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the number of milliseconds elapsed since power on.
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/running-time shim=micro_bit::getCurrentTime weight=50
|
2016-03-16 22:56:50 +01:00
|
|
|
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
2016-03-10 23:01:04 +01:00
|
|
|
export function runningTime(): number {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obsolete, compass calibration is automatic.
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/calibrate weight=0 shim=TD_NOOP
|
2016-03-10 23:01:04 +01:00
|
|
|
export function calibrate(): void { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
2016-03-23 20:55:36 +01:00
|
|
|
* @param name pin used to detect the touch
|
2016-03-10 23:01:04 +01:00
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/pin-is-pressed weight=58 shim=micro_bit::isPinTouched block="pin|%NAME|is pressed" icon="\uf094"
|
2016-03-24 16:26:55 +01:00
|
|
|
export function pinIsPressed(name: TouchPin): boolean {
|
2016-03-10 23:01:04 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2016-03-10 23:01:04 +01:00
|
|
|
export function onScreenUp(body: Action): 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
|
2016-03-10 23:01:04 +01:00
|
|
|
export function onScreenDown(body: Action): 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
|
2016-03-10 23:01:04 +01:00
|
|
|
export function onShake(body: Action): 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
|
2016-03-10 23:01:04 +01:00
|
|
|
export function onLogoUp(body: Action): 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
|
2016-03-10 23:01:04 +01:00
|
|
|
export function onLogoDown(body: Action): void {
|
2016-03-24 16:26:55 +01:00
|
|
|
onGesture(Gesture.LogoDown, body);
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|
2016-03-16 22:56:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the accelerometer sample range in gravities.
|
|
|
|
* @param range a value describe the maximum strengh of acceleration measured
|
|
|
|
*/
|
2016-03-22 06:13:39 +01:00
|
|
|
//% help=input/set-accelerator-range
|
2016-03-16 22:56:50 +01:00
|
|
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
|
|
|
//% weight=5
|
|
|
|
//% shim=micro_bit::setAccelerometerRange
|
|
|
|
export function setAccelerometerRange(range : AcceleratorRange) : void {
|
|
|
|
|
|
|
|
}
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|