mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-20 06:28:59 +00:00
refactor: add display.Pin interface and use it everywhere that is easy to do so
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
committed by
Yurii Soldak
parent
d02d21ecea
commit
38c606d813
@@ -5,7 +5,6 @@ package epd2in66b
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
@@ -19,18 +18,18 @@ const (
|
||||
const Baudrate = 4_000_000 // 4 MHz
|
||||
|
||||
type Config struct {
|
||||
ResetPin machine.Pin
|
||||
DataPin machine.Pin
|
||||
ChipSelectPin machine.Pin
|
||||
BusyPin machine.Pin
|
||||
ResetPin drivers.Pin
|
||||
DataPin drivers.Pin
|
||||
ChipSelectPin drivers.Pin
|
||||
BusyPin drivers.Pin
|
||||
}
|
||||
|
||||
type Device struct {
|
||||
bus drivers.SPI
|
||||
cs machine.Pin
|
||||
dc machine.Pin
|
||||
rst machine.Pin
|
||||
busy machine.Pin
|
||||
cs drivers.Pin
|
||||
dc drivers.Pin
|
||||
rst drivers.Pin
|
||||
busy drivers.Pin
|
||||
|
||||
blackBuffer []byte
|
||||
redBuffer []byte
|
||||
@@ -50,18 +49,14 @@ func New(bus drivers.SPI) Device {
|
||||
}
|
||||
}
|
||||
|
||||
// Configure configures the device and its pins.
|
||||
// Configure configures the device. Note that pins should already
|
||||
// be configured. Busy pin should be input, the rest should be output.
|
||||
func (d *Device) Configure(c Config) error {
|
||||
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})
|
||||
d.rst.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
d.busy.Configure(machine.PinConfig{Mode: machine.PinInput})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user