Skip to content

Commit

Permalink
keira: add onSuspend / onResume / onStop methods to App class
Browse files Browse the repository at this point in the history
  • Loading branch information
and3rson committed Mar 10, 2024
1 parent ec12561 commit 20d8319
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions firmware/keira/src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ void App::_run(void* data) {
void App::suspend() {
// TODO: Check if the task is already suspended
Serial.println("Suspending app " + String(name) + " (state = " + String(getState()) + ")");
onSuspend();
vTaskSuspend(taskHandle);
}

void App::resume() {
// TODO: Check if the task is already running
Serial.println("Resuming app " + String(name) + " (state = " + String(getState()) + ")");
onResume();
vTaskResume(taskHandle);
}

void App::stop() {
Serial.println("Stopping app " + String(name) + " (state = " + String(getState()) + ")");
onStop();
vTaskDelete(taskHandle);
}

Expand Down
6 changes: 6 additions & 0 deletions firmware/keira/src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class App {

private:
virtual void run() = 0;
virtual void onSuspend() {
}
virtual void onResume() {
}
virtual void onStop() {
}

const char* name;
uint16_t x, y, w, h;
Expand Down

0 comments on commit 20d8319

Please sign in to comment.