mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-08 08:53:40 +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
+4
-4
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"tinygo.org/x/drivers"
|
||||
"tinygo.org/x/drivers/internal/legacy"
|
||||
"tinygo.org/x/drivers/internal/pin"
|
||||
)
|
||||
|
||||
// Device wraps a GPIO connection to a buzzer.
|
||||
@@ -16,7 +16,7 @@ type Device struct {
|
||||
}
|
||||
|
||||
// New returns a new buzzer driver given which pin to use
|
||||
func New(pin legacy.PinOutput) Device {
|
||||
func New(pin pin.Output) Device {
|
||||
return Device{
|
||||
pin: pin.Set,
|
||||
High: false,
|
||||
@@ -26,14 +26,14 @@ func New(pin legacy.PinOutput) Device {
|
||||
|
||||
// On sets the buzzer to a high state.
|
||||
func (l *Device) On() (err error) {
|
||||
l.pin(true)
|
||||
l.pin.High()
|
||||
l.High = true
|
||||
return
|
||||
}
|
||||
|
||||
// Off sets the buzzer to a low state.
|
||||
func (l *Device) Off() (err error) {
|
||||
l.pin(false)
|
||||
l.pin.Low()
|
||||
l.High = false
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user