try to fix type error

This commit is contained in:
Baozhu Zuo 2019-07-30 15:03:03 +08:00
parent fe28f60f66
commit bc272c73bd

47
main.ts
View File

@ -95,30 +95,8 @@ namespace grove {
let lastGesture = GroveGesture.None;
let lastJoystick = GroveJoystickKey.None;
let joystick: GroveJoystick = undefined;
let paj7620: PAJ7620 = undefined;
let distanceBackup: number = 0;
/**
* Do something when a gesture is detected by Grove - Gesture
* @param gesture type of gesture to detect
* @param handler code to run
*/
//% blockId=grove_gesture_create_event block="on Gesture|%gesture"
export function onGesture(gesture: GroveGesture, handler: () => void) {
control.onEvent(gestureEventId, gesture, handler);
if (!paj7620) {
paj7620.init();
control.inBackground(() => {
while(true) {
const gesture = paj7620.read();
if (gesture != lastGesture) {
lastGesture = gesture;
control.raiseEvent(gestureEventId, lastGesture);
}
basic.pause(50);
}
})
}
}
/**
@ -327,6 +305,29 @@ namespace grove {
}
}
let paj7620 = new PAJ7620() ;
/**
* Do something when a gesture is detected by Grove - Gesture
* @param gesture type of gesture to detect
* @param handler code to run
*/
//% blockId=grove_gesture_create_event block="on Gesture|%gesture"
export function onGesture(gesture: GroveGesture, handler: () => void) {
control.onEvent(gestureEventId, gesture, handler);
if (!paj7620) {
paj7620.init();
control.inBackground(() => {
while(true) {
const gesture = paj7620.read();
if (gesture != lastGesture) {
lastGesture = gesture;
control.raiseEvent(gestureEventId, lastGesture);
}
basic.pause(50);
}
})
}
}
/**
*
*/