Skip to content

Commit

Permalink
restore app
Browse files Browse the repository at this point in the history
  • Loading branch information
Alx-Lai committed Aug 23, 2024
1 parent d48cb50 commit e828d8e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions fw/Core/Hitcon/App/ShowNameApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void ShowNameApp::check_update() {
SysTimer::GetTime() - last_disp_update > SURPRISE_TIME) {
mode = NameScore;
update_display();
badge_controller.RestoreApp();
} else if (mode != Surprise &&
(SysTimer::GetTime() - last_disp_update > kMinUpdateInterval ||
starting_up)) {
Expand Down
7 changes: 7 additions & 0 deletions fw/Core/Hitcon/Logic/BadgeController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,11 @@ void BadgeController::OnEdgeButton(void *arg1) {
current_app->OnEdgeButton(button);
}

void BadgeController::SetStoredApp(App *app) { stored_app = app; }

void BadgeController::RestoreApp() {
if (stored_app) change_app(stored_app);
stored_app = nullptr;
}

} // namespace hitcon
5 changes: 5 additions & 0 deletions fw/Core/Hitcon/Logic/BadgeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ class BadgeController {
void SetCallback(callback_t callback, void *callback_arg1,
void *callback_arg2);

// for interrupt resume
void SetStoredApp(App *app);
void RestoreApp();

private:
callback_t callback = nullptr;
void *callback_arg1;
void *callback_arg2;
App *stored_app;
};

extern BadgeController badge_controller;
Expand Down
1 change: 1 addition & 0 deletions fw/Core/Hitcon/Logic/IrController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void IrController::Send2Game(void* arg) {
}
void IrController::ShowText(void* arg) {
struct ShowPacket* pkt = reinterpret_cast<struct ShowPacket*>(arg);
badge_controller.SetStoredApp(badge_controller.GetCurrentApp());
show_name_app.SetSurpriseMsg(pkt->message);
show_name_app.SetMode(Surprise);
badge_controller.change_app(&show_name_app);
Expand Down

0 comments on commit e828d8e

Please sign in to comment.