mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-17 05:13:23 +00:00
legacy.PinOutput->pin.Output and add High+Low methods on drivers.PinOutput and use them in drivers
This commit is contained in:
committed by
deadprogram
parent
2e007a6de7
commit
8ac285e821
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
"tinygo.org/x/drivers/internal/legacy"
|
||||
"tinygo.org/x/drivers/internal/pin"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -33,7 +34,7 @@ type Device struct {
|
||||
type Color 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 {
|
||||
func New(bus drivers.SPI, csPin, dcPin, rstPin pin.Output, busyPin pin.Input) Device {
|
||||
legacy.ConfigurePinOut(csPin)
|
||||
legacy.ConfigurePinOut(dcPin)
|
||||
legacy.ConfigurePinOut(rstPin)
|
||||
@@ -75,9 +76,9 @@ func (d *Device) Configure(cfg Config) {
|
||||
}
|
||||
}
|
||||
|
||||
d.cs(false)
|
||||
d.dc(false)
|
||||
d.rst(false)
|
||||
d.cs.Low()
|
||||
d.dc.Low()
|
||||
d.rst.Low()
|
||||
|
||||
d.Reset()
|
||||
|
||||
@@ -99,9 +100,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)
|
||||
}
|
||||
|
||||
@@ -126,13 +127,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()
|
||||
}
|
||||
|
||||
// SetPixel modifies the internal buffer in a single pixel.
|
||||
|
||||
Reference in New Issue
Block a user