Change capture start/stop to toggle image button.

This commit is contained in:
Jared Boone 2016-04-12 11:37:58 -07:00
parent cee5417a4a
commit 2201a9e95f
2 changed files with 65 additions and 23 deletions

View File

@ -30,13 +30,12 @@ namespace ui {
CaptureAppView::CaptureAppView(NavigationView& nav) { CaptureAppView::CaptureAppView(NavigationView& nav) {
add_children({ { add_children({ {
&button_start_stop,
&rssi, &rssi,
&channel, &channel,
&field_frequency, &field_frequency,
&field_lna, &field_lna,
&field_vga, &field_vga,
&button_start,
&button_stop,
} }); } });
field_frequency.set_value(receiver_model.tuning_frequency()); field_frequency.set_value(receiver_model.tuning_frequency());
@ -63,8 +62,9 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
this->on_vga_changed(v_db); this->on_vga_changed(v_db);
}; };
button_start.on_select = [this](Button&){ this->on_start(); }; button_start_stop.on_select = [this](ImageButton&) {
button_stop.on_select = [this](Button&){ this->on_stop(); }; this->on_start_stop();
};
receiver_model.set_baseband_configuration({ receiver_model.set_baseband_configuration({
.mode = toUType(ReceiverModel::Mode::Capture), .mode = toUType(ReceiverModel::Mode::Capture),
@ -80,19 +80,19 @@ CaptureAppView::~CaptureAppView() {
} }
void CaptureAppView::focus() { void CaptureAppView::focus() {
button_start.focus(); button_start_stop.focus();
} }
void CaptureAppView::on_start() { void CaptureAppView::on_start_stop() {
if( !capture_thread ) { if( capture_thread ) {
capture_thread.reset();
button_start_stop.set_bitmap(&bitmap_record);
} else {
capture_thread = std::make_unique<AudioThread>("baseband.c16"); capture_thread = std::make_unique<AudioThread>("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) { void CaptureAppView::on_tuning_frequency_changed(rf::Frequency f) {
receiver_model.set_tuning_frequency(f); receiver_model.set_tuning_frequency(f);
} }

View File

@ -33,6 +33,52 @@
namespace ui { 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 { class CaptureAppView : public View {
public: public:
CaptureAppView(NavigationView& nav); CaptureAppView(NavigationView& nav);
@ -48,13 +94,19 @@ private:
std::unique_ptr<AudioThread> capture_thread; std::unique_ptr<AudioThread> capture_thread;
void on_start(); void on_start_stop();
void on_stop();
void on_tuning_frequency_changed(rf::Frequency f); void on_tuning_frequency_changed(rf::Frequency f);
void on_lna_changed(int32_t v_db); void on_lna_changed(int32_t v_db);
void on_vga_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 { RSSI rssi {
{ 21 * 8, 0, 6 * 8, 4 }, { 21 * 8, 0, 6 * 8, 4 },
}; };
@ -74,16 +126,6 @@ private:
VGAGainField field_vga { VGAGainField field_vga {
{ 18 * 8, 0 * 16 } { 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 */ } /* namespace ui */