Add setStepperMode logic from other project. Will sleep work?
This commit is contained in:
parent
9552d738c2
commit
da46928dee
|
@ -0,0 +1 @@
|
|||
*.DS_Store
|
|
@ -10,6 +10,12 @@ void IteadDualStepperShield::setup () {
|
|||
pinMode(_stepB, OUTPUT);
|
||||
setDir(0, 1);
|
||||
setDir(1, 1);
|
||||
pinMode(_settingsA1, OUTPUT);
|
||||
pinMode(_settingsA2, OUTPUT);
|
||||
pinMode(_settingsB1, OUTPUT);
|
||||
pinMode(_settingsB2, OUTPUT);
|
||||
setStepperMode(0, 1);
|
||||
setStepperMode(1, 1);
|
||||
}
|
||||
|
||||
void IteadDualStepperShield::setDir (uint8_t motor, uint8_t dir) {
|
||||
|
@ -78,4 +84,27 @@ void IteadDualStepperShield::stepBoth (uint64_t steps) {
|
|||
for (int i = 0; i < steps; i++) {
|
||||
_both();
|
||||
}
|
||||
}
|
||||
|
||||
void IteadDualStepperShield::setStepperMode (uint8_t motor, uint8_t mode) {
|
||||
uint8_t pin1 = motor == 0 ? _settingsA1 : _settingsB1;
|
||||
uint8_t pin2 = motor == 0 ? _settingsA2 : _settingsB2;
|
||||
switch (mode) {
|
||||
case 1 :
|
||||
digitalWrite(pin1, LOW);
|
||||
digitalWrite(pin2, LOW);
|
||||
break;
|
||||
case 2 :
|
||||
digitalWrite(pin1, HIGH);
|
||||
digitalWrite(pin2, LOW);
|
||||
break;
|
||||
case 4 :
|
||||
digitalWrite(pin1, LOW);
|
||||
digitalWrite(pin2, HIGH);
|
||||
break;
|
||||
case 8 :
|
||||
digitalWrite(pin1, HIGH);
|
||||
digitalWrite(pin2, HIGH);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,23 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
/**
|
||||
* D2 X Step
|
||||
* D3 X Direction
|
||||
* D4 X MS1 setting
|
||||
* D5 X MS2 setting
|
||||
* D6 Y Step
|
||||
* D7 Y Direction
|
||||
* D8 Y MS1 setting
|
||||
* D9 Y MS2 setting
|
||||
*
|
||||
* MS1(X/Y) MS2(X/Y) Description
|
||||
* L L Full step
|
||||
* H L Half step
|
||||
* L H Quarter step
|
||||
* H H Eighth STEP
|
||||
**/
|
||||
|
||||
class IteadDualStepperShield {
|
||||
private:
|
||||
const uint8_t _microsteps = 8; //8 or 16
|
||||
|
@ -11,6 +28,11 @@ class IteadDualStepperShield {
|
|||
const uint8_t _stepA = 2;
|
||||
const uint8_t _stepB = 6;
|
||||
|
||||
const uint8_t _settingsA1 = 4;
|
||||
const uint8_t _settingsA2 = 5;
|
||||
const uint8_t _settingsB1 = 8;
|
||||
const uint8_t _settingsB2 = 9;
|
||||
|
||||
void _single(uint8_t motor);
|
||||
void _micro(uint8_t motor);
|
||||
void _both();
|
||||
|
@ -34,6 +56,7 @@ class IteadDualStepperShield {
|
|||
void step(uint8_t motor, uint64_t steps, uint8_t dir);
|
||||
void stepBoth(uint64_t steps);
|
||||
void onestep(uint8_t motor, uint8_t dir);
|
||||
void setStepperMode (uint8_t motor, uint8_t mode);
|
||||
|
||||
void release();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue