Add cards to 'Control' page to match editor. (#454)

This commit is contained in:
Galen Nickel 2017-07-17 23:48:13 -07:00 committed by Peli de Halleux
parent 8e730f619c
commit a61f1ec25c
2 changed files with 9 additions and 1 deletions

View File

@ -8,8 +8,12 @@ control.inBackground(() => {
});
control.reset();
control.waitMicros(4);
control.onEvent(0, 0, () => { });
control.raiseEvent(0, 0);
control.eventTimestamp();
control.eventValue();
```
### See Also
[inBackground](/reference/control/in-background), [reset](/reference/control/reset), [wait-micros](/reference/control/wait-micros)
[inBackground](/reference/control/in-background), [reset](/reference/control/reset), [waitMicros](/reference/control/wait-micros), [onEvent](/reference/control/on-event), [raiseEvent](/reference/control/raise-event), [eventTimestamp](/reference/control/event-timestamp), [eventValue](/reference/control/event-value)

View File

@ -245,6 +245,7 @@ namespace control {
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
*/
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
//% help=control/raise-event
//% mode.defl=CREATE_AND_FIRE
void raiseEvent(int src, int value, EventCreationMode mode) {
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
@ -254,6 +255,7 @@ namespace control {
* Raises an event in the event bus.
*/
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
//% help=control/on-event
//% blockExternalInputs=1
void onEvent(int src, int value, Action handler) {
registerWithDal(src, value, handler);
@ -263,6 +265,7 @@ namespace control {
* Gets the value of the last event executed on the bus
*/
//% blockId=control_event_value" block="event value"
//% help=control/event-value
//% weight=18
int eventValue() {
return pxt::lastEvent.value;
@ -272,6 +275,7 @@ namespace control {
* Gets the timestamp of the last event executed on the bus
*/
//% blockId=control_event_timestamp" block="event timestamp"
//% help=control/event-timestamp
//% weight=19 blockGap=8
int eventTimestamp() {
return pxt::lastEvent.timestamp;