feature: some additional changes to drivers.Pin HAL for clarity and readability.

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2025-09-20 08:29:32 +02:00
parent 97ed81556b
commit d224b5d648
33 changed files with 139 additions and 171 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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")
}
+1 -1
View File
@@ -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() {