mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-21 23:19:00 +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
@@ -6,7 +6,6 @@ package epd2in13x // import "tinygo.org/x/drivers/waveshare-epd/epd2in13x"
|
||||
import (
|
||||
"errors"
|
||||
"image/color"
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
@@ -20,10 +19,10 @@ type Config struct {
|
||||
|
||||
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
|
||||
width int16
|
||||
height int16
|
||||
buffer [][]uint8
|
||||
@@ -32,12 +31,9 @@ type Device struct {
|
||||
|
||||
type Color uint8
|
||||
|
||||
// New returns a new epd2in13x driver. Pass in a fully configured SPI bus.
|
||||
func New(bus drivers.SPI, csPin, dcPin, rstPin, busyPin machine.Pin) Device {
|
||||
csPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
dcPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
rstPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
busyPin.Configure(machine.PinConfig{Mode: machine.PinInput})
|
||||
// New returns a new epd2in13x driver. Pass in a fully configured SPI bus and pins.
|
||||
// Busy pin should input, the rest should be output.
|
||||
func New(bus drivers.SPI, csPin, dcPin, rstPin, busyPin drivers.Pin) Device {
|
||||
return Device{
|
||||
bus: bus,
|
||||
cs: csPin,
|
||||
|
||||
Reference in New Issue
Block a user