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:
deadprogram
2025-03-16 17:35:09 +01:00
committed by Yurii Soldak
parent d02d21ecea
commit 38c606d813
28 changed files with 164 additions and 236 deletions
+5 -9
View File
@@ -5,7 +5,6 @@ package ssd1331 // import "tinygo.org/x/drivers/ssd1331"
import (
"image/color"
"machine"
"errors"
"time"
@@ -19,9 +18,9 @@ type Rotation uint8
// Device wraps an SPI connection.
type Device struct {
bus drivers.SPI
dcPin machine.Pin
resetPin machine.Pin
csPin machine.Pin
dcPin drivers.Pin
resetPin drivers.Pin
csPin drivers.Pin
width int16
height int16
batchLength int16
@@ -35,11 +34,8 @@ type Config struct {
Height int16
}
// New creates a new SSD1331 connection. The SPI wire must already be configured.
func New(bus drivers.SPI, resetPin, dcPin, csPin machine.Pin) Device {
dcPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
resetPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
csPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
// New creates a new SSD1331 connection. The SPI wire and pins must already be configured.
func New(bus drivers.SPI, resetPin, dcPin, csPin drivers.Pin) Device {
return Device{
bus: bus,
dcPin: dcPin,