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
+18 -18
View File
@@ -9,7 +9,7 @@ import (
"time"
"tinygo.org/x/drivers"
"tinygo.org/x/drivers/internal/legacy"
"tinygo.org/x/drivers/internal/pin"
)
type Config struct {
@@ -21,9 +21,9 @@ type Config struct {
type Device struct {
bus drivers.SPI
cs drivers.PinOutput
dc drivers.PinOutput
rst drivers.PinOutput
cs pin.OutputFunc
dc pin.OutputFunc
rst pin.OutputFunc
isBusy drivers.PinInput
logicalWidth int16
width int16
@@ -53,11 +53,11 @@ var lutPartialUpdate = [30]uint8{
}
// New returns a new epd2in13x driver. Pass in a fully configured SPI bus.
func New(bus drivers.SPI, csPin, dcPin, rstPin legacy.PinOutput, busyPin legacy.PinInput) Device {
legacy.ConfigurePinOut(csPin)
legacy.ConfigurePinOut(dcPin)
legacy.ConfigurePinOut(rstPin)
legacy.ConfigurePinInput(busyPin)
func New(bus drivers.SPI, csPin, dcPin, rstPin pin.Output, busyPin pin.Input) Device {
pin.ConfigureOutput(csPin)
pin.ConfigureOutput(dcPin)
pin.ConfigureOutput(rstPin)
pin.ConfigureInput(busyPin)
return Device{
bus: bus,
cs: csPin.Set,
@@ -91,9 +91,9 @@ func (d *Device) Configure(cfg Config) {
d.buffer[i] = 0xFF
}
d.cs(false)
d.dc(false)
d.rst(false)
d.cs.Low()
d.dc.Low()
d.rst.Low()
d.Reset()
@@ -119,9 +119,9 @@ func (d *Device) Configure(cfg Config) {
// Reset resets the device
func (d *Device) Reset() {
d.rst(false)
d.rst.Low()
time.Sleep(200 * time.Millisecond)
d.rst(true)
d.rst.High()
time.Sleep(200 * time.Millisecond)
}
@@ -155,13 +155,13 @@ func (d *Device) SendData(data uint8) {
// sendDataCommand sends image data or a command to the screen
func (d *Device) sendDataCommand(isCommand bool, data uint8) {
if isCommand {
d.dc(false)
d.dc.Low()
} else {
d.dc(true)
d.dc.High()
}
d.cs(false)
d.cs.Low()
d.bus.Transfer(data)
d.cs(true)
d.cs.High()
}
// SetLUT sets the look up tables for full or partial updates