mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-08 17:03:39 +00:00
feature: some additional changes to drivers.Pin HAL for clarity and readability.
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -32,7 +32,7 @@ func (sm StepMode) stepCount() uint {
|
||||
|
||||
// Device holds the pins and the delay between steps
|
||||
type Device struct {
|
||||
pins [4]drivers.PinOutput
|
||||
pins [4]drivers.PinOutputFunc
|
||||
config func()
|
||||
stepDelay time.Duration
|
||||
stepNumber uint8
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"tinygo.org/x/drivers"
|
||||
)
|
||||
|
||||
func NewCrossPlatform(stepcount, rpm uint, mode StepMode, pins [4]drivers.PinOutput) (*Device, error) {
|
||||
func NewCrossPlatform(stepcount, rpm uint, mode StepMode, pins [4]drivers.PinOutputFunc) (*Device, error) {
|
||||
if stepcount == 0 || rpm == 0 {
|
||||
return nil, errors.New("zero rpm and/or stepcount")
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ func New(config DeviceConfig) (*Device, error) {
|
||||
return nil, errors.New("config.StepCount and config.RPM must be > 0")
|
||||
}
|
||||
return &Device{
|
||||
pins: [4]drivers.PinOutput{config.Pin1.Set, config.Pin2.Set, config.Pin3.Set, config.Pin4.Set},
|
||||
pins: [4]drivers.PinOutputFunc{config.Pin1.Set, config.Pin2.Set, config.Pin3.Set, config.Pin4.Set},
|
||||
stepDelay: time.Second * 60 / time.Duration((config.StepCount * config.RPM)),
|
||||
stepMode: config.Mode,
|
||||
config: func() {
|
||||
|
||||
Reference in New Issue
Block a user