Skip to content

Commit 398f214

Browse files
committed
Update to add override flag
1 parent 79b5dd9 commit 398f214

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Command_Interpreter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ Command_Interpreter_RPi5::Command_Interpreter_RPi5(std::vector<PwmPin *> thruste
127127
const WiringControl &wiringControl, std::ostream &output,
128128
std::ostream &outLog, std::ostream &errorLog) :
129129
thrusterPins(std::move(thrusterPins)), digitalPins(std::move(digitalPins)), wiringControl(wiringControl),
130-
errorLog(errorLog),
131-
outLog(outLog), output(output) {
130+
errorLog(errorLog), outLog(outLog), output(output), isInterruptBlind_Execute(false) {
132131
if (this->thrusterPins.size() != 8) {
133132
errorLog << "Incorrect number of thruster pwm pins given! Need 8, given " << this->thrusterPins.size()
134133
<< std::endl;
@@ -168,13 +167,14 @@ Command_Interpreter_RPi5::~Command_Interpreter_RPi5() {
168167
}
169168

170169
void Command_Interpreter_RPi5::timed_execute(const CommandComponent &commandComponent) {
170+
isInterruptBlind_Execute = false;
171171
auto endTime = std::chrono::system_clock::now() + commandComponent.duration;
172172
auto currentTime = std::chrono::system_clock::now();
173173
untimed_execute(commandComponent.thruster_pwms);
174-
while (currentTime < endTime) {
175-
174+
while (currentTime < endTime && !isInterruptBlind_Execute) {
176175
currentTime = std::chrono::system_clock::now();
177176
}
177+
isInterruptBlind_Execute = false;
178178
}
179179

180180
void Command_Interpreter_RPi5::untimed_execute(pwm_array thrusterPwms) {

src/Command_Interpreter.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class Command_Interpreter_RPi5 {
167167
std::ostream &outLog;
168168
std::ostream &errorLog;
169169

170+
bool isInterruptBlind_Execute;
171+
170172
public:
171173
/// @param thrusterPins the PWM pins that will drive robot thrusters
172174
/// @param digitalPins non-PWM pins to be used for digital (2-state) output
@@ -194,6 +196,9 @@ class Command_Interpreter_RPi5 {
194196
/// @return A vector containing the current value of all pins. PWM pins will return a value in the range [1100, 1900]
195197
std::vector<int> readPins();
196198

199+
/// @brief Set an interrupt for the blind_execute function while running. Calling this function sets the interrupt to occur.
200+
void interruptBlind_Execute() {isInterruptBlind_Execute = true;}
201+
197202
~Command_Interpreter_RPi5(); //TODO this also deletes all its pins. Not sure if this is desirable or not?
198203
};
199204

0 commit comments

Comments
 (0)