Block-friendly buttons
This commit is contained in:
parent
36050de253
commit
df45cb98ef
@ -15,7 +15,6 @@ const enum LightsPattern {
|
|||||||
OrangePulse = 9, // LED_ORANGE_PULSE
|
OrangePulse = 9, // LED_ORANGE_PULSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User interaction on buttons
|
* User interaction on buttons
|
||||||
*/
|
*/
|
||||||
|
@ -109,7 +109,36 @@ namespace input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//% whenUsed
|
//% whenUsed
|
||||||
export const ir: IrSensor = new IrSensor()
|
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)
|
||||||
}
|
}
|
||||||
|
@ -29,17 +29,17 @@ input.buttonUp.onEvent(ButtonEvent.Click, () => {
|
|||||||
|
|
||||||
let num = 0
|
let num = 0
|
||||||
|
|
||||||
input.touch.button.onEvent(ButtonEvent.Click, () => {
|
input.touchSensor.onEvent(ButtonEvent.Click, () => {
|
||||||
screen.drawText(10, 60, "Click! " + num)
|
screen.drawText(10, 60, "Click! " + num)
|
||||||
num++
|
num++
|
||||||
})
|
})
|
||||||
|
|
||||||
input.ir.button(IrRemoteButton.TopLeft).onEvent(ButtonEvent.Click, () => {
|
input.remoteTopLeft.onEvent(ButtonEvent.Click, () => {
|
||||||
screen.drawText(10, 60, "TOPLEFT " + num)
|
screen.drawText(10, 60, "TOPLEFT " + num)
|
||||||
num++
|
num++
|
||||||
})
|
})
|
||||||
|
|
||||||
input.ir.button(IrRemoteButton.TopRight).onEvent(ButtonEvent.Down, () => {
|
input.remoteTopRight.onEvent(ButtonEvent.Down, () => {
|
||||||
screen.drawText(10, 60, "TOPRIGH " + num)
|
screen.drawText(10, 60, "TOPRIGH " + num)
|
||||||
num++
|
num++
|
||||||
})
|
})
|
||||||
|
@ -21,5 +21,8 @@ namespace input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//% whenUsed
|
//% whenUsed
|
||||||
export const touch: TouchSensor = new TouchSensor()
|
export const touchSensorImpl: TouchSensor = new TouchSensor()
|
||||||
|
|
||||||
|
//% whenUsed
|
||||||
|
export const touchSensor: Button = touchSensorImpl.button
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user