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
+19 -19
View File
@@ -16,7 +16,7 @@ import (
"time"
"tinygo.org/x/drivers"
"tinygo.org/x/drivers/internal/legacy"
"tinygo.org/x/drivers/internal/pin"
)
type Config struct {
@@ -28,9 +28,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
@@ -61,11 +61,11 @@ var lutPartialUpdate = [30]uint8{
}
// New returns a new epd2in9 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,
@@ -99,9 +99,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()
@@ -122,14 +122,14 @@ func (d *Device) Configure(cfg Config) {
d.SendCommand(DATA_ENTRY_MODE_SETTING)
d.SendData(0x03) // X increment; Y increment
d.SetLUT(true)
d.SetLUT.High()
}
// 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)
}
@@ -152,13 +152,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