@@ -3,8 +3,9 @@ package easystepper // import "tinygo.org/x/drivers/easystepper"
33
44import (
55 "errors"
6- "machine"
76 "time"
7+
8+ "tinygo.org/x/drivers"
89)
910
1011// StepMode determines the coil sequence used to perform a single step
@@ -33,7 +34,7 @@ func (sm StepMode) stepCount() uint {
3334// DeviceConfig contains the configuration data for a single easystepper driver
3435type DeviceConfig struct {
3536 // Pin1 ... Pin4 determines the pins to configure and use for the device
36- Pin1 , Pin2 , Pin3 , Pin4 machine .Pin
37+ Pin1 , Pin2 , Pin3 , Pin4 drivers .Pin
3738 // StepCount is the number of steps required to perform a full revolution of the stepper motor
3839 StepCount uint
3940 // RPM determines the speed of the stepper motor in 'Revolutions per Minute'
@@ -46,12 +47,12 @@ type DeviceConfig struct {
4647type DualDeviceConfig struct {
4748 DeviceConfig
4849 // Pin5 ... Pin8 determines the pins to configure and use for the second device
49- Pin5 , Pin6 , Pin7 , Pin8 machine .Pin
50+ Pin5 , Pin6 , Pin7 , Pin8 drivers .Pin
5051}
5152
5253// Device holds the pins and the delay between steps
5354type Device struct {
54- pins [4 ]machine .Pin
55+ pins [4 ]drivers .Pin
5556 stepDelay time.Duration
5657 stepNumber uint8
5758 stepMode StepMode
@@ -68,17 +69,15 @@ func New(config DeviceConfig) (*Device, error) {
6869 return nil , errors .New ("config.StepCount and config.RPM must be > 0" )
6970 }
7071 return & Device {
71- pins : [4 ]machine .Pin {config .Pin1 , config .Pin2 , config .Pin3 , config .Pin4 },
72+ pins : [4 ]drivers .Pin {config .Pin1 , config .Pin2 , config .Pin3 , config .Pin4 },
7273 stepDelay : time .Second * 60 / time .Duration ((config .StepCount * config .RPM )),
7374 stepMode : config .Mode ,
7475 }, nil
7576}
7677
77- // Configure configures the pins of the Device
78+ // Configure does nothing, as it assumes that the pins of the Device have already
79+ // been configured by the user as outputs.
7880func (d * Device ) Configure () {
79- for _ , pin := range d .pins {
80- pin .Configure (machine.PinConfig {Mode : machine .PinOutput })
81- }
8281}
8382
8483// NewDual returns a new dual easystepper driver given 8 pins, number of steps and rpm
0 commit comments