mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-20 22:49:02 +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
@@ -5,7 +5,6 @@ package gc9a01 // import "tinygo.org/x/drivers/gc9a01"
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
@@ -22,10 +21,10 @@ type FrameRate uint8
|
||||
// Device wraps an SPI connection.
|
||||
type Device struct {
|
||||
bus drivers.SPI
|
||||
dcPin machine.Pin
|
||||
resetPin machine.Pin
|
||||
csPin machine.Pin
|
||||
blPin machine.Pin
|
||||
dcPin drivers.Pin
|
||||
resetPin drivers.Pin
|
||||
csPin drivers.Pin
|
||||
blPin drivers.Pin
|
||||
width int16
|
||||
height int16
|
||||
columnOffsetCfg int16
|
||||
@@ -51,12 +50,9 @@ type Config struct {
|
||||
Height int16
|
||||
}
|
||||
|
||||
// New creates a new ST7789 connection. The SPI wire must already be configured.
|
||||
func New(bus drivers.SPI, resetPin, dcPin, csPin, blPin machine.Pin) Device {
|
||||
resetPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
dcPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
csPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
blPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
// New creates a new ST7789 connection. The SPI wire must already be configured, along with the
|
||||
// data/command and reset pins as outputs.
|
||||
func New(bus drivers.SPI, resetPin, dcPin, csPin, blPin drivers.Pin) Device {
|
||||
return Device{
|
||||
bus: bus,
|
||||
resetPin: resetPin,
|
||||
|
||||
Reference in New Issue
Block a user