mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-14 12:08:40 +00:00
Change capture start/stop to toggle image button.
This commit is contained in:
parent
cee5417a4a
commit
2201a9e95f
@ -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<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) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
}
|
||||
|
@ -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<AudioThread> 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 */
|
||||
|
Loading…
Reference in New Issue
Block a user