2023-08-23 19:21:50 +00:00
|
|
|
/// Mcopy Projector Class
|
|
|
|
|
|
|
|
#include "McopyProjector.h"
|
|
|
|
#include "IteadDualStepperShield.h"
|
|
|
|
|
|
|
|
McopyProjector::McopyProjector () {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void McopyProjector::begin () {
|
|
|
|
steppers.setup();
|
|
|
|
steppers.setSpeed(0, _speed);
|
|
|
|
steppers.setSpeed(1, _speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void McopyProjector::setDirection (bool dir) {
|
|
|
|
_dir = dir;
|
|
|
|
if (_dir) {
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.setDir(0, FORWARD);
|
|
|
|
steppers.setDir(1, FORWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
} else {
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.setDir(0, BACKWARD);
|
|
|
|
steppers.setDir(1, BACKWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void McopyProjector::frame (bool dir) {
|
|
|
|
if (dir != _dir) {
|
|
|
|
setDirection(dir);
|
|
|
|
}
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.step(FEED, _stepsPerFrame, _dir ? FORWARD : BACKWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
_posTakeup += dir ? _stepsPerFrame : -_stepsPerFrame;
|
|
|
|
_posFeed += dir ? _stepsPerFrame : -_stepsPerFrame;
|
|
|
|
}
|
|
|
|
|
2023-08-25 20:44:28 +00:00
|
|
|
void McopyProjector::adjust(uint8_t motor, int64_t steps) {
|
|
|
|
uint64_t s = abs(steps);
|
2023-08-23 19:21:50 +00:00
|
|
|
if (steps < 0) {
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.setDir(motor, BACKWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
} else {
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.setDir(motor, FORWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
}
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.step(motor, s, _dir ? FORWARD : BACKWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
if (motor == 0) {
|
|
|
|
_posTakeup += steps;
|
|
|
|
} else if (motor == 1) {
|
|
|
|
_posFeed += steps;
|
|
|
|
}
|
2023-08-25 20:44:28 +00:00
|
|
|
//restore set direction after adjustment
|
|
|
|
steppers.setDir(motor, _dir ? FORWARD : BACKWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
}
|
|
|
|
|
2023-08-25 20:44:28 +00:00
|
|
|
void McopyProjector::adjustBoth(int64_t steps) {
|
|
|
|
uint64_t s = abs(steps);
|
2023-08-23 19:21:50 +00:00
|
|
|
if (steps < 0) {
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.setDir(TAKEUP, BACKWARD);
|
|
|
|
steppers.setDir(FEED, BACKWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
} else {
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.setDir(TAKEUP, FORWARD);
|
|
|
|
steppers.setDir(FEED, FORWARD);
|
2023-08-23 19:21:50 +00:00
|
|
|
}
|
2023-08-25 20:44:28 +00:00
|
|
|
steppers.stepBoth(s);
|
2023-08-23 19:21:50 +00:00
|
|
|
_posTakeup += steps;
|
|
|
|
_posFeed += steps;
|
2023-08-25 20:44:28 +00:00
|
|
|
|
|
|
|
//restore set direction after adjustment
|
|
|
|
steppers.setDir(TAKEUP, _dir ? FORWARD : BACKWARD);
|
|
|
|
steppers.setDir(FEED, _dir ? FORWARD : BACKWARD);
|
|
|
|
}
|
|
|
|
|
|
|
|
void McopyProjector::frames(bool dir, uint64_t count) {
|
|
|
|
|
2023-08-23 19:21:50 +00:00
|
|
|
}
|