From 0463ddb96618d3cf1e3a9bebcb2b4d4c6fe52d05 Mon Sep 17 00:00:00 2001 From: Baozhu Zuo Date: Wed, 31 Jul 2019 15:18:56 +0800 Subject: [PATCH] remove onGesture and onJoystick event --- main.ts | 73 +++++++++++++------------------------------------------- pxt.json | 2 +- 2 files changed, 18 insertions(+), 57 deletions(-) diff --git a/main.ts b/main.ts index 881358d..ee8e18d 100644 --- a/main.ts +++ b/main.ts @@ -491,69 +491,30 @@ namespace grove { } /** - * Create a new driver Grove - 4-Digit Display - * @param clkPin value of clk pin number - * @param dataPin value of data pin number + * init Grove Gesture modules + * */ - //% blockId=grove_tm1637_create block="4-Digit Display at|%clkPin|and|%dataPin" - export function createDisplay(clkPin: DigitalPin, dataPin: DigitalPin): TM1637 - { - let display = new TM1637(); - - display.buf = pins.createBuffer(4); - display.clkPin = clkPin; - display.dataPin = dataPin; - display.brightnessLevel = 0; - display.pointFlag = false; - display.clear(); - - return display; - } - - /** - * 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); + //% blockId=grove_initgesture block="init gesture" + export function initGesture() { if (!paj7620) { 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 - * @param key type of joystick to detect - * @param xpin - * @param ypin - * @param handler code to run + * get Grove Gesture modle + * */ - //% blockId=grove_joystick_create_event block="on Key|%key|at|%xpin|and|%ypin|" - export function onJoystick(key: GroveJoystickKey, xpin: AnalogPin, ypin: AnalogPin, handler: () => void) { - control.onEvent(joystickEventID, key, handler); - control.inBackground(() => { - while(true) { - const key = joystick.read(xpin, ypin); - if (key != lastJoystick) { - lastJoystick = key; - control.raiseEvent(joystickEventID, lastJoystick); - } - basic.pause(50); - } - }) - + //% blockId=grove_getgesture block="get gesture model" + export function getGestureModel(): number { + return paj7620.read(); + } + /** + * 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); } } \ No newline at end of file diff --git a/pxt.json b/pxt.json index a4ada0a..6d26c62 100644 --- a/pxt.json +++ b/pxt.json @@ -1,6 +1,6 @@ { "name": "Grove", - "version": "0.1.1", + "version": "0.1.2", "description": "A Microsoft MakeCode package for Seeed Studio Grove module", "license": "MIT", "dependencies": {