Add getDirection() to EndstopCameraShield and fix sloppy bugs in code that were not disabling emitters after actions. Could have caused false positives in behavior so check on the machine

This commit is contained in:
Matt McWilliams 2024-08-03 08:46:46 -04:00
parent 35d832f965
commit 7cecef3de5
6 changed files with 27 additions and 21 deletions

View File

@ -112,7 +112,6 @@ uint32_t EndstopCameraShield::frame() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableCloseEmitter(); _enableCloseEmitter();
_enableOpenEmitter();
//_enableCloseInterrupt(); //_enableCloseInterrupt();
primed = true; primed = true;
} }
@ -124,8 +123,8 @@ uint32_t EndstopCameraShield::frame() {
_motor.step(); _motor.step();
i++; i++;
} }
//_disableCloseInterrupt();
_disableCloseEmitter(); _disableCloseEmitter();
//_disableCloseInterrupt();
return i; return i;
} }
@ -138,7 +137,6 @@ uint32_t EndstopCameraShield::toOpen() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableOpenEmitter(); _enableOpenEmitter();
_enableCloseEmitter();
//_enableOpenInterrupt(); //_enableOpenInterrupt();
primed = true; primed = true;
} }
@ -150,8 +148,8 @@ uint32_t EndstopCameraShield::toOpen() {
_motor.step(); _motor.step();
i++; i++;
} }
//_disableOpenInterrupt();
_disableOpenEmitter(); _disableOpenEmitter();
//_disableOpenInterrupt();
return i; return i;
} }
@ -164,7 +162,6 @@ uint32_t EndstopCameraShield::toClose() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableCloseEmitter(); _enableCloseEmitter();
_enableOpenEmitter();
//_enableCloseInterrupt(); //_enableCloseInterrupt();
primed = true; primed = true;
} }
@ -176,8 +173,8 @@ uint32_t EndstopCameraShield::toClose() {
_motor.step(); _motor.step();
i++; i++;
} }
_disableCloseInterrupt(); _disableCloseEmitter();
//_disableCloseEmitter(); //_disableCloseInterrupt();
return i; return i;
} }
@ -188,6 +185,10 @@ void EndstopCameraShield::setDirection(bool direction) {
} }
} }
bool EndstopCameraShield::getDirection() {
return _direction;
}
bool EndstopCameraShield::isOpened() { bool EndstopCameraShield::isOpened() {
return _isOpened; return _isOpened;
} }

View File

@ -65,6 +65,7 @@ class EndstopCameraShield {
uint32_t toOpen(); uint32_t toOpen();
uint32_t toClose(); uint32_t toClose();
void setDirection(bool direction); void setDirection(bool direction);
bool getDirection();
bool isOpened(); bool isOpened();
bool isClosed(); bool isClosed();
void test(); void test();

View File

@ -112,7 +112,6 @@ uint32_t EndstopCameraShield::frame() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableCloseEmitter(); _enableCloseEmitter();
_enableOpenEmitter();
//_enableCloseInterrupt(); //_enableCloseInterrupt();
primed = true; primed = true;
} }
@ -124,8 +123,8 @@ uint32_t EndstopCameraShield::frame() {
_motor.step(); _motor.step();
i++; i++;
} }
//_disableCloseInterrupt();
_disableCloseEmitter(); _disableCloseEmitter();
//_disableCloseInterrupt();
return i; return i;
} }
@ -138,7 +137,6 @@ uint32_t EndstopCameraShield::toOpen() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableOpenEmitter(); _enableOpenEmitter();
_enableCloseEmitter();
//_enableOpenInterrupt(); //_enableOpenInterrupt();
primed = true; primed = true;
} }
@ -150,8 +148,8 @@ uint32_t EndstopCameraShield::toOpen() {
_motor.step(); _motor.step();
i++; i++;
} }
//_disableOpenInterrupt();
_disableOpenEmitter(); _disableOpenEmitter();
//_disableOpenInterrupt();
return i; return i;
} }
@ -164,7 +162,6 @@ uint32_t EndstopCameraShield::toClose() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableCloseEmitter(); _enableCloseEmitter();
_enableOpenEmitter();
//_enableCloseInterrupt(); //_enableCloseInterrupt();
primed = true; primed = true;
} }
@ -176,8 +173,8 @@ uint32_t EndstopCameraShield::toClose() {
_motor.step(); _motor.step();
i++; i++;
} }
_disableCloseInterrupt(); _disableCloseEmitter();
//_disableCloseEmitter(); //_disableCloseInterrupt();
return i; return i;
} }
@ -188,6 +185,10 @@ void EndstopCameraShield::setDirection(bool direction) {
} }
} }
bool EndstopCameraShield::getDirection() {
return _direction;
}
bool EndstopCameraShield::isOpened() { bool EndstopCameraShield::isOpened() {
return _isOpened; return _isOpened;
} }

View File

@ -65,6 +65,7 @@ class EndstopCameraShield {
uint32_t toOpen(); uint32_t toOpen();
uint32_t toClose(); uint32_t toClose();
void setDirection(bool direction); void setDirection(bool direction);
bool getDirection();
bool isOpened(); bool isOpened();
bool isClosed(); bool isClosed();
void test(); void test();

View File

@ -112,7 +112,6 @@ uint32_t EndstopCameraShield::frame() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableCloseEmitter(); _enableCloseEmitter();
_enableOpenEmitter();
//_enableCloseInterrupt(); //_enableCloseInterrupt();
primed = true; primed = true;
} }
@ -124,8 +123,8 @@ uint32_t EndstopCameraShield::frame() {
_motor.step(); _motor.step();
i++; i++;
} }
//_disableCloseInterrupt();
_disableCloseEmitter(); _disableCloseEmitter();
//_disableCloseInterrupt();
return i; return i;
} }
@ -138,7 +137,6 @@ uint32_t EndstopCameraShield::toOpen() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableOpenEmitter(); _enableOpenEmitter();
_enableCloseEmitter();
//_enableOpenInterrupt(); //_enableOpenInterrupt();
primed = true; primed = true;
} }
@ -150,8 +148,8 @@ uint32_t EndstopCameraShield::toOpen() {
_motor.step(); _motor.step();
i++; i++;
} }
//_disableOpenInterrupt();
_disableOpenEmitter(); _disableOpenEmitter();
//_disableOpenInterrupt();
return i; return i;
} }
@ -164,7 +162,6 @@ uint32_t EndstopCameraShield::toClose() {
while (running) { while (running) {
if (!primed && i > _minSteps) { if (!primed && i > _minSteps) {
_enableCloseEmitter(); _enableCloseEmitter();
_enableOpenEmitter();
//_enableCloseInterrupt(); //_enableCloseInterrupt();
primed = true; primed = true;
} }
@ -176,8 +173,8 @@ uint32_t EndstopCameraShield::toClose() {
_motor.step(); _motor.step();
i++; i++;
} }
_disableCloseInterrupt(); _disableCloseEmitter();
//_disableCloseEmitter(); //_disableCloseInterrupt();
return i; return i;
} }
@ -188,6 +185,10 @@ void EndstopCameraShield::setDirection(bool direction) {
} }
} }
bool EndstopCameraShield::getDirection() {
return _direction;
}
bool EndstopCameraShield::isOpened() { bool EndstopCameraShield::isOpened() {
return _isOpened; return _isOpened;
} }

View File

@ -65,6 +65,7 @@ class EndstopCameraShield {
uint32_t toOpen(); uint32_t toOpen();
uint32_t toClose(); uint32_t toClose();
void setDirection(bool direction); void setDirection(bool direction);
bool getDirection();
bool isOpened(); bool isOpened();
bool isClosed(); bool isClosed();
void test(); void test();