Merge branch 'master' of github.com:Microsoft/kindscript-microbit

This commit is contained in:
Michal Moskal 2016-03-18 09:04:11 +01:00
commit a9db4f59e7
3 changed files with 22 additions and 10 deletions

View File

@ -4,12 +4,12 @@ enum Button {
//% enumval=MICROBIT_ID_BUTTON_B
B,
//% enumval=MICROBIT_ID_BUTTON_AB
//% blockId="A+B"
//% blockId="A+B" block="A+B"
AB,
}
enum Dimension {
//% enumval=0 blockId=x
//% enumval=0 blockId=x
X,
//% enumval=1 blockId=y
Y,

File diff suppressed because one or more lines are too long

View File

@ -213,16 +213,22 @@ namespace ks.rt.micro_bit {
/* input */
export function onButtonPressed(button : number, handler: RefAction) : void {
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 {
var ens = enums();
let b = board();
if (button == ens.MICROBIT_ID_BUTTON_AB && !board().usesButtonAB) {
board().usesButtonAB = true;
runtime.queueDisplayUpdate();
b.usesButtonAB = true;
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_B) return bts[1].pressed;
return bts[2].pressed || (bts[0].pressed && bts[1].pressed);