Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfeeada678 | ||
|
|
1d51956960 | ||
|
|
f006a8b115 | ||
|
|
a97427ee49 | ||
|
|
90d23f74fd | ||
|
|
dff3c9bf76 | ||
|
|
f1dba411b0 | ||
|
|
f65efbaf40 | ||
|
|
48ab57de24 | ||
|
|
37bcbb378e | ||
|
|
eba0e205f5 | ||
|
|
43674e0dc5 |
10
README.md
10
README.md
@@ -9,6 +9,16 @@ A Microsoft MakeCode package for for Seeed Studio Grove module.
|
|||||||
get gesture model.
|
get gesture model.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
|
|
||||||
|
|
||||||
|
grove.onGesture(GroveGesture.Up, () => {
|
||||||
|
basic.showString("Up");
|
||||||
|
})
|
||||||
|
grove.onGesture(GroveGesture.Down, () => {
|
||||||
|
basic.showString("Down");
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
grove.initGesture()
|
grove.initGesture()
|
||||||
basic.forever(function () {
|
basic.forever(function () {
|
||||||
if (grove.getGestureModel() == 1) {
|
if (grove.getGestureModel() == 1) {
|
||||||
|
|||||||
39
_locales/de/Grove-strings.json
Normal file
39
_locales/de/Grove-strings.json
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"{id:category}Grove": "Grove",
|
||||||
|
"GroveGesture.None|block": "keine",
|
||||||
|
"GroveGesture.Right|block": "rechts",
|
||||||
|
"GroveGesture.Left|block": "links",
|
||||||
|
"GroveGesture.Up|block": "auf",
|
||||||
|
"GroveGesture.Down|block": "nieder",
|
||||||
|
"GroveGesture.Forward|block": "vorwärts",
|
||||||
|
"GroveGesture.Backward|block": "rückwärts",
|
||||||
|
"GroveGesture.Clockwise|block": "Uhrzeigersinn",
|
||||||
|
"GroveGesture.Anticlockwise|block": "Gegenuhrzeigersinn",
|
||||||
|
"GroveGesture.Wave|block": "Welle",
|
||||||
|
"grove.initGesture|block": "initialisiere Grove Gestenerkennung",
|
||||||
|
"grove.getGestureModel|block": "hole Geste",
|
||||||
|
"grove.onGesture|block": "wenn Grove - Gestensensor |%gesture|",
|
||||||
|
"grove.measureInCentimeters|block": "Ultraschallsensor (in cm) an |%pin",
|
||||||
|
"grove.measureInInches|block": "Ultraschallsensor (in inch) an |%pin",
|
||||||
|
"grove.createDisplay|block": "4-Ziffern Display an|%clkPin|und|%dataPin",
|
||||||
|
"grove.PAJ7620.init|block": "%strip|initialisiere den Gestensensor",
|
||||||
|
"grove.PAJ7620.read|block": "%strip|erkenne Geste",
|
||||||
|
"grove.TM1637.show|block": "%strip|zeige Zahl|%dispData|",
|
||||||
|
"grove.TM1637.set|block": "%strip|setze Helligkeit auf|%level|",
|
||||||
|
"grove.TM1637.bit|block": "%strip|zeige Ziffer|%dispData|an Stelle|%bitAddr|",
|
||||||
|
"grove.TM1637.point|block": "%strip|schalte Kommapunkt|%point|",
|
||||||
|
"grove.TM1637.clear|block": "%strip|lösche 4-Ziffern Display",
|
||||||
|
"GroveJoystickKey.None|block": "Keiner",
|
||||||
|
"GroveJoystickKey.Right|block": "Rechts",
|
||||||
|
"GroveJoystickKey.Left|block": "Links",
|
||||||
|
"GroveJoystickKey.Up|block": "Hoch",
|
||||||
|
"GroveJoystickKey.Down|block": "Runter",
|
||||||
|
"GroveJoystickKey.UL|block": "Oben links",
|
||||||
|
"GroveJoystickKey.UR|block": "Oben rechts",
|
||||||
|
"GroveJoystickKey.LL|block": "Unten links",
|
||||||
|
"GroveJoystickKey.LR|block": "Unten rechts",
|
||||||
|
"GroveJoystickKey.Press|block": "Gedrückt",
|
||||||
|
"grove.strip.read|block": "%strip|lies Position von Joystick an|%xpin|und|%ypin",
|
||||||
|
"grove.onJoystick|block": "wenn Grove - Joysticktaste|%key an|%xpin|und|%ypin",
|
||||||
|
"grove.getJoystick|block": "hole Joysticktaste an|%xpin|und|%ypin"
|
||||||
|
}
|
||||||
116
main.ts
116
main.ts
@@ -260,59 +260,68 @@ namespace grove {
|
|||||||
//% blockId=grove_tm1637_display_number block="%strip|show number|%dispData"
|
//% blockId=grove_tm1637_display_number block="%strip|show number|%dispData"
|
||||||
show(dispData: number)
|
show(dispData: number)
|
||||||
{
|
{
|
||||||
|
let compare_01:number = Math.floor(dispData / 10);
|
||||||
|
let compare_001:number = Math.floor(dispData / 100);
|
||||||
|
let compare_0001:number = Math.floor(dispData / 1000);
|
||||||
|
|
||||||
if(dispData < 10)
|
if(dispData < 10)
|
||||||
{
|
{
|
||||||
this.bit(dispData, 3);
|
this.bit(dispData, 3);
|
||||||
this.bit(0x7f, 2);
|
this.bit(0x7f, 2);
|
||||||
this.bit(0x7f, 1);
|
this.bit(0x7f, 1);
|
||||||
this.bit(0x7f, 0);
|
this.bit(0x7f, 0);
|
||||||
|
|
||||||
this.buf[3] = dispData;
|
|
||||||
this.buf[2] = 0x7f;
|
|
||||||
this.buf[1] = 0x7f;
|
|
||||||
this.buf[0] = 0x7f;
|
|
||||||
}
|
}
|
||||||
else if(dispData < 100)
|
else if(dispData < 100)
|
||||||
{
|
{
|
||||||
this.bit(dispData % 10, 3);
|
this.bit(dispData % 10, 3);
|
||||||
this.bit((dispData / 10) % 10, 2);
|
if(dispData > 90){
|
||||||
|
this.bit(9, 2);
|
||||||
|
} else{
|
||||||
|
this.bit(Math.floor(dispData / 10) % 10, 2);
|
||||||
|
}
|
||||||
|
|
||||||
this.bit(0x7f, 1);
|
this.bit(0x7f, 1);
|
||||||
this.bit(0x7f, 0);
|
this.bit(0x7f, 0);
|
||||||
|
|
||||||
this.buf[3] = dispData % 10;
|
|
||||||
this.buf[2] = (dispData / 10) % 10;
|
|
||||||
this.buf[1] = 0x7f;
|
|
||||||
this.buf[0] = 0x7f;
|
|
||||||
}
|
}
|
||||||
else if(dispData < 1000)
|
else if(dispData < 1000)
|
||||||
{
|
{
|
||||||
this.bit(dispData % 10, 3);
|
this.bit(dispData % 10, 3);
|
||||||
this.bit((dispData / 10) % 10, 2);
|
if(compare_01 > 90){
|
||||||
this.bit((dispData / 100) % 10, 1);
|
this.bit(9, 2);
|
||||||
|
} else{
|
||||||
|
this.bit(Math.floor(dispData / 10) % 10, 2);
|
||||||
|
}
|
||||||
|
if(compare_001 > 900){
|
||||||
|
this.bit(9, 1);
|
||||||
|
} else{
|
||||||
|
this.bit(Math.floor(dispData / 100) % 10, 1);
|
||||||
|
}
|
||||||
this.bit(0x7f, 0);
|
this.bit(0x7f, 0);
|
||||||
|
|
||||||
this.buf[3] = dispData % 10;
|
|
||||||
this.buf[2] = (dispData / 10) % 10;
|
|
||||||
this.buf[1] = (dispData / 100) % 10;
|
|
||||||
this.buf[0] = 0x7f;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.bit(dispData % 10, 3);
|
this.bit(dispData % 10, 3);
|
||||||
this.bit((dispData / 10) % 10, 2);
|
if(compare_01 > 90){
|
||||||
this.bit((dispData / 100) % 10, 1);
|
this.bit(9, 2);
|
||||||
this.bit((dispData / 1000) % 10, 0);
|
} else{
|
||||||
|
this.bit(Math.floor(dispData / 10) % 10, 2);
|
||||||
this.buf[3] = dispData % 10;
|
}
|
||||||
this.buf[2] = (dispData / 10) % 10;
|
if(compare_001 > 900){
|
||||||
this.buf[1] = (dispData / 100) % 10;
|
this.bit(9, 1);
|
||||||
this.buf[0] = (dispData / 1000) % 10;
|
} else{
|
||||||
|
this.bit(Math.floor(dispData / 100) % 10, 1);
|
||||||
|
}
|
||||||
|
if(compare_0001 > 9000){
|
||||||
|
this.bit(9, 0);
|
||||||
|
} else{
|
||||||
|
this.bit(Math.floor(dispData / 1000) % 10, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the brightness level of display at from 0 to 7
|
* Set the brightness level of display at from 0 to 7
|
||||||
* @param level value of brightness level
|
* @param level value of brightness light level
|
||||||
*/
|
*/
|
||||||
//% blockId=grove_tm1637_set_display_level block="%strip|brightness level to|%level"
|
//% blockId=grove_tm1637_set_display_level block="%strip|brightness level to|%level"
|
||||||
//% level.min=0 level.max=7
|
//% level.min=0 level.max=7
|
||||||
@@ -395,7 +404,7 @@ namespace grove {
|
|||||||
* @param xPin
|
* @param xPin
|
||||||
* @param yPin
|
* @param yPin
|
||||||
*/
|
*/
|
||||||
//% blockId=grove_joystick_read block="%strip|read position of joystick"
|
//% blockId=grove_joystick_read block="%strip|read position of joystick at|%xpin|and|%ypin"
|
||||||
//% advanced=true
|
//% advanced=true
|
||||||
read(xPin: AnalogPin, yPin: AnalogPin): number {
|
read(xPin: AnalogPin, yPin: AnalogPin): number {
|
||||||
let xdata = 0, ydata = 0, result = 0;
|
let xdata = 0, ydata = 0, result = 0;
|
||||||
@@ -533,9 +542,54 @@ namespace grove {
|
|||||||
* get Joystick key
|
* get Joystick key
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//% blockId=grove_getjoystick block="get joystick key at|%xpin|and|%xpin"
|
//% blockId=grove_getjoystick block="get joystick key at|%xpin|and|%ypin"
|
||||||
export function getJoystick(xpin: AnalogPin, ypin: AnalogPin): number {
|
export function getJoystick(xpin: AnalogPin, ypin: AnalogPin): number {
|
||||||
return joystick.read(xpin, ypin);
|
return joystick.read(xpin, ypin);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
//% 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);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
5
pxt.json
5
pxt.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Grove",
|
"name": "Grove",
|
||||||
"version": "0.1.4",
|
"version": "0.1.7",
|
||||||
"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": {
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"README.md",
|
"README.md",
|
||||||
"main.ts",
|
"main.ts",
|
||||||
"_locales/ja/Grove-strings.json"
|
"_locales/ja/Grove-strings.json",
|
||||||
|
"_locales/de/Grove-strings.json"
|
||||||
],
|
],
|
||||||
"testFiles": [
|
"testFiles": [
|
||||||
"test.ts"
|
"test.ts"
|
||||||
|
|||||||
Reference in New Issue
Block a user