Skip to content

Commit

Permalink
#97 Remove Unnecessary Variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Peyton-McKee committed Jun 10, 2024
1 parent 80d3a1b commit eb55bc7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 39 deletions.
46 changes: 14 additions & 32 deletions NERODevelopment/src/controllers/buttoncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,31 @@ void ButtonController::buttonUpdate() {
this->leftButtonPressed();
this->m_leftButtonDebounce = currentDate.toMSecsSinceEpoch();
} else if (this->m_model->getBackwardButtonPressed() == 0) {
this->m_leftButtonDebounceRunning = false;
this->m_leftButtonDebounce = currentDate.toMSecsSinceEpoch();
} else {
this->m_leftButtonDebounceRunning = true;
}

if (this->m_model->getForwardButtonPressed() == 1 &&
if (this->m_model->getRightButtonPressed() == 1 &&
currentDate.toMSecsSinceEpoch() - this->m_rightButtonDebounce >
this->m_debounceOffset) {
qDebug() << "Right Button Pressed";

qDebug() << "Forward button pressed";
this->rightButtonPressed();
this->m_rightButtonDebounce = currentDate.toMSecsSinceEpoch();
} else if (this->m_model->getForwardButtonPressed() == 0) {
this->m_rightButtonDebounceRunning = false;
} else if (this->m_model->getRightButtonPressed() == 0) {
this->m_rightButtonDebounce = currentDate.toMSecsSinceEpoch();
} else {
this->m_rightButtonDebounceRunning = true;
}

// if (this->m_model->getForwardButtonPressed() == 1 &&
// currentDate.toMSecsSinceEpoch() - this->m_rightButtonDebounce >
// this->m_debounceOffset) {

// qDebug() << "Forward button pressed";
// this->rightButtonPressed();
// this->m_rightButtonDebounce = currentDate.toMSecsSinceEpoch();
// } else if (this->m_model->getForwardButtonPressed() == 0) {
// this->m_rightButtonDebounce = currentDate.toMSecsSinceEpoch();
// }

if (this->m_model->getEnterButtonPressed() == 1 &&
currentDate.toMSecsSinceEpoch() - this->m_enterButtonDebounce >
this->m_debounceOffset) {
Expand All @@ -70,24 +75,7 @@ void ButtonController::buttonUpdate() {
this->enterButtonPressed();
this->m_enterButtonDebounce = currentDate.toMSecsSinceEpoch();
} else if (this->m_model->getEnterButtonPressed() == 0) {
this->m_enterButtonDebounceRunning = false;
this->m_enterButtonDebounce = currentDate.toMSecsSinceEpoch();
} else {
this->m_enterButtonDebounceRunning = true;
}

if (this->m_model->getRightButtonPressed() == 1 &&
currentDate.toMSecsSinceEpoch() - this->m_rightButtonDebounce >
this->m_debounceOffset) {
qDebug() << "Right Button Pressed";

this->rightButtonPressed();
this->m_rightButtonDebounce = currentDate.toMSecsSinceEpoch();
} else if (this->m_model->getRightButtonPressed() == 0) {
this->m_rightButtonDebounceRunning = false;
this->m_rightButtonDebounce = currentDate.toMSecsSinceEpoch();
} else {
this->m_rightButtonDebounceRunning = true;
}

if (this->m_model->getUpButtonPressed() == 1 &&
Expand All @@ -97,10 +85,7 @@ void ButtonController::buttonUpdate() {
this->upButtonPressed();
this->m_upButtonDebounce = currentDate.toMSecsSinceEpoch();
} else if (this->m_model->getUpButtonPressed() == 0) {
this->m_upButtonDebounceRunning = false;
this->m_upButtonDebounce = currentDate.toMSecsSinceEpoch();
} else {
this->m_upButtonDebounceRunning = true;
}

if (this->m_model->getDownButtonPressed() == 1 &&
Expand All @@ -111,10 +96,7 @@ void ButtonController::buttonUpdate() {
this->downButtonPressed();
this->m_downButtonDebounce = currentDate.toMSecsSinceEpoch();
} else if (this->m_model->getDownButtonPressed() == 0) {
this->m_downButtonDebounceRunning = false;
this->m_downButtonDebounce = currentDate.toMSecsSinceEpoch();
} else {
this->m_downButtonDebounceRunning = true;
}

if (this->m_model->getHomeButtonPressed() == 1 &&
Expand Down
7 changes: 1 addition & 6 deletions NERODevelopment/src/controllers/buttoncontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ public slots:
qint64 m_rightButtonDebounce = 0;
qint64 m_leftButtonDebounce = 0;
qint64 m_homeButtonDebounce = 0;
int m_debounceOffset = 100;
bool m_downButtonDebounceRunning = false;
bool m_upButtonDebounceRunning = false;
bool m_rightButtonDebounceRunning = false;
bool m_leftButtonDebounceRunning = false;
bool m_enterButtonDebounceRunning = false;
int m_debounceOffset = 500;
};

#endif // BUTTONCONTROLLER_H
2 changes: 1 addition & 1 deletion NERODevelopment/src/controllers/efficiencycontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EfficiencyController::EfficiencyController(Model *model, QObject *parent)
connect(m_updateTimer, &QTimer::timeout, this,
&EfficiencyController::updateCurrentTime);
m_updateTimer->setInterval(1);
this->m_debounceOffset = 2000;
this->m_debounceOffset = 750;
}

int EfficiencyController::currentMaxTorque() const {
Expand Down

0 comments on commit eb55bc7

Please sign in to comment.