IteadStudioDualStepperShield/IteadDualStepperShield.h

71 lines
1.5 KiB
C++

#ifndef IteadDualStepperShield_h
#define IteadDualStepperShield_h
#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 _directionA = 3;
const uint8_t _directionB = 7;
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;
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();
public:
IteadDualStepperShield();
uint16_t revsteps = 200; // # steps per revolution
volatile uint8_t directionA = 1;
volatile uint8_t directionB = 1;
void setup();
void setDir(uint8_t motor, uint8_t dir);
void setSpeed(uint8_t motor, uint16_t speed);
//full
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();
};
#endif