mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-17 05:13:23 +00:00
refactor: add display.Pin interface and use it everywhere that is easy to do so
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
committed by
Yurii Soldak
parent
d02d21ecea
commit
38c606d813
+5
-9
@@ -6,7 +6,6 @@ package ssd1306 // import "tinygo.org/x/drivers/ssd1306"
|
||||
import (
|
||||
"errors"
|
||||
"image/color"
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
@@ -58,9 +57,9 @@ type I2CBus struct {
|
||||
|
||||
type SPIBus struct {
|
||||
wire drivers.SPI
|
||||
dcPin machine.Pin
|
||||
resetPin machine.Pin
|
||||
csPin machine.Pin
|
||||
dcPin drivers.Pin
|
||||
resetPin drivers.Pin
|
||||
csPin drivers.Pin
|
||||
}
|
||||
|
||||
type Buser interface {
|
||||
@@ -81,11 +80,8 @@ func NewI2C(bus drivers.I2C) Device {
|
||||
}
|
||||
}
|
||||
|
||||
// NewSPI creates a new SSD1306 connection. The SPI wire must already be configured.
|
||||
func NewSPI(bus drivers.SPI, dcPin, resetPin, csPin machine.Pin) Device {
|
||||
dcPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
resetPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
csPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
// NewSPI creates a new SSD1306 connection. The SPI wire and pins must already be configured.
|
||||
func NewSPI(bus drivers.SPI, dcPin, resetPin, csPin drivers.Pin) Device {
|
||||
return Device{
|
||||
bus: &SPIBus{
|
||||
wire: bus,
|
||||
|
||||
Reference in New Issue
Block a user