mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-15 20:33:39 +00:00
revision: modify proposed pin HAL.
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
"tinygo.org/x/drivers/internal/legacy"
|
||||
"tinygo.org/x/drivers/internal/pin"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -25,9 +25,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
|
||||
@@ -40,11 +40,11 @@ type Device struct {
|
||||
type Rotation uint8
|
||||
|
||||
// New returns a new epd4in2 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,
|
||||
@@ -78,9 +78,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()
|
||||
d.SendCommand(POWER_SETTING)
|
||||
@@ -104,9 +104,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)
|
||||
}
|
||||
|
||||
@@ -145,13 +145,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
|
||||
|
||||
Reference in New Issue
Block a user