2017-06-23 03:54:44 +02:00
|
|
|
# Grove
|
|
|
|
|
|
|
|
A Microsoft MakeCode package for for Seeed Studio Grove module.
|
|
|
|
|
|
|
|
## Basic usage
|
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
### Grove - Gesture
|
|
|
|
|
2019-07-31 09:51:43 +02:00
|
|
|
get gesture model.
|
2018-01-30 07:40:13 +01:00
|
|
|
|
2017-06-23 03:54:44 +02:00
|
|
|
```blocks
|
2019-07-31 10:52:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
grove.onGesture(GroveGesture.Up, () => {
|
|
|
|
basic.showString("Up");
|
|
|
|
})
|
|
|
|
grove.onGesture(GroveGesture.Down, () => {
|
|
|
|
basic.showString("Down");
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2019-07-31 09:51:43 +02:00
|
|
|
grove.initGesture()
|
|
|
|
basic.forever(function () {
|
|
|
|
if (grove.getGestureModel() == 1) {
|
|
|
|
basic.showLeds(`
|
|
|
|
. . # . .
|
|
|
|
. . . # .
|
|
|
|
# # # # #
|
|
|
|
. . . # .
|
|
|
|
. . # . .
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
if (grove.getGestureModel() == 2) {
|
|
|
|
basic.showLeds(`
|
|
|
|
. . # . .
|
|
|
|
. # . . .
|
|
|
|
# # # # #
|
|
|
|
. # . . .
|
|
|
|
. . # . .
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
if (grove.getGestureModel() == 3) {
|
|
|
|
basic.showLeds(`
|
|
|
|
. . # . .
|
|
|
|
. # # # .
|
|
|
|
# . # . #
|
|
|
|
. . # . .
|
|
|
|
. . # . .
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
if (grove.getGestureModel() == 4) {
|
|
|
|
basic.showLeds(`
|
|
|
|
. . # . .
|
|
|
|
. . # . .
|
|
|
|
# . # . #
|
|
|
|
. # # # .
|
|
|
|
. . # . .
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
basic.pause(100)
|
2017-06-23 03:54:44 +02:00
|
|
|
})
|
|
|
|
```
|
2019-07-31 09:51:43 +02:00
|
|
|
all the model
|
|
|
|
```
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Grove Gestures
|
|
|
|
*/
|
|
|
|
enum GroveGesture {
|
|
|
|
//% block=None
|
|
|
|
None = 0,
|
|
|
|
//% block=Right
|
|
|
|
Right = 1,
|
|
|
|
//% block=Left
|
|
|
|
Left = 2,
|
|
|
|
//% block=Up
|
|
|
|
Up = 3,
|
|
|
|
//% block=Down
|
|
|
|
Down = 4,
|
|
|
|
//% block=Forward
|
|
|
|
Forward = 5,
|
|
|
|
//% block=Backward
|
|
|
|
Backward = 6,
|
|
|
|
//% block=Clockwise
|
|
|
|
Clockwise = 7,
|
|
|
|
//% block=Anticlockwise
|
|
|
|
Anticlockwise = 8,
|
|
|
|
//% block=Wave
|
|
|
|
Wave = 9
|
|
|
|
}
|
|
|
|
```
|
2017-06-23 03:54:44 +02:00
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
### Grove - Ultrasonic Ranger
|
2017-06-23 03:54:44 +02:00
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
Measure distance in centimeters, specify the signal pin.
|
2018-01-30 07:40:13 +01:00
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
```blocks
|
2018-01-30 07:51:35 +01:00
|
|
|
let distance = grove.measureInCentimeters(DigitalPin.P0);
|
2017-06-23 03:54:44 +02:00
|
|
|
```
|
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
Measure distance in inches, specify the signal pin.
|
2018-01-30 07:40:13 +01:00
|
|
|
|
2017-06-23 03:54:44 +02:00
|
|
|
```blocks
|
2018-01-30 07:51:35 +01:00
|
|
|
let distance = grove.measureInInches(DigitalPin.P0);
|
2018-01-30 07:31:04 +01:00
|
|
|
```
|
2017-06-23 03:54:44 +02:00
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
### Grove - 4 digital display
|
2017-06-23 03:54:44 +02:00
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
Create a 4 Digital Display driver, specify the clk and data pin, and set the brightness level, then start display value.
|
2018-01-30 07:40:13 +01:00
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
```blocks
|
2018-01-30 07:51:35 +01:00
|
|
|
let display = grove.createDisplay(DigitalPin.P0, DigitalPin.P1);
|
|
|
|
display.set(7);
|
|
|
|
display.show(1234);
|
2017-06-23 03:54:44 +02:00
|
|
|
```
|
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
Use ``||bit||`` to display one bit number.
|
2017-06-23 03:54:44 +02:00
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
Use ``||point||`` to open or close point dispay.
|
2017-06-23 03:54:44 +02:00
|
|
|
|
2018-01-30 07:31:04 +01:00
|
|
|
Use ``||clear||`` to clean display.
|
2017-06-23 03:54:44 +02:00
|
|
|
|
2020-10-12 14:55:42 +02:00
|
|
|
### Grove - UART WiFi V2
|
|
|
|
|
|
|
|
Connect to a WiFi and send data to ThinkSpeak or IFTTT, specify the UART tx and rx pin.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
grove.setupWifi(
|
|
|
|
SerialPin.P15,
|
|
|
|
SerialPin.P1,
|
|
|
|
BaudRate.BaudRate115200,
|
|
|
|
"test-ssid",
|
|
|
|
"test-passwd"
|
|
|
|
)
|
|
|
|
|
|
|
|
basic.forever(() => {
|
|
|
|
if (grove.wifiOK()) {
|
|
|
|
basic.showIcon(IconNames.Yes)
|
|
|
|
} else {
|
|
|
|
basic.showIcon(IconNames.No)
|
|
|
|
}
|
|
|
|
grove.sendToThinkSpeak("write_api_key", 1, 2, 3, 4, 5, 6, 7, 8)
|
|
|
|
grove.sendToIFTTT("ifttt_event", "ifttt_key", "hello", 'micro', 'bit')
|
|
|
|
basic.pause(60000)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2017-06-23 03:54:44 +02:00
|
|
|
## License
|
|
|
|
|
|
|
|
MIT
|
|
|
|
|
|
|
|
## Supported targets
|
|
|
|
|
2020-09-16 21:55:09 +02:00
|
|
|
* for PXT/calliopemini
|