2016-04-06 00:59:25 +02:00
|
|
|
/**
|
|
|
|
* Events and data from sensors
|
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% color=#C90072 weight=99 icon="\uf192"
|
|
|
|
//% groups=['Events', 'States', 'Sensors', 'Configuration', 'System', 'others']
|
2016-03-10 23:01:04 +01:00
|
|
|
namespace input {
|
2022-08-10 18:36:19 +02:00
|
|
|
|
2016-03-10 23:01:04 +01:00
|
|
|
/**
|
2022-08-10 18:36:19 +02:00
|
|
|
* Returns the ID of an Button Event
|
2016-03-10 23:01:04 +01:00
|
|
|
*/
|
2022-08-10 18:36:19 +02:00
|
|
|
//% help=input/button-event
|
|
|
|
//% weight=19 blockId="control_button_event_value" block="%id"
|
2022-03-22 17:36:19 +01:00
|
|
|
//% shim=TD_ID advanced=true
|
2022-08-10 18:36:19 +02:00
|
|
|
//% group="Events"
|
|
|
|
export function buttonEventValue(id: ButtonEvent): number {
|
2022-03-22 17:36:19 +01:00
|
|
|
return id;
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|
|
|
|
|
2022-08-10 18:36:19 +02:00
|
|
|
/**
|
|
|
|
* Returns the ID of an Click Event
|
|
|
|
*/
|
|
|
|
//% blockId="control_button_event_click" block="clicked"
|
|
|
|
//% advanced=true
|
|
|
|
//% blockHidden=true
|
|
|
|
export function buttonEventClick(): number {
|
|
|
|
return ButtonEvent.Click;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the ID of an Down Event
|
|
|
|
*/
|
|
|
|
//% blockId="control_button_event_down" block="pressed down"
|
|
|
|
//% advanced=true
|
|
|
|
//% blockHidden=true
|
|
|
|
export function buttonEventDown(): number {
|
|
|
|
return ButtonEvent.Down;
|
|
|
|
}
|
|
|
|
|
2020-05-08 18:35:38 +02:00
|
|
|
/**
|
|
|
|
* Gets the number of milliseconds elapsed since power on.
|
|
|
|
*/
|
|
|
|
//% help=input/running-time weight=50 blockGap=8
|
|
|
|
//% blockId=device_get_running_time block="running time (ms)"
|
|
|
|
//% advanced=true
|
2022-03-22 17:36:19 +01:00
|
|
|
//% group="System"
|
2020-05-08 18:35:38 +02:00
|
|
|
export function runningTime() {
|
|
|
|
return control.millis();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the number of microseconds elapsed since power on.
|
|
|
|
*/
|
2022-03-22 17:36:19 +01:00
|
|
|
//% help=input/running-time-micros weight=49 blockGap=8
|
2020-05-08 18:35:38 +02:00
|
|
|
//% blockId=device_get_running_time_micros block="running time (micros)"
|
|
|
|
//% advanced=true
|
2022-03-22 17:36:19 +01:00
|
|
|
//% group="System"
|
2020-05-08 18:35:38 +02:00
|
|
|
export function runningTimeMicros() {
|
|
|
|
return control.micros();
|
|
|
|
}
|
2022-03-22 17:36:19 +01:00
|
|
|
|
2016-03-10 23:01:04 +01:00
|
|
|
}
|