Set mode of stepper.

This commit is contained in:
mmcwilliams 2023-08-30 10:52:23 -04:00
parent 373a0ef295
commit 261bfa219c
2 changed files with 13 additions and 5 deletions

View File

@ -50,7 +50,8 @@ void IteadDualStepperShield::_micro (uint8_t motor) {
void IteadDualStepperShield::_single (uint8_t motor) {
uint8_t stepPin = motor == 0 ? _stepA : _stepB;
uint32_t usStep = motor == 0 ? _usStepA : _usStepB;
for (uint8_t i = 0; i < _microsteps; i++) {
uint8_t mode = motor == 0 ? _modeA : _modeB;
for (uint8_t i = 0; i < mode; i++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(usStep);
digitalWrite(stepPin, LOW);

View File

@ -22,7 +22,9 @@
class IteadDualStepperShield {
private:
const uint8_t _microsteps = 8; //8 or 16
const uint8_t _directionA = 3;
const uint8_t _directionB = 7;
const uint8_t _stepA = 2;
@ -33,14 +35,19 @@ class IteadDualStepperShield {
const uint8_t _settingsB1 = 8;
const uint8_t _settingsB2 = 9;
volatile uint32_t _usStepA = 300;
volatile uint32_t _usStepB = 300;
//const uint8_t _microsteps = 8; //8 or 16
volatile uint8_t _modeA = 1; //1, 2, 4, or 8
volatile uint8_t _modeB = 1;
void _single(uint8_t motor);
void _micro(uint8_t motor);
void _both();
uint32_t _usStepA = 300;
uint32_t _usStepB = 300;
public:
IteadDualStepperShield();
uint16_t revsteps = 200; // # steps per revolution