From 447a7a5661fc04870a329ea73a414b3dfb002f70 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 3 Aug 2016 16:14:34 -0700 Subject: [PATCH] Add TXGainField user interface element. --- firmware/application/ui_receiver.cpp | 25 +++++++++++++++++++++++++ firmware/application/ui_receiver.hpp | 9 +++++++++ 2 files changed, 34 insertions(+) diff --git a/firmware/application/ui_receiver.cpp b/firmware/application/ui_receiver.cpp index 18a5c613..d48917a4 100644 --- a/firmware/application/ui_receiver.cpp +++ b/firmware/application/ui_receiver.cpp @@ -353,4 +353,29 @@ void VGAGainField::on_focus() { } } +/* TXGainField **********************************************************/ + +TXGainField::TXGainField( + Point parent_pos +) : NumberField { + parent_pos, 2, + { max2837::tx::gain_db_range.minimum, max2837::tx::gain_db_range.maximum }, + max2837::tx::gain_db_step, + ' ', + } +{ + set_value(receiver_model.tx_gain()); + + on_change = [](int32_t v) { + receiver_model.set_tx_gain(v); + }; +} + +void TXGainField::on_focus() { + //Widget::on_focus(); + if( on_show_options ) { + on_show_options(); + } +} + } /* namespace ui */ diff --git a/firmware/application/ui_receiver.hpp b/firmware/application/ui_receiver.hpp index 1d4cb6d3..eb012f4d 100644 --- a/firmware/application/ui_receiver.hpp +++ b/firmware/application/ui_receiver.hpp @@ -330,6 +330,15 @@ public: void on_focus() override; }; +class TXGainField : public NumberField { +public: + std::function on_show_options; + + TXGainField(Point parent_pos); + + void on_focus() override; +}; + } /* namespace ui */ #endif/*__UI_RECEIVER_H__*/