mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-11 18:33:43 +00:00
revision: modify proposed pin HAL.
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
+17
-17
@@ -11,7 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
"tinygo.org/x/drivers/internal/legacy"
|
||||
"tinygo.org/x/drivers/internal/pin"
|
||||
"tinygo.org/x/drivers/pixel"
|
||||
)
|
||||
|
||||
@@ -31,9 +31,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
|
||||
width int16
|
||||
height int16
|
||||
@@ -49,11 +49,11 @@ type Device struct {
|
||||
type Speed uint8
|
||||
|
||||
// New returns a new uc8151 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,
|
||||
@@ -133,9 +133,9 @@ func (d *Device) Configure(cfg Config) {
|
||||
|
||||
// Reset resets the device
|
||||
func (d *Device) Reset() {
|
||||
d.rst(false)
|
||||
d.rst.Low()
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
d.rst(true)
|
||||
d.rst.High()
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
d.WaitUntilIdle()
|
||||
}
|
||||
@@ -152,18 +152,18 @@ func (d *Device) PowerOn() {
|
||||
|
||||
// SendCommand sends a command to the display
|
||||
func (d *Device) SendCommand(command uint8) {
|
||||
d.dc(false)
|
||||
d.cs(false)
|
||||
d.dc.Low()
|
||||
d.cs.Low()
|
||||
d.bus.Transfer(command)
|
||||
d.cs(true)
|
||||
d.cs.High()
|
||||
}
|
||||
|
||||
// SendData sends a data byte to the display
|
||||
func (d *Device) SendData(data ...uint8) {
|
||||
d.dc(true)
|
||||
d.cs(false)
|
||||
d.dc.High()
|
||||
d.cs.Low()
|
||||
d.bus.Tx(data, nil)
|
||||
d.cs(true)
|
||||
d.cs.High()
|
||||
}
|
||||
|
||||
// SetPixel modifies the internal buffer in a single pixel.
|
||||
|
||||
Reference in New Issue
Block a user