diff --git a/libs/core/control.cpp b/libs/core/control.cpp index 4340014e..0aff221f 100644 --- a/libs/core/control.cpp +++ b/libs/core/control.cpp @@ -205,6 +205,15 @@ enum EventBusValue { MES_REMOTE_CONTROL_EVT_VOLUMEUP_ = MES_REMOTE_CONTROL_EVT_VOLUMEUP, }; +enum EventFlags { + //% + QueueIfBusy = MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY, + //% + DropIfBusy = MESSAGE_BUS_LISTENER_DROP_IF_BUSY, + //% + Reentrant = MESSAGE_BUS_LISTENER_REENTRANT +}; + //% weight=1 color="#333333" //% advanced=true namespace control { @@ -261,8 +270,9 @@ namespace control { //% 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); + void onEvent(int src, int value, Action handler, int flags = 0) { + if (!flags) flags = EventFlags::QueueIfBusy; + registerWithDal(src, value, handler, (int)flags); } /** diff --git a/libs/core/enums.d.ts b/libs/core/enums.d.ts index 5afb1cc1..41c45fff 100644 --- a/libs/core/enums.d.ts +++ b/libs/core/enums.d.ts @@ -400,6 +400,16 @@ declare namespace input { //% blockIdentity="control.eventValueId" MES_REMOTE_CONTROL_EVT_VOLUMEUP = 8, // MES_REMOTE_CONTROL_EVT_VOLUMEUP } + + + declare const enum EventFlags { + //% + QueueIfBusy = 16, // MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY + //% + DropIfBusy = 32, // MESSAGE_BUS_LISTENER_DROP_IF_BUSY + //% + Reentrant = 8, // MESSAGE_BUS_LISTENER_REENTRANT + } declare namespace control { } diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index b0082c35..5d370f40 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -411,8 +411,8 @@ declare namespace control { */ //% 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 shim=control::onEvent - function onEvent(src: int32, value: int32, handler: () => void): void; + //% blockExternalInputs=1 flags.defl=0 shim=control::onEvent + function onEvent(src: int32, value: int32, handler: () => void, flags?: int32): void; /** * Gets the value of the last event executed on the bus