Skip to content

Commit

Permalink
added waveshare shield
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 15, 2023
1 parent 6143430 commit 2190c91
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/drivers/src/index.ts
Expand Up @@ -20,5 +20,6 @@ export * from "./accelerometer"
export * from "./esp32c3fh4rgb"
export * from "./picobricks"
export * from "./xiaoexpansionboard"
export * from "./wavesharepicolcd114"

configureHardware({ scanI2C: false })
52 changes: 52 additions & 0 deletions packages/drivers/src/wavesharepicolcd114.ts
@@ -0,0 +1,52 @@
import { startGamepad } from "@devicescript/servers"
import { spi } from "@devicescript/spi"
import { pins } from "@dsboard/pico_w"
import * as ds from "@devicescript/core"
import { ST7789Driver } from "@devicescript/drivers"
import { Image } from "@devicescript/graphics"

/**
* Driver for WaveShare Pico-LCD-1.14 inch.
*
* @see https://www.waveshare.com/pico-lcd-1.14.htm
* @devsPart WaveShare Pico LCD114 for Raspberry Pi Pico
* @devsWhenUsed only start services which are used!
*/
export class WaveSharePicoLCD114 {
constructor() {}

startGamepad() {
return startGamepad({
pinA: pins.GP15,
pinB: pins.GP17,
pinDown: pins.GP18,
pinLeft: pins.GP16,
pinSelect: pins.GP3, // middle
pinRight: pins.GP20,
pinUp: pins.GP2,
})
}

async startDisplay() {
spi.configure({
mosi: pins.GP11,
sck: pins.GP10,
hz: 8_000_000,
})

pins.GP13.setMode(ds.GPIOMode.OutputHigh) // BL

const d = new ST7789Driver(Image.alloc(240, 136, 4), {
dc: pins.GP8,
cs: pins.GP9,
reset: pins.GP12,
// frmctr1: 0x0e_14_ff,
flip: false,
spi: spi,
offX: 40,
offY: 53,
})
await d.init()
return d
}
}
9 changes: 9 additions & 0 deletions vscode/src/server-info.json
Expand Up @@ -336,6 +336,15 @@
"XiaoExpansionBoard": "@devicescript/drivers"
},
"snippet": "const shield = new XiaoExpansionBoard()\n"
},
{
"label": "WaveShare Pico LCD114 for Raspberry Pi Pico",
"detail": "Driver for WaveShare Pico-LCD-1.14 inch.\r",
"startName": "WaveSharePicoLCD114",
"imports": {
"WaveSharePicoLCD114": "@devicescript/drivers"
},
"snippet": "const shield = new WaveSharePicoLCD114()\n"
}
]
}
10 changes: 6 additions & 4 deletions website/docs/devices/shields/index.mdx
Expand Up @@ -3,6 +3,8 @@ title: Shields
---

import xiaoUrl from "@site/static/img/shields/xiao-expansion-board.jpg"
import waveUrl from "@site/static/img/shields/waveshare-pico-lcd-114.png"
import picoUrl from "@site/static/img/shields/pico-bricks.jpg"
import DeviceCard from "@site/src/components/DeviceCard"

# Shields
Expand All @@ -18,16 +20,16 @@ DeviceScript provides support for a few shield "out of box" but more can be cont
/>

- <DeviceCard
image="https://camo.githubusercontent.com/87b630c1000c12fe6919768cfb73ab8122ec26cfec0f2029ca16b3edf01b022e/68747470733a2f2f6b73722d7567632e696d6769782e6e65742f6173736574732f3033362f3934392f3333332f31396434653833373031393061353662653133383938333264333434383736665f6f726967696e616c2e6a70673f69786c69623d72622d342e302e3226773d363830266669743d6d617826763d31363439363733393835266769662d713d353026713d393226733d6266326338666635323763643036633665303231646262656264353038383762"
image={picoUrl}
href="/devices/shields/pico-bricks"
title="Pico Bricks"
description="For Raspberry Pi Pico and Pico-W"
/>

- <DeviceCard
image="https://github.com/mmoskal/devicescript-waveshare-pico-lcd/blob/main/assets/pico-lcd-114.png?raw=true"
href="/devices/shields/waveshare-pico-led"
title="WaveShare Pico Led"
image={waveUrl}
href="/devices/shields/waveshare-pico-lcd-114"
title="WaveShare Pico LCD 114"
description="For Raspberry Pi Pico and Pico-W"
/>

Expand Down
2 changes: 1 addition & 1 deletion website/docs/devices/shields/pico-bricks.mdx
Expand Up @@ -7,7 +7,7 @@ title: Pico Bricks
- Device: [Raspberry Pi Pico W](/devices/rp2040/pico-w)
- [Home](https://picobricks.com/)

![PicoBricks image](https://camo.githubusercontent.com/87b630c1000c12fe6919768cfb73ab8122ec26cfec0f2029ca16b3edf01b022e/68747470733a2f2f6b73722d7567632e696d6769782e6e65742f6173736574732f3033362f3934392f3333332f31396434653833373031393061353662653133383938333264333434383736665f6f726967696e616c2e6a70673f69786c69623d72622d342e302e3226773d363830266669743d6d617826763d31363439363733393835266769662d713d353026713d393226733d6266326338666635323763643036633665303231646262656264353038383762)
![PicoBricks image](/img/shields/pico-bricks.jpg)

## DeviceScript import

Expand Down
26 changes: 26 additions & 0 deletions website/docs/devices/shields/waveshare-pico-lcd-114.mdx
@@ -0,0 +1,26 @@
---
title: WaveShare Pico-LCD
---

# WaveShare Pico-LCD

- Device: [Raspberry Pi Pico W](/devices/rp2040/pico-w)
- [Home](https://www.waveshare.com/pico-lcd-1.14.htm)

![WaveShare Image](/img/shields/waveshare-pico-lcd-114.png)

## DeviceScript import

You must import `WaveSharePicoLCD114` to access the shield services.

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

```ts
import { WaveSharePicoLCD114 } from "@devicescript/drivers"
const shield = new WaveSharePicoLCD114()

const gamepad = await shield.startGamepad()
const display = await shield.startDisplay()
```
11 changes: 0 additions & 11 deletions website/docs/devices/shields/waveshare-pico-led.mdx

This file was deleted.

9 changes: 4 additions & 5 deletions website/docs/devices/shields/xiao-expansion-board.mdx
Expand Up @@ -2,21 +2,20 @@
title: Xiao ESP32-C3 Expansion Board
---

import xiaoUrl from "@site/static/img/shields/xiao-expansion-board.jpg"

# Seeed Xiao ESP32-C3 Expansion board

<img src={xiaoUrl} alt="Photograph of shield" style={{ width: "20rem" }} />

- Device: [Seeed Xiao ESP32-C3](/devices/esp32/seeed-xiao-esp32c3) or [Adafruit QT Py C3](/devices/esp32/adafruit-qt-py-c3)
- [Home](https://wiki.seeedstudio.com/Seeeduino-XIAO-Expansion-Board/)


![Photograph of shield](/img/shields/xiao-expansion-board.jpg)

## DeviceScript import

You must import `XiaoExpansionBoard` to access the shield services.

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

```ts
Expand Down
Binary file added website/static/img/shields/pico-bricks.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2190c91

Please sign in to comment.