2023-08-23 19:21:50 +00:00
|
|
|
#ifndef MCOPY_PROJECTOR
|
|
|
|
#define MCOPY_PROJECTOR
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
2023-08-29 19:33:51 +00:00
|
|
|
#include <AccelStepper.h>
|
2023-08-23 19:21:50 +00:00
|
|
|
|
2023-08-30 05:18:10 +00:00
|
|
|
/**
|
|
|
|
* 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-08-23 19:21:50 +00:00
|
|
|
class McopyProjector {
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2023-08-29 19:33:51 +00:00
|
|
|
AccelStepper _takeup;
|
|
|
|
AccelStepper _feed;
|
2023-08-23 19:21:50 +00:00
|
|
|
|
2023-08-29 19:33:51 +00:00
|
|
|
uint8_t _motorSteps = 1600; //microstepped
|
2023-08-23 19:21:50 +00:00
|
|
|
uint8_t _frames = 8;
|
2023-08-30 03:33:42 +00:00
|
|
|
uint8_t _stepsPerFrame = 25; //round(_motorSteps / _frames);
|
2023-08-29 19:33:51 +00:00
|
|
|
float _speed = 500.0;
|
2023-08-23 19:21:50 +00:00
|
|
|
|
|
|
|
int64_t _posTakeup = 0;
|
|
|
|
int64_t _posFeed = 0;
|
|
|
|
|
2023-08-25 20:44:28 +00:00
|
|
|
|
2023-08-29 23:48:49 +00:00
|
|
|
uint8_t _takeupSettingA = 4;
|
|
|
|
uint8_t _takeupSettingB = 5;
|
|
|
|
uint8_t _feedSettingA = 8;
|
|
|
|
uint8_t _feedSettingB = 9;
|
2023-08-25 20:44:28 +00:00
|
|
|
|
2023-08-23 19:21:50 +00:00
|
|
|
bool _dir = true;
|
|
|
|
|
2023-08-29 19:33:51 +00:00
|
|
|
bool _running = false;
|
|
|
|
bool _adjusting = false;
|
|
|
|
|
2023-08-23 19:21:50 +00:00
|
|
|
public:
|
|
|
|
|
2023-08-29 23:48:49 +00:00
|
|
|
McopyProjector(AccelStepper takeup, AccelStepper feed, uint8_t takeupSettingA, uint8_t takeupSettingB, uint8_t feedSettingA, uint8_t feedSettingB);
|
2023-08-23 19:21:50 +00:00
|
|
|
void begin();
|
|
|
|
//0 = takeup, 1 = feed
|
2023-08-25 20:44:28 +00:00
|
|
|
void adjust(uint8_t motor, int64_t steps);
|
|
|
|
void adjustBoth(int64_t steps);
|
2023-08-23 19:21:50 +00:00
|
|
|
//true = forward, false = back
|
|
|
|
void frame(bool dir);
|
|
|
|
void setDirection(bool dir);
|
2023-08-29 23:48:49 +00:00
|
|
|
void setStepperMode(uint8_t mode);
|
2023-08-29 19:33:51 +00:00
|
|
|
void loop();
|
2023-08-23 19:21:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|