Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Apr 11, 2024
2 parents cd8a966 + 5995c61 commit 70c7a40
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
11 changes: 4 additions & 7 deletions compiler/src/boards.json
Original file line number Diff line number Diff line change
Expand Up @@ -693,17 +693,13 @@
"service": "buzzer"
},
{
"dir": -1,
"en": -1,
"name": "M1",
"pwm": 1,
"pin1": 1,
"service": "motor"
},
{
"dir": -1,
"en": -1,
"pin1": 4,
"name": "M2",
"pwm": 4,
"service": "motor"
}
],
Expand All @@ -725,7 +721,8 @@
},
"pins": {
"P1": 2,
"P2": 0
"P2": 0,
"LED": 10
},
"productId": "0x38ccab8d",
"url": "https://www.kittenbot.cc/products/kittenbot-grapebit"
Expand Down
18 changes: 18 additions & 0 deletions packages/drivers/src/kittenbotgrapebit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { configureHardware } from "@devicescript/servers"
import { pins, board } from "@dsboard/kittenbot_grapebit_esp32c3"
import { startAccelerometer } from "./accelerometer"
import { DA213BDriver } from "./da213b"
import { startLed } from "./ledserver"
import { LedStripLightType, LedVariant } from "@devicescript/core"
/**
* Support for KittenBot Grape:bit ESP32-C3
*
Expand Down Expand Up @@ -69,7 +71,23 @@ export class KittenBotGrapeBit {
*/
async startAccelerometer() {
const driver = new DA213BDriver()
await driver.init()
const acc = await startAccelerometer(driver, {})
return acc
}

/**
* Start On board LED
*/
async startLed() {
const led = await startLed({
length: 4,
variant: LedVariant.Ring,
hwConfig: {
type: LedStripLightType.WS2812B_GRB,
pin: pins.LED,
}
})
return led
}
}
3 changes: 3 additions & 0 deletions packages/sampleprj/src/maingrapebit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const m1 = await board.startMotor1()
const m2 = await board.startMotor2()
const bA = await board.startButtonA()
const bB = await board.startButtonB()
const led = await board.startLed()

await led.showAll(0x001f00)

acc.reading.subscribe(v => console.data(v))
bA.down.subscribe(() => console.data("A down"))
Expand Down
11 changes: 4 additions & 7 deletions website/docs/devices/boards.json
Original file line number Diff line number Diff line change
Expand Up @@ -569,17 +569,13 @@
"service": "buzzer"
},
{
"dir": -1,
"en": -1,
"name": "M1",
"pwm": 1,
"pin1": 1,
"service": "motor"
},
{
"dir": -1,
"en": -1,
"pin1": 4,
"name": "M2",
"pwm": 4,
"service": "motor"
}
],
Expand All @@ -601,7 +597,8 @@
},
"pins": {
"P1": 2,
"P2": 0
"P2": 0,
"LED": 10
},
"productId": "0x38ccab8d",
"url": "https://www.kittenbot.cc/products/kittenbot-grapebit",
Expand Down
15 changes: 7 additions & 8 deletions website/docs/devices/esp32/kittenbot-grapebit-esp32c3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ A round board packed with IMU, buzzer, motor control, 4 RGB LEDs, and Jacdac.
|:---------|:------------|---------:|
| **P1** | GPIO2 | analogIn, boot, io |
| **P2** | GPIO0 | analogIn, io |
| **LED** | GPIO10 | io |
| **$services.buttonA[0].pin** | GPIO21 | $services.buttonA[0].pin, bootUart, io |
| **$services.buttonB[1].pin** | GPIO9 | $services.buttonB[1].pin, boot, io |
| **$services.music[2].pin** | GPIO3 | $services.music[2].pin, analogIn, io |
| **$services.M1[3].pin1** | GPIO1 | $services.M1[3].pin1, analogIn, io |
| **$services.M2[4].pin1** | GPIO4 | $services.M2[4].pin1, analogIn, debug, io |
| **i2c.pinSCL** | GPIO7 | i2c.pinSCL, debug, io |
| **i2c.pinSDA** | GPIO6 | i2c.pinSDA, debug, io |
| **jacdac.pin** | GPIO5 | jacdac.pin, debug, io |
| **led.pin** | GPIO10 | led.pin, io |



Expand Down Expand Up @@ -105,17 +107,13 @@ devicescript flash --board kittenbot_grapebit_esp32c3
"service": "buzzer"
},
{
"dir": -1,
"en": -1,
"name": "M1",
"pwm": 1,
"pin1": 1,
"service": "motor"
},
{
"dir": -1,
"en": -1,
"pin1": 4,
"name": "M2",
"pwm": 4,
"service": "motor"
}
],
Expand All @@ -134,7 +132,8 @@ devicescript flash --board kittenbot_grapebit_esp32c3
},
"pins": {
"P1": 2,
"P2": 0
"P2": 0,
"LED": 10
}
}
```

0 comments on commit 70c7a40

Please sign in to comment.