remove onGesture and onJoystick event
This commit is contained in:
parent
3ea33acce9
commit
902648c6a9
56
main.ts
56
main.ts
@ -509,51 +509,33 @@ namespace grove {
|
|||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a gesture is detected by Grove - Gesture
|
* init Grove Gesture modules
|
||||||
* @param gesture type of gesture to detect
|
*
|
||||||
* @param handler code to run
|
|
||||||
*/
|
*/
|
||||||
//% blockId=grove_gesture_create_event block="on Gesture|%gesture"
|
//% blockId=grove_initgesture block="init gesture"
|
||||||
export function onGesture(gesture: GroveGesture, handler: () => void) {
|
export function initGesture() {
|
||||||
control.onEvent(gestureEventId, gesture, handler);
|
|
||||||
if (!paj7620) {
|
if (!paj7620) {
|
||||||
paj7620.init();
|
paj7620.init();
|
||||||
control.inBackground(() => {
|
|
||||||
while(true) {
|
|
||||||
const gesture = paj7620.read();
|
|
||||||
if (gesture != lastGesture) {
|
|
||||||
lastGesture = gesture;
|
|
||||||
control.raiseEvent(gestureEventId, lastGesture);
|
|
||||||
}
|
|
||||||
basic.pause(50);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a key is detected by Grove - Thumb Joystick
|
* get Grove Gesture modle
|
||||||
* @param key type of joystick to detect
|
*
|
||||||
* @param xpin
|
|
||||||
* @param ypin
|
|
||||||
* @param handler code to run
|
|
||||||
*/
|
*/
|
||||||
//% blockId=grove_joystick_create_event block="on Key|%key|at|%xpin|and|%ypin|"
|
//% blockId=grove_getgesture block="get gesture model"
|
||||||
export function onJoystick(key: GroveJoystickKey, xpin: AnalogPin, ypin: AnalogPin, handler: () => void) {
|
export function getGestureModel(): number {
|
||||||
control.onEvent(joystickEventID, key, handler);
|
return paj7620.read();
|
||||||
control.inBackground(() => {
|
|
||||||
while(true) {
|
|
||||||
const key = joystick.read(xpin, ypin);
|
|
||||||
if (key != lastJoystick) {
|
|
||||||
lastJoystick = key;
|
|
||||||
control.raiseEvent(joystickEventID, lastJoystick);
|
|
||||||
}
|
|
||||||
basic.pause(50);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* get Joystick key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//% blockId=grove_getjoystick block="get joystick key at|%xpin|and|%xpin"
|
||||||
|
export function getJoystick(xpin: AnalogPin, ypin: AnalogPin): number {
|
||||||
|
return joystick.read(xpin, ypin);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
2
pxt.json
2
pxt.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Grove",
|
"name": "Grove",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"description": "A Microsoft MakeCode package for Seeed Studio Grove module",
|
"description": "A Microsoft MakeCode package for Seeed Studio Grove module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user