revision: modify proposed pin HAL.

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2025-09-16 20:33:50 +02:00
parent f55c0b1853
commit dcf53ac04a
38 changed files with 554 additions and 554 deletions
+5 -6
View File
@@ -4,19 +4,18 @@ package buzzer // import "tinygo.org/x/drivers/buzzer"
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.
type Device struct {
pin drivers.PinOutput
pin pin.OutputFunc
High bool
BPM float64
}
// 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 +25,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
}