From 2201a9e95f6b134c4d80266b7126b8ddaab9bba0 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 12 Apr 2016 11:37:58 -0700 Subject: [PATCH] Change capture start/stop to toggle image button. --- firmware/application/capture_app.cpp | 22 +++++----- firmware/application/capture_app.hpp | 66 +++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 23 deletions(-) diff --git a/firmware/application/capture_app.cpp b/firmware/application/capture_app.cpp index e51c5049a..173eefd67 100644 --- a/firmware/application/capture_app.cpp +++ b/firmware/application/capture_app.cpp @@ -30,13 +30,12 @@ namespace ui { CaptureAppView::CaptureAppView(NavigationView& nav) { add_children({ { + &button_start_stop, &rssi, &channel, &field_frequency, &field_lna, &field_vga, - &button_start, - &button_stop, } }); field_frequency.set_value(receiver_model.tuning_frequency()); @@ -63,8 +62,9 @@ CaptureAppView::CaptureAppView(NavigationView& nav) { this->on_vga_changed(v_db); }; - button_start.on_select = [this](Button&){ this->on_start(); }; - button_stop.on_select = [this](Button&){ this->on_stop(); }; + button_start_stop.on_select = [this](ImageButton&) { + this->on_start_stop(); + }; receiver_model.set_baseband_configuration({ .mode = toUType(ReceiverModel::Mode::Capture), @@ -80,19 +80,19 @@ CaptureAppView::~CaptureAppView() { } void CaptureAppView::focus() { - button_start.focus(); + button_start_stop.focus(); } -void CaptureAppView::on_start() { - if( !capture_thread ) { +void CaptureAppView::on_start_stop() { + if( capture_thread ) { + capture_thread.reset(); + button_start_stop.set_bitmap(&bitmap_record); + } else { capture_thread = std::make_unique("baseband.c16"); + button_start_stop.set_bitmap(&bitmap_stop); } } -void CaptureAppView::on_stop() { - capture_thread.reset(); -} - void CaptureAppView::on_tuning_frequency_changed(rf::Frequency f) { receiver_model.set_tuning_frequency(f); } diff --git a/firmware/application/capture_app.hpp b/firmware/application/capture_app.hpp index 64bd07eb8..b62ab8c56 100644 --- a/firmware/application/capture_app.hpp +++ b/firmware/application/capture_app.hpp @@ -33,6 +33,52 @@ namespace ui { +static constexpr uint8_t bitmap_record_data[] = { + 0x00, 0x00, + 0x00, 0x00, + 0xc0, 0x03, + 0xf0, 0x0f, + 0xf8, 0x1f, + 0xf8, 0x1f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xf8, 0x1f, + 0xf8, 0x1f, + 0xf0, 0x0f, + 0xc0, 0x03, + 0x00, 0x00, + 0x00, 0x00, +}; + +static constexpr Bitmap bitmap_record { + { 16, 16 }, bitmap_record_data +}; + +static constexpr uint8_t bitmap_stop_data[] = { + 0x00, 0x00, + 0x00, 0x00, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0xfc, 0x3f, + 0x00, 0x00, + 0x00, 0x00, +}; + +static constexpr Bitmap bitmap_stop { + { 16, 16 }, bitmap_stop_data +}; + class CaptureAppView : public View { public: CaptureAppView(NavigationView& nav); @@ -48,13 +94,19 @@ private: std::unique_ptr capture_thread; - void on_start(); - void on_stop(); + void on_start_stop(); void on_tuning_frequency_changed(rf::Frequency f); void on_lna_changed(int32_t v_db); void on_vga_changed(int32_t v_db); + ImageButton button_start_stop { + { 0 * 8, 0, 2 * 8, 1 * 16 }, + &bitmap_record, + Color::red(), + Color::black() + }; + RSSI rssi { { 21 * 8, 0, 6 * 8, 4 }, }; @@ -74,16 +126,6 @@ private: VGAGainField field_vga { { 18 * 8, 0 * 16 } }; - - Button button_start { - { 16, 17 * 16, 96, 24 }, - "Start" - }; - - Button button_stop { - { 240 - 96 - 16, 17 * 16, 96, 24 }, - "Stop" - }; }; } /* namespace ui */