From 7cecef3de5fa396ab416f81db192c67b3a8a83b6 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sat, 3 Aug 2024 08:46:46 -0400 Subject: [PATCH] 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 --- .../EndstopCameraShield/EndstopCameraShield.cpp | 15 ++++++++------- ino/lib/EndstopCameraShield/EndstopCameraShield.h | 1 + ino/mcopy_mitchell_camera/EndstopCameraShield.cpp | 15 ++++++++------- ino/mcopy_mitchell_camera/EndstopCameraShield.h | 1 + ino/mcopy_oxberry_camera/EndstopCameraShield.cpp | 15 ++++++++------- ino/mcopy_oxberry_camera/EndstopCameraShield.h | 1 + 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/ino/lib/EndstopCameraShield/EndstopCameraShield.cpp b/ino/lib/EndstopCameraShield/EndstopCameraShield.cpp index a2b16fa..098e6e0 100644 --- a/ino/lib/EndstopCameraShield/EndstopCameraShield.cpp +++ b/ino/lib/EndstopCameraShield/EndstopCameraShield.cpp @@ -112,7 +112,6 @@ uint32_t EndstopCameraShield::frame() { while (running) { if (!primed && i > _minSteps) { _enableCloseEmitter(); - _enableOpenEmitter(); //_enableCloseInterrupt(); primed = true; } @@ -124,8 +123,8 @@ uint32_t EndstopCameraShield::frame() { _motor.step(); i++; } - //_disableCloseInterrupt(); _disableCloseEmitter(); + //_disableCloseInterrupt(); return i; } @@ -138,7 +137,6 @@ uint32_t EndstopCameraShield::toOpen() { while (running) { if (!primed && i > _minSteps) { _enableOpenEmitter(); - _enableCloseEmitter(); //_enableOpenInterrupt(); primed = true; } @@ -150,8 +148,8 @@ uint32_t EndstopCameraShield::toOpen() { _motor.step(); i++; } - //_disableOpenInterrupt(); _disableOpenEmitter(); + //_disableOpenInterrupt(); return i; } @@ -164,7 +162,6 @@ uint32_t EndstopCameraShield::toClose() { while (running) { if (!primed && i > _minSteps) { _enableCloseEmitter(); - _enableOpenEmitter(); //_enableCloseInterrupt(); primed = true; } @@ -176,8 +173,8 @@ uint32_t EndstopCameraShield::toClose() { _motor.step(); i++; } - _disableCloseInterrupt(); - //_disableCloseEmitter(); + _disableCloseEmitter(); + //_disableCloseInterrupt(); return i; } @@ -188,6 +185,10 @@ void EndstopCameraShield::setDirection(bool direction) { } } +bool EndstopCameraShield::getDirection() { + return _direction; +} + bool EndstopCameraShield::isOpened() { return _isOpened; } diff --git a/ino/lib/EndstopCameraShield/EndstopCameraShield.h b/ino/lib/EndstopCameraShield/EndstopCameraShield.h index 9377f1a..68e0725 100644 --- a/ino/lib/EndstopCameraShield/EndstopCameraShield.h +++ b/ino/lib/EndstopCameraShield/EndstopCameraShield.h @@ -65,6 +65,7 @@ class EndstopCameraShield { uint32_t toOpen(); uint32_t toClose(); void setDirection(bool direction); + bool getDirection(); bool isOpened(); bool isClosed(); void test(); diff --git a/ino/mcopy_mitchell_camera/EndstopCameraShield.cpp b/ino/mcopy_mitchell_camera/EndstopCameraShield.cpp index a2b16fa..098e6e0 100644 --- a/ino/mcopy_mitchell_camera/EndstopCameraShield.cpp +++ b/ino/mcopy_mitchell_camera/EndstopCameraShield.cpp @@ -112,7 +112,6 @@ uint32_t EndstopCameraShield::frame() { while (running) { if (!primed && i > _minSteps) { _enableCloseEmitter(); - _enableOpenEmitter(); //_enableCloseInterrupt(); primed = true; } @@ -124,8 +123,8 @@ uint32_t EndstopCameraShield::frame() { _motor.step(); i++; } - //_disableCloseInterrupt(); _disableCloseEmitter(); + //_disableCloseInterrupt(); return i; } @@ -138,7 +137,6 @@ uint32_t EndstopCameraShield::toOpen() { while (running) { if (!primed && i > _minSteps) { _enableOpenEmitter(); - _enableCloseEmitter(); //_enableOpenInterrupt(); primed = true; } @@ -150,8 +148,8 @@ uint32_t EndstopCameraShield::toOpen() { _motor.step(); i++; } - //_disableOpenInterrupt(); _disableOpenEmitter(); + //_disableOpenInterrupt(); return i; } @@ -164,7 +162,6 @@ uint32_t EndstopCameraShield::toClose() { while (running) { if (!primed && i > _minSteps) { _enableCloseEmitter(); - _enableOpenEmitter(); //_enableCloseInterrupt(); primed = true; } @@ -176,8 +173,8 @@ uint32_t EndstopCameraShield::toClose() { _motor.step(); i++; } - _disableCloseInterrupt(); - //_disableCloseEmitter(); + _disableCloseEmitter(); + //_disableCloseInterrupt(); return i; } @@ -188,6 +185,10 @@ void EndstopCameraShield::setDirection(bool direction) { } } +bool EndstopCameraShield::getDirection() { + return _direction; +} + bool EndstopCameraShield::isOpened() { return _isOpened; } diff --git a/ino/mcopy_mitchell_camera/EndstopCameraShield.h b/ino/mcopy_mitchell_camera/EndstopCameraShield.h index 9377f1a..68e0725 100644 --- a/ino/mcopy_mitchell_camera/EndstopCameraShield.h +++ b/ino/mcopy_mitchell_camera/EndstopCameraShield.h @@ -65,6 +65,7 @@ class EndstopCameraShield { uint32_t toOpen(); uint32_t toClose(); void setDirection(bool direction); + bool getDirection(); bool isOpened(); bool isClosed(); void test(); diff --git a/ino/mcopy_oxberry_camera/EndstopCameraShield.cpp b/ino/mcopy_oxberry_camera/EndstopCameraShield.cpp index a2b16fa..098e6e0 100644 --- a/ino/mcopy_oxberry_camera/EndstopCameraShield.cpp +++ b/ino/mcopy_oxberry_camera/EndstopCameraShield.cpp @@ -112,7 +112,6 @@ uint32_t EndstopCameraShield::frame() { while (running) { if (!primed && i > _minSteps) { _enableCloseEmitter(); - _enableOpenEmitter(); //_enableCloseInterrupt(); primed = true; } @@ -124,8 +123,8 @@ uint32_t EndstopCameraShield::frame() { _motor.step(); i++; } - //_disableCloseInterrupt(); _disableCloseEmitter(); + //_disableCloseInterrupt(); return i; } @@ -138,7 +137,6 @@ uint32_t EndstopCameraShield::toOpen() { while (running) { if (!primed && i > _minSteps) { _enableOpenEmitter(); - _enableCloseEmitter(); //_enableOpenInterrupt(); primed = true; } @@ -150,8 +148,8 @@ uint32_t EndstopCameraShield::toOpen() { _motor.step(); i++; } - //_disableOpenInterrupt(); _disableOpenEmitter(); + //_disableOpenInterrupt(); return i; } @@ -164,7 +162,6 @@ uint32_t EndstopCameraShield::toClose() { while (running) { if (!primed && i > _minSteps) { _enableCloseEmitter(); - _enableOpenEmitter(); //_enableCloseInterrupt(); primed = true; } @@ -176,8 +173,8 @@ uint32_t EndstopCameraShield::toClose() { _motor.step(); i++; } - _disableCloseInterrupt(); - //_disableCloseEmitter(); + _disableCloseEmitter(); + //_disableCloseInterrupt(); return i; } @@ -188,6 +185,10 @@ void EndstopCameraShield::setDirection(bool direction) { } } +bool EndstopCameraShield::getDirection() { + return _direction; +} + bool EndstopCameraShield::isOpened() { return _isOpened; } diff --git a/ino/mcopy_oxberry_camera/EndstopCameraShield.h b/ino/mcopy_oxberry_camera/EndstopCameraShield.h index 9377f1a..68e0725 100644 --- a/ino/mcopy_oxberry_camera/EndstopCameraShield.h +++ b/ino/mcopy_oxberry_camera/EndstopCameraShield.h @@ -65,6 +65,7 @@ class EndstopCameraShield { uint32_t toOpen(); uint32_t toClose(); void setDirection(bool direction); + bool getDirection(); bool isOpened(); bool isClosed(); void test();