Merge branch 'master' of github.com:Microsoft/kindscript-microbit
This commit is contained in:
commit
a9db4f59e7
@ -4,12 +4,12 @@ enum Button {
|
|||||||
//% enumval=MICROBIT_ID_BUTTON_B
|
//% enumval=MICROBIT_ID_BUTTON_B
|
||||||
B,
|
B,
|
||||||
//% enumval=MICROBIT_ID_BUTTON_AB
|
//% enumval=MICROBIT_ID_BUTTON_AB
|
||||||
//% blockId="A+B"
|
//% blockId="A+B" block="A+B"
|
||||||
AB,
|
AB,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Dimension {
|
enum Dimension {
|
||||||
//% enumval=0 blockId=x
|
//% enumval=0 blockId=x
|
||||||
X,
|
X,
|
||||||
//% enumval=1 blockId=y
|
//% enumval=1 blockId=y
|
||||||
Y,
|
Y,
|
||||||
|
File diff suppressed because one or more lines are too long
@ -213,16 +213,22 @@ namespace ks.rt.micro_bit {
|
|||||||
/* input */
|
/* input */
|
||||||
export function onButtonPressed(button : number, handler: RefAction) : void {
|
export function onButtonPressed(button : number, handler: RefAction) : void {
|
||||||
let ens = enums();
|
let ens = enums();
|
||||||
board().bus.listen(button, ens.MICROBIT_BUTTON_EVT_CLICK, handler);
|
let b = board();
|
||||||
|
if (button == ens.MICROBIT_ID_BUTTON_AB && !board().usesButtonAB) {
|
||||||
|
b.usesButtonAB = true;
|
||||||
|
b.updateView();
|
||||||
|
}
|
||||||
|
b.bus.listen(button, ens.MICROBIT_BUTTON_EVT_CLICK, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isButtonPressed(button: number): boolean {
|
export function isButtonPressed(button: number): boolean {
|
||||||
var ens = enums();
|
var ens = enums();
|
||||||
|
let b = board();
|
||||||
if (button == ens.MICROBIT_ID_BUTTON_AB && !board().usesButtonAB) {
|
if (button == ens.MICROBIT_ID_BUTTON_AB && !board().usesButtonAB) {
|
||||||
board().usesButtonAB = true;
|
b.usesButtonAB = true;
|
||||||
runtime.queueDisplayUpdate();
|
b.updateView();
|
||||||
}
|
}
|
||||||
var bts = board().buttons;
|
var bts = b.buttons;
|
||||||
if (button == ens.MICROBIT_ID_BUTTON_A) return bts[0].pressed;
|
if (button == ens.MICROBIT_ID_BUTTON_A) return bts[0].pressed;
|
||||||
if (button == ens.MICROBIT_ID_BUTTON_B) return bts[1].pressed;
|
if (button == ens.MICROBIT_ID_BUTTON_B) return bts[1].pressed;
|
||||||
return bts[2].pressed || (bts[0].pressed && bts[1].pressed);
|
return bts[2].pressed || (bts[0].pressed && bts[1].pressed);
|
||||||
|
Loading…
Reference in New Issue
Block a user