mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 21:03:23 +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
+7
-11
@@ -8,7 +8,6 @@ package uc8151 // import "tinygo.org/x/drivers/uc8151"
|
||||
import (
|
||||
"errors"
|
||||
"image/color"
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
@@ -31,10 +30,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
|
||||
@@ -48,12 +47,9 @@ type Device struct {
|
||||
|
||||
type Speed uint8
|
||||
|
||||
// New returns a new uc8151 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 uc8151 driver. Pass in a fully configured SPI bus and pins.
|
||||
// busyPin should be set and input, the others as outputs.
|
||||
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