diff --git a/compiler/src/boards.json b/compiler/src/boards.json index 9ca8ed6269..c43fa8115a 100644 --- a/compiler/src/boards.json +++ b/compiler/src/boards.json @@ -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" } ], @@ -725,7 +721,8 @@ }, "pins": { "P1": 2, - "P2": 0 + "P2": 0, + "LED": 10 }, "productId": "0x38ccab8d", "url": "https://www.kittenbot.cc/products/kittenbot-grapebit" diff --git a/packages/drivers/src/kittenbotgrapebit.ts b/packages/drivers/src/kittenbotgrapebit.ts index f9a4462d16..f9c0bd0f71 100644 --- a/packages/drivers/src/kittenbotgrapebit.ts +++ b/packages/drivers/src/kittenbotgrapebit.ts @@ -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 * @@ -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 + } } diff --git a/packages/sampleprj/src/maingrapebit.ts b/packages/sampleprj/src/maingrapebit.ts index 0ed059d890..5fb3e45671 100644 --- a/packages/sampleprj/src/maingrapebit.ts +++ b/packages/sampleprj/src/maingrapebit.ts @@ -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")) diff --git a/website/docs/devices/boards.json b/website/docs/devices/boards.json index 51f35ee792..83b7a64293 100644 --- a/website/docs/devices/boards.json +++ b/website/docs/devices/boards.json @@ -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" } ], @@ -601,7 +597,8 @@ }, "pins": { "P1": 2, - "P2": 0 + "P2": 0, + "LED": 10 }, "productId": "0x38ccab8d", "url": "https://www.kittenbot.cc/products/kittenbot-grapebit", diff --git a/website/docs/devices/esp32/kittenbot-grapebit-esp32c3.mdx b/website/docs/devices/esp32/kittenbot-grapebit-esp32c3.mdx index 43c24d6cea..6ceafa3174 100644 --- a/website/docs/devices/esp32/kittenbot-grapebit-esp32c3.mdx +++ b/website/docs/devices/esp32/kittenbot-grapebit-esp32c3.mdx @@ -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 | @@ -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" } ], @@ -134,7 +132,8 @@ devicescript flash --board kittenbot_grapebit_esp32c3 }, "pins": { "P1": 2, - "P2": 0 + "P2": 0, + "LED": 10 } } ```