diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index 7274b37c..8f16f02e 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -15,7 +15,6 @@ const enum LightsPattern { OrangePulse = 9, // LED_ORANGE_PULSE } - /** * User interaction on buttons */ diff --git a/libs/core/ir.ts b/libs/core/ir.ts index f8d22773..cba498c9 100644 --- a/libs/core/ir.ts +++ b/libs/core/ir.ts @@ -109,7 +109,36 @@ namespace input { } } - //% whenUsed export const ir: IrSensor = new IrSensor() + + /** + * Remote top-left button. + */ + //% whenUsed block="remote top-left" weight=95 fixedInstance + export const remoteTopLeft = ir.button(IrRemoteButton.TopLeft) + + /** + * Remote top-right button. + */ + //% whenUsed block="remote top-right" weight=95 fixedInstance + export const remoteTopRight = ir.button(IrRemoteButton.TopRight) + + /** + * Remote bottom-left button. + */ + //% whenUsed block="remote bottom-left" weight=95 fixedInstance + export const remoteBottomLeft = ir.button(IrRemoteButton.BottomLeft) + + /** + * Remote bottom-right button. + */ + //% whenUsed block="remote bottom-right" weight=95 fixedInstance + export const remoteBottomRight = ir.button(IrRemoteButton.BottomRight) + + /** + * Remote beacon (center) button. + */ + //% whenUsed block="remote center" weight=95 fixedInstance + export const remoteCenter = ir.button(IrRemoteButton.CenterBeacon) } diff --git a/libs/core/test.ts b/libs/core/test.ts index c5a17f49..0a056b2d 100644 --- a/libs/core/test.ts +++ b/libs/core/test.ts @@ -29,17 +29,17 @@ input.buttonUp.onEvent(ButtonEvent.Click, () => { let num = 0 -input.touch.button.onEvent(ButtonEvent.Click, () => { +input.touchSensor.onEvent(ButtonEvent.Click, () => { screen.drawText(10, 60, "Click! " + num) num++ }) -input.ir.button(IrRemoteButton.TopLeft).onEvent(ButtonEvent.Click, () => { +input.remoteTopLeft.onEvent(ButtonEvent.Click, () => { screen.drawText(10, 60, "TOPLEFT " + num) num++ }) -input.ir.button(IrRemoteButton.TopRight).onEvent(ButtonEvent.Down, () => { +input.remoteTopRight.onEvent(ButtonEvent.Down, () => { screen.drawText(10, 60, "TOPRIGH " + num) num++ }) diff --git a/libs/core/touch.ts b/libs/core/touch.ts index 172bb455..61339344 100644 --- a/libs/core/touch.ts +++ b/libs/core/touch.ts @@ -21,5 +21,8 @@ namespace input { } //% whenUsed - export const touch: TouchSensor = new TouchSensor() + export const touchSensorImpl: TouchSensor = new TouchSensor() + + //% whenUsed + export const touchSensor: Button = touchSensorImpl.button }