Skip to content

Commit

Permalink
MsgDblReg fix (#2144)
Browse files Browse the repository at this point in the history
  • Loading branch information
htotoo committed May 11, 2024
1 parent 963c6e5 commit e666eb1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
20 changes: 20 additions & 0 deletions firmware/application/apps/ui_battinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using namespace portapack;

namespace ui {

bool BattinfoView::needRun = true;
void BattinfoView::focus() {
button_exit.focus();
}
Expand Down Expand Up @@ -99,6 +100,25 @@ BattinfoView::BattinfoView(NavigationView& nav)
};

update_result();
needRun = true;
thread = chThdCreateFromHeap(NULL, 512, NORMALPRIO + 10, BattinfoView::static_fn, this);
}

msg_t BattinfoView::static_fn(void* arg) {
auto obj = static_cast<BattinfoView*>(arg);
while (needRun) {
chThdSleepMilliseconds(16);
obj->on_timer();
}
return 0;
}

BattinfoView::~BattinfoView() {
needRun = false;
if (thread) {
chThdTerminate(thread);
chThdWait(thread);
thread = nullptr;
}
}
} // namespace ui
15 changes: 9 additions & 6 deletions firmware/application/apps/ui_battinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@
namespace ui {
class BattinfoView : public View {
public:
~BattinfoView();
BattinfoView(NavigationView& nav);
BattinfoView(const BattinfoView&) = delete;
BattinfoView(BattinfoView&&) = delete;
BattinfoView& operator=(const BattinfoView&) = delete;
BattinfoView& operator=(BattinfoView&&) = delete;

void focus() override;
std::string title() const override { return "Battery"; };

Expand Down Expand Up @@ -70,12 +76,9 @@ class BattinfoView : public View {
Button button_exit{
{72, 17 * 16, 96, 32},
"Back"};

MessageHandlerRegistration message_handler_frame_sync{
Message::ID::DisplayFrameSync,
[this](const Message* const) {
this->on_timer();
}};
static msg_t static_fn(void* arg);
static bool needRun;
Thread* thread{nullptr};
};

} /* namespace ui */
Expand Down

0 comments on commit e666eb1

Please sign in to comment.