From 32312a6cfbe40237ccfbca2df12d96912a562199 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Fri, 14 Aug 2015 17:52:29 -0700 Subject: [PATCH] Can't use context() in ui::Widget constructor, move use elsewhere. TODO: Seems like a design flaw to me... Either eliminate need for context(), or pass into constructors. --- firmware/application/ui_receiver.cpp | 19 ++++++++++++------- firmware/application/ui_receiver.hpp | 3 +++ 2 files changed, 15 insertions(+), 7 deletions(-) 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;