Skip to content

Commit

Permalink
Fix surprise message
Browse files Browse the repository at this point in the history
  • Loading branch information
john0312 committed Aug 21, 2024
1 parent cac6ae4 commit 90186f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fw/Core/Hitcon/App/ShowNameApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ void ShowNameApp::SetMode(const enum ShowNameMode mode) {
update_display();
}

void ShowNameApp::SetSurpriseMsg(const char *msg) {
int len = strlen(msg);
if (len >= kDisplayScrollMaxTextLen) {
len = kDisplayScrollMaxTextLen;
}
memcpy(surprise_msg, msg, len);
surprise_msg[len] = 0;
}

enum ShowNameMode ShowNameApp::GetMode() { return mode; }

} // namespace hitcon
3 changes: 3 additions & 0 deletions fw/Core/Hitcon/App/ShowNameApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ShowNameApp : public App {
void SetMode(const enum ShowNameMode mode);
enum ShowNameMode GetMode();

void SetSurpriseMsg(const char *msg);

void check_update();

private:
Expand All @@ -44,6 +46,7 @@ class ShowNameApp : public App {
hitcon::service::sched::PeriodicTask _routine_task;
uint32_t score_cache = 0;

char surprise_msg[kDisplayScrollMaxTextLen + 1];
bool starting_up;
unsigned last_disp_update;
};
Expand Down
2 changes: 2 additions & 0 deletions fw/Core/Hitcon/Logic/IrController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ void IrController::Send2Game(void* arg) {
send_lock = true;
}
void IrController::ShowText(void* arg) {
struct ShowPacket* pkt = reinterpret_cast<struct ShowPacket*>(arg);
show_name_app.SetSurpriseMsg(pkt->message);
show_name_app.SetMode(Surprise);
badge_controller.change_app(&show_name_app);
}
Expand Down

0 comments on commit 90186f2

Please sign in to comment.