Skip to content

Commit

Permalink
make defaults pico specific
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrichner-oviva committed May 3, 2024
1 parent d0e4400 commit f668370
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 34 deletions.
2 changes: 1 addition & 1 deletion examples/waveshare-epd/epd2in66b/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
println("started")

display := epd2in66b.New(machine.SPI1)
err := display.Configure(epd2in66b.Config{})
err := display.Configure(epd2in66b.DefaultConfig)
if err != nil {
panic(err)
}
Expand Down
38 changes: 5 additions & 33 deletions waveshare-epd/epd2in66b/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import (
const (
displayWidth = 152
displayHeight = 296

// using numerical values to enable generic tinygo compilation
dcPin = 8
csPin = 9
rstPin = 12
busyPin = 13
)

const Baudrate = 4_000_000 // 4 MHz
Expand Down Expand Up @@ -50,40 +44,18 @@ func New(bus drivers.SPI) Device {
bufLen := pixelCount / 8

return Device{
bus: bus,
cs: csPin,
dc: dcPin,
rst: rstPin,
busy: busyPin,

bus: bus,
blackBuffer: make([]byte, bufLen),
redBuffer: make([]byte, bufLen),
}
}

// Configure configures the device and its pins. The 'zero' config will fall back to the defaults.
//
// Default pins are:
//
// Data = GP8
// ChipSelect = GP9
// Reset = GP12
// Busy = GP13
func (d *Device) Configure(c Config) error {
if c.ChipSelectPin > 0 {
d.cs = c.ChipSelectPin
}
if c.DataPin > 0 {
d.dc = c.DataPin
}

if c.ResetPin > 0 {
d.rst = c.ResetPin
}

if c.BusyPin > 0 {
d.busy = c.BusyPin
}
d.cs = c.ChipSelectPin
d.dc = c.DataPin
d.rst = c.ResetPin
d.busy = c.BusyPin

d.cs.Configure(machine.PinConfig{Mode: machine.PinOutput})
d.dc.Configure(machine.PinConfig{Mode: machine.PinOutput})
Expand Down
15 changes: 15 additions & 0 deletions waveshare-epd/epd2in66b/dev_pico.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build pico

package epd2in66b

import (
"machine"
)

// DefaultConfig contains the default config for the https://www.waveshare.com/wiki/Pico-ePaper-2.66 module
var DefaultConfig = Config{
ResetPin: machine.GP12,
DataPin: machine.GP8,
ChipSelectPin: machine.GP9,
BusyPin: machine.GP13,
}

0 comments on commit f668370

Please sign in to comment.