Skip to content

Commit

Permalink
added rp2040 matrix example
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Oct 2, 2023
1 parent 68ebe7b commit 11d1f3d
Show file tree
Hide file tree
Showing 28 changed files with 335 additions and 4 deletions.
4 changes: 2 additions & 2 deletions compiler/src/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ description: ${devName}
: undefined,
`\n## Features\n`,
...info.features.map(f => `- ${f}`),
`\n{@import optional ./${fdevId}-features.mdp}\n`,
`{@import optional ./${fdevId}-features.mdp}\n`,
...info.services.map(f => `- Service: ${f}`),
`\n{@import optional ./${fdevId}-services.mdp}\n`,
`{@import optional ./${fdevId}-services.mdp}\n`,
!boardJson.i2c &&
`
:::caution
Expand Down
4 changes: 2 additions & 2 deletions packages/drivers/src/esp32c3fh4rgb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Esp32C3FH4RGB {
/**
* Start built-in ButtonBOOT
*/
startButtonBOOT(roleName?: string) {
return board.startButtonBOOT(roleName)
startButtonBOOT() {
return board.startButtonBOOT("BOOT")
}
}
36 changes: 36 additions & 0 deletions packages/sampleprj/boards/waveshare_pico_matrix.board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/devicescript-pico/main/boards/rp2040deviceconfig.schema.json",
"devName": "Waveshare RP2040-Matrix",
"productId": "0x3f8a8e31",
"$description": "RP2040 RGB LED Matrix Board.",
"archId": "rp2040",
"url": "https://www.waveshare.com/rp2040-matrix.htm",
"pins": {
"GP0": 0,
"GP1": 1,
"GP10": 10,
"GP11": 11,
"GP12": 12,
"GP13": 13,
"GP14": 14,
"GP15": 15,
"LEDS": 16,
"GP17": 17,
"GP18": 18,
"GP19": 19,
"GP2": 2,
"GP20": 20,
"GP21": 21,
"GP22": 22,
"GP26": 26,
"GP27": 27,
"GP28": 28,
"GP3": 3,
"GP4": 4,
"GP5": 5,
"GP6": 6,
"GP7": 7,
"GP8": 8,
"GP9": 9
}
}
52 changes: 52 additions & 0 deletions packages/sampleprj/src/main5x5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { pins, board } from "@dsboard/waveshare_pico_matrix"
import { Led, LedStripLightType, LedVariant } from "@devicescript/core"
import { startLed } from "@devicescript/drivers"
import { configureHardware } from "@devicescript/servers"
import { startLedDisplay } from "@devicescript/runtime"
import { font5 } from "@devicescript/graphics"

/**
* Driver for the WaveShare RP2040 Matrix board
*
* @devsWhenUsed
*/
export class WaveShareRP2040Matrix {
constructor() {
configureHardware({
scanI2C: false
})
}

/**
* Gets the pin mappings
*/
pins() {
return pins
}

/**
* Starts the LED service for the 5x5 matrix
* @returns
*/
async startLed() {
return await startLed({
length: 25,
columns: 5,
intensity: 0.2,
variant: LedVariant.Matrix,
hwConfig: {
type: LedStripLightType.WS2812B_GRB,
pin: pins.LEDS,
},
roleName: "LEDS",
})
}
}

const b = new WaveShareRP2040Matrix()
const leds = await b.startLed()
const pixels = await leds.buffer()
const display = await startLedDisplay(leds)
const font = font5()
display.image.print("0", 0, 0, 3, font)
await display.show()
38 changes: 38 additions & 0 deletions website/docs/devices/boards.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,44 @@
"url": "https://github.com/esp-rs/esp-rust-board",
"img": "https://microsoft.github.io/jacdac-docs/images/devices/espressif/esp32c3rustdevkitv12a.catalog.jpg"
},
"esp32c3_supermini": {
"$description": "A super tiny ESP32-C3 board.",
"$fwUrl": "https://github.com/microsoft/devicescript-esp32/releases/latest/download/devicescript-esp32c3-esp32c3_supermini-0x0.bin",
"$schema": "https://raw.githubusercontent.com/microsoft/devicescript-esp32/main/boards/esp32deviceconfig.schema.json",
"$services": [
{
"name": "buttonBOOT",
"pin": 9,
"service": "button"
}
],
"archId": "esp32c3",
"devName": "ESP32-C3 SuperMini",
"i2c": {
"pinSCL": 7,
"pinSDA": 6
},
"id": "esp32c3_supermini",
"led": {
"isMono": true,
"pin": 8
},
"log": {
"pinTX": 21
},
"pins": {
"P0": 0,
"P1": 1,
"P10": 10,
"P2": 2,
"P20": 20,
"P3": 3,
"P4": 4,
"P5": 5
},
"productId": "0x31606c1c",
"url": "https://banggood.com/ESP32-C3-Development-Board-ESP32-SuperMini-WiFi-Bluetooth-Mini-Module-p-1997449.html"
},
"esp32s2_bare": {
"$description": "A bare ESP32-S2 board without any pin functions.",
"$fwUrl": "https://github.com/microsoft/devicescript-esp32/releases/latest/download/devicescript-esp32s2-esp32s2_bare-0x1000.bin",
Expand Down
4 changes: 4 additions & 0 deletions website/docs/devices/esp32/adafruit-feather-esp32-s2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ A S2 Feather from Adafruit. (untested)
- I2C on SDA/SCL using Qwiic connector
- WS2812B RGB LED on pin 33 (use [setStatusLight](/developer/status-light) to control)
- Serial logging on pin 43 at 115200 8N1

{@import optional ./adafruit-feather-esp32-s2-features.mdp}


{@import optional ./adafruit-feather-esp32-s2-services.mdp}


## Stores

- [https://www.adafruit.com/product/5000](https://www.adafruit.com/product/5000)
Expand Down
4 changes: 4 additions & 0 deletions website/docs/devices/esp32/adafruit-qt-py-c3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ A tiny ESP32-C3 board.
- I2C on SDA_D4/SCL_D5 using Qwiic connector
- WS2812B RGB LED on pin 2 (use [setStatusLight](/developer/status-light) to control)
- Serial logging on pin TX_D6 at 115200 8N1

{@import optional ./adafruit-qt-py-c3-features.mdp}

- Service: buttonBOOT (button)

{@import optional ./adafruit-qt-py-c3-services.mdp}


## Stores

- [https://www.adafruit.com/product/5405](https://www.adafruit.com/product/5405)
Expand Down
4 changes: 4 additions & 0 deletions website/docs/devices/esp32/esp32-bare.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ Bare ESP32 without any default functions for pins.

## Features


{@import optional ./esp32-bare-features.mdp}


{@import optional ./esp32-bare-services.mdp}


:::caution

I2C pins are not [configured](/developer/board-configuration).
Expand Down
4 changes: 4 additions & 0 deletions website/docs/devices/esp32/esp32-c3fh4-rgb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ A tiny ESP32-C3 board with 5x5 LED array.
- I2C on 0/1 using Qwiic connector
- LED on pin 10 (use [setStatusLight](/developer/status-light) to control)
- Serial logging on pin 21 at 115200 8N1

{@import optional ./esp32-c3fh4-rgb-features.mdp}

- Service: buttonBOOT (button)

{@import optional ./esp32-c3fh4-rgb-services.mdp}


## Stores

- [https://github.com/01Space/ESP32-C3FH4-RGB](https://github.com/01Space/ESP32-C3FH4-RGB)
Expand Down
4 changes: 4 additions & 0 deletions website/docs/devices/esp32/esp32-devkit-c.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ There are currently issues with serial chip on these, best avoid. ESP32-DevKitC
## Features

- LED on pin 2 (use [setStatusLight](/developer/status-light) to control)

{@import optional ./esp32-devkit-c-features.mdp}

- Service: buttonIO0 (button)

{@import optional ./esp32-devkit-c-services.mdp}


:::caution

I2C pins are not [configured](/developer/board-configuration).
Expand Down
4 changes: 4 additions & 0 deletions website/docs/devices/esp32/esp32c3-bare.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ A bare ESP32-C3 board without any pin functions.
## Features

- Serial logging on pin P21 at 115200 8N1

{@import optional ./esp32c3-bare-features.mdp}

- Service: buttonBOOT (button)

{@import optional ./esp32c3-bare-services.mdp}


:::caution

I2C pins are not [configured](/developer/board-configuration).
Expand Down
4 changes: 4 additions & 0 deletions website/docs/devices/esp32/esp32c3-rust-devkit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ A ESP32-C3 dev-board from Espressif with IMU and Temp/Humidity sensor, originall
- I2C on 10/8 using Header connector
- WS2812B RGB LED on pin 2 (use [setStatusLight](/developer/status-light) to control)
- Serial logging on pin P21 at 115200 8N1

{@import optional ./esp32c3-rust-devkit-features.mdp}

- Service: buttonBOOT (button)

{@import optional ./esp32c3-rust-devkit-services.mdp}


## Stores

- [https://github.com/esp-rs/esp-rust-board](https://github.com/esp-rs/esp-rust-board)
Expand Down
117 changes: 117 additions & 0 deletions website/docs/devices/esp32/esp32c3-supermini.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
description: ESP32-C3 SuperMini
---
# ESP32-C3 SuperMini


A super tiny ESP32-C3 board.


## Features

- I2C on 6/7
- LED on pin 8 (use [setStatusLight](/developer/status-light) to control)
- Serial logging on pin 21 at 115200 8N1

{@import optional ./esp32c3-supermini-features.mdp}

- Service: buttonBOOT (button)

{@import optional ./esp32c3-supermini-services.mdp}


## Stores

- [https://banggood.com/ESP32-C3-Development-Board-ESP32-SuperMini-WiFi-Bluetooth-Mini-Module-p-1997449.html](https://banggood.com/ESP32-C3-Development-Board-ESP32-SuperMini-WiFi-Bluetooth-Mini-Module-p-1997449.html)

## Pins

| pin name | hardware id | features |
|:---------|:------------|---------:|
| **P0** | GPIO0 | analogIn, io |
| **P1** | GPIO1 | analogIn, io |
| **P10** | GPIO10 | io |
| **P2** | GPIO2 | analogIn, boot, io |
| **P20** | GPIO20 | bootUart, io |
| **P3** | GPIO3 | analogIn, io |
| **P4** | GPIO4 | analogIn, debug, io |
| **P5** | GPIO5 | debug, io |
| **$services.buttonBOOT[0].pin** | GPIO9 | $services.buttonBOOT[0].pin, boot, io |
| **i2c.pinSCL** | GPIO7 | i2c.pinSCL, debug, io |
| **i2c.pinSDA** | GPIO6 | i2c.pinSDA, debug, io |
| **led.pin** | GPIO8 | led.pin, boot, io |
| **log.pinTX** | GPIO21 | log.pinTX, bootUart, io |



## DeviceScript import


You must add this import statement to load
the pinout configuration for this device.

In [Visual Studio Code](/getting-started/vscode),
click the **wand** icon on the file menu and
select "ESP32-C3 SuperMini".

```ts
import { pins, board } from "@dsboard/esp32c3_supermini"
```

{@import optional ./esp32c3-supermini-examples.mdp}

## Firmware update

In Visual Studio Code,
select **DeviceScript: Flash Firmware...** from the command palette.

Run this [command line](/api/cli) command and follow the instructions.

```bash
devicescript flash --board esp32c3_supermini
```


- [Firmware](https://github.com/microsoft/devicescript-esp32/releases/latest/download/devicescript-esp32c3-esp32c3_supermini-0x0.bin)

## Configuration

```json title="esp32c3_supermini.json"
{
"$schema": "https://raw.githubusercontent.com/microsoft/devicescript-esp32/main/boards/esp32deviceconfig.schema.json",
"id": "esp32c3_supermini",
"devName": "ESP32-C3 SuperMini",
"productId": "0x31606c1c",
"$description": "A super tiny ESP32-C3 board.",
"archId": "esp32c3",
"url": "https://banggood.com/ESP32-C3-Development-Board-ESP32-SuperMini-WiFi-Bluetooth-Mini-Module-p-1997449.html",
"$services": [
{
"name": "buttonBOOT",
"pin": 9,
"service": "button"
}
],
"i2c": {
"pinSCL": 7,
"pinSDA": 6
},
"led": {
"isMono": true,
"pin": 8
},
"log": {
"pinTX": 21
},
"pins": {
"P0": 0,
"P1": 1,
"P10": 10,
"P2": 2,
"P20": 20,
"P3": 3,
"P4": 4,
"P5": 5
}
}
```
4 changes: 4 additions & 0 deletions website/docs/devices/esp32/esp32s2-bare.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ A bare ESP32-S2 board without any pin functions.
## Features

- Serial logging on pin P43 at 115200 8N1

{@import optional ./esp32s2-bare-features.mdp}


{@import optional ./esp32s2-bare-services.mdp}


:::caution

I2C pins are not [configured](/developer/board-configuration).
Expand Down
Loading

0 comments on commit 11d1f3d

Please sign in to comment.