71 lines
1.4 KiB
C++
71 lines
1.4 KiB
C++
#ifndef MCOPY_PROJECTOR
|
|
#define MCOPY_PROJECTOR
|
|
|
|
#include <Arduino.h>
|
|
#include <AccelStepper.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 McopyProjector {
|
|
|
|
private:
|
|
|
|
AccelStepper _takeup;
|
|
AccelStepper _feed;
|
|
|
|
uint16_t _motorSteps = 1600; //microstepped
|
|
uint8_t _frames = 8;
|
|
uint16_t _stepsPerFrame = 25; //round(_motorSteps / _frames);
|
|
uint8_t _mode = 1;
|
|
float _speed = 2000.0;
|
|
|
|
int64_t _posTakeup = 0;
|
|
int64_t _posFeed = 0;
|
|
|
|
|
|
uint8_t _takeupSettingA = 4;
|
|
uint8_t _takeupSettingB = 5;
|
|
uint8_t _feedSettingA = 8;
|
|
uint8_t _feedSettingB = 9;
|
|
|
|
bool _dir = true;
|
|
|
|
bool _running = false;
|
|
bool _adjusting = false;
|
|
|
|
long readVcc();
|
|
long analogReadAccurate (int pin);
|
|
long analogReadAccurateAverage (int pin);
|
|
|
|
public:
|
|
|
|
McopyProjector(AccelStepper takeup, AccelStepper feed, uint8_t takeupSettingA, uint8_t takeupSettingB, uint8_t feedSettingA, uint8_t feedSettingB);
|
|
void begin();
|
|
//0 = takeup, 1 = feed
|
|
void adjust(uint8_t motor, int64_t steps);
|
|
void adjustBoth(int64_t steps);
|
|
//true = forward, false = back
|
|
void frame(bool dir);
|
|
void setDirection(bool dir);
|
|
void setStepperMode(uint8_t mode);
|
|
void loop();
|
|
void home();
|
|
|
|
};
|
|
|
|
#endif |