apply @gen2thomas suggestions

This commit is contained in:
Patricio Whittingslow
2025-09-16 09:26:00 -03:00
parent 3cd6afb84c
commit 8d3cac8322
13 changed files with 77 additions and 67 deletions
+13 -13
View File
@@ -25,14 +25,14 @@ type Config struct {
}
type Device struct {
bus *machine.SPI
cs drivers.PinOutput
dc drivers.PinOutput
rst drivers.PinOutput
busy drivers.PinInput
config func()
buffer []uint8
rotation Rotation
bus *machine.SPI
cs drivers.PinOutput
dc drivers.PinOutput
rst drivers.PinOutput
busy drivers.PinInput
configurePins func()
buffer []uint8
rotation Rotation
}
type Rotation uint8
@@ -90,7 +90,7 @@ func New(bus *machine.SPI, csPin, dcPin, rstPin legacy.PinOutput, busyPin legacy
dc: dcPin.Set,
rst: rstPin.Set,
busy: busyPin.Get,
config: func() {
configurePins: func() {
legacy.ConfigurePinOut(csPin)
legacy.ConfigurePinOut(dcPin)
legacy.ConfigurePinOut(rstPin)
@@ -100,10 +100,10 @@ func New(bus *machine.SPI, csPin, dcPin, rstPin legacy.PinOutput, busyPin legacy
}
func (d *Device) LDirInit(cfg Config) {
if d.config == nil {
if d.configurePins == nil {
panic(legacy.ErrConfigBeforeInstantiated)
}
d.config()
d.configurePins()
d.bus.Configure(machine.SPIConfig{
Frequency: 2000000,
@@ -159,10 +159,10 @@ func (d *Device) LDirInit(cfg Config) {
}
func (d *Device) HDirInit(cfg Config) {
if d.config == nil {
if d.configurePins == nil {
panic(legacy.ErrConfigBeforeInstantiated)
}
d.config()
d.configurePins()
d.bus.Configure(machine.SPIConfig{
Frequency: 2000000,