Skip to content

Commit

Permalink
fix clang-format and cppcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
k3kukua committed Jun 7, 2024
1 parent 0d14e0f commit cee0985
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
16 changes: 10 additions & 6 deletions firmware/keira/src/apps/ble_gamepad/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ void MainApp::uiLoop() {
}
}

void MainApp::onStop() {
bleGamepadController.stop();
}

bool MainApp::isExitHotkeyPressed() {
lilka::State st = lilka::controller.peekState();
lilka::ButtonState hotkeyState = st.select;
Expand All @@ -53,14 +49,22 @@ bool MainApp::isExitHotkeyPressed() {
uint64_t curTime = millis();
uint64_t delta = curTime - hotkeyPressTime;
lastSecondsToExit = EXIT_BUTTON_PRESS_SECONDS - delta / ONE_SECOND;
if(lastSecondsToExit < 0) {
if (lastSecondsToExit < 0) {
lastSecondsToExit = 0;
}
return lastSecondsToExit == 0;
}

void MainApp::cleanUp() {
bleGamepadController.stop();
}

void MainApp::onStop() {
cleanUp();
}

MainApp::~MainApp() {
onStop();
cleanUp();
}

} // namespace ble_gamepad_app
1 change: 1 addition & 0 deletions firmware/keira/src/apps/ble_gamepad/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class MainApp : public App {
void uiLoop();
void onStop() override;
bool isExitHotkeyPressed();
void cleanUp();

Controller bleGamepadController;
FPS uiFps;
Expand Down
2 changes: 1 addition & 1 deletion firmware/keira/src/apps/ble_gamepad/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool Controller::start() {
"bleControllerTimer",
pdMS_TO_TICKS(CONTROLLER_TIMER_DELAY_MILLIS),
pdTRUE,
(void*)this,
static_cast<void*>(this),
Controller::controllerTimerCallback
);
if (controllerTimer != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion firmware/keira/src/apps/ble_gamepad/fps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ unsigned long FPS::getDelta() {
unsigned long FPS::getLimitMillis() {
unsigned long delta = getDelta();
// Incorrect delay time. Using default limits
if (delta <= 0) {
if (delta == 0) {
return delayLimitMillis;
}
// Too long delay time. Using min limits
Expand Down
2 changes: 1 addition & 1 deletion firmware/keira/src/apps/ble_gamepad/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace ble_gamepad_app {

class Timer {
public:
Timer(int periodMillis);
explicit Timer(int periodMillis);
static unsigned long getTime();
unsigned long go();
bool isTime(bool triggerOnFirstCall = false);
Expand Down

0 comments on commit cee0985

Please sign in to comment.