diff --git a/firmware/application/ui_receiver.cpp b/firmware/application/ui_receiver.cpp index 96fbe5d9..7dfbb38e 100644 --- a/firmware/application/ui_receiver.cpp +++ b/firmware/application/ui_receiver.cpp @@ -480,7 +480,18 @@ ReceiverView::ReceiverView( }; receiver_model.enable(); +} +ReceiverView::~ReceiverView() { + + // TODO: Manipulating audio codec here, and in ui_receiver.cpp. Good to do + // both? + audio_codec.headphone_mute(); + + receiver_model.disable(); +} + +void ReceiverView::on_show() { context().message_map.register_handler(Message::ID::FSKPacket, [](const Message* const p) { const auto message = static_cast(p); @@ -489,14 +500,8 @@ ReceiverView::ReceiverView( ); } -ReceiverView::~ReceiverView() { +void ReceiverView::on_hide() { context().message_map.unregister_handler(Message::ID::FSKPacket); - - // TODO: Manipulating audio codec here, and in ui_receiver.cpp. Good to do - // both? - audio_codec.headphone_mute(); - - receiver_model.disable(); } void ReceiverView::set_parent_rect(const Rect new_parent_rect) { diff --git a/firmware/application/ui_receiver.hpp b/firmware/application/ui_receiver.hpp index 639ad6b7..3280ede6 100644 --- a/firmware/application/ui_receiver.hpp +++ b/firmware/application/ui_receiver.hpp @@ -367,6 +367,9 @@ public: void focus() override; + void on_show() override; + void on_hide() override; + private: ReceiverModel& receiver_model;