IteadStudioDualStepperShield/IteadDualStepperShield.h

71 lines
1.5 KiB
C
Raw Permalink Normal View History

2023-03-27 14:17:27 +00:00
#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
**/
2023-03-27 14:17:27 +00:00
class IteadDualStepperShield {
private:
2023-08-30 14:52:23 +00:00
2023-03-27 14:17:27 +00:00
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;
2023-08-30 14:52:23 +00:00
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;
2023-03-27 14:17:27 +00:00
void _single(uint8_t motor);
void _micro(uint8_t motor);
void _both();
public:
2023-08-30 14:52:23 +00:00
2023-03-27 14:17:27 +00:00
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
2023-08-25 16:34:21 +00:00
void step(uint8_t motor, uint64_t steps, uint8_t dir);
void stepBoth(uint64_t steps);
2023-03-27 14:17:27 +00:00
void onestep(uint8_t motor, uint8_t dir);
void setStepperMode (uint8_t motor, uint8_t mode);
2023-03-27 14:17:27 +00:00
void release();
};
#endif