revision: modify proposed pin HAL.

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2025-09-16 20:33:50 +02:00
parent f55c0b1853
commit dcf53ac04a
38 changed files with 554 additions and 554 deletions
+15 -15
View File
@@ -10,7 +10,7 @@ import (
"errors"
"tinygo.org/x/drivers"
"tinygo.org/x/drivers/internal/legacy"
"tinygo.org/x/drivers/internal/pin"
"tinygo.org/x/drivers/pixel"
)
@@ -39,10 +39,10 @@ type Device = DeviceOf[pixel.RGB565BE]
// formats.
type DeviceOf[T Color] struct {
bus drivers.SPI
dcPin drivers.PinOutput
resetPin drivers.PinOutput
csPin drivers.PinOutput
blPin drivers.PinOutput
dcPin pin.OutputFunc
resetPin pin.OutputFunc
csPin pin.OutputFunc
blPin pin.OutputFunc
width int16
height int16
columnOffset int16
@@ -65,17 +65,17 @@ type Config struct {
}
// New creates a new ST7735 connection. The SPI wire must already be configured.
func New(bus drivers.SPI, resetPin, dcPin, csPin, blPin legacy.PinOutput) Device {
func New(bus drivers.SPI, resetPin, dcPin, csPin, blPin pin.Output) Device {
return NewOf[pixel.RGB565BE](bus, resetPin, dcPin, csPin, blPin)
}
// NewOf creates a new ST7735 connection with a particular pixel format. The SPI
// wire must already be configured.
func NewOf[T Color](bus drivers.SPI, resetPin, dcPin, csPin, blPin legacy.PinOutput) DeviceOf[T] {
legacy.ConfigurePinOut(dcPin)
legacy.ConfigurePinOut(resetPin)
legacy.ConfigurePinOut(csPin)
legacy.ConfigurePinOut(blPin)
func NewOf[T Color](bus drivers.SPI, resetPin, dcPin, csPin, blPin pin.Output) DeviceOf[T] {
pin.ConfigureOutput(dcPin)
pin.ConfigureOutput(resetPin)
pin.ConfigureOutput(csPin)
pin.ConfigureOutput(blPin)
return DeviceOf[T]{
bus: bus,
dcPin: dcPin.Set,
@@ -114,11 +114,11 @@ func (d *DeviceOf[T]) Configure(cfg Config) {
d.batchData = pixel.NewImage[T](int(d.batchLength), 1)
// reset the device
d.resetPin(true)
d.resetPin.High()
time.Sleep(5 * time.Millisecond)
d.resetPin(false)
d.resetPin.Low()
time.Sleep(20 * time.Millisecond)
d.resetPin(true)
d.resetPin.High()
time.Sleep(150 * time.Millisecond)
// Common initialization
@@ -226,7 +226,7 @@ func (d *DeviceOf[T]) Configure(cfg Config) {
d.SetRotation(d.rotation)
d.blPin(true)
d.blPin.High()
}
// Display does nothing, there's no buffer as it might be too big for some boards