Capture UI basic controls.

Tuning, LNA/VGA gain, second IF and "channel" RSSI. Use ReceiverModel, so that audio receiver parameters come across for quicker capture configuration.
This commit is contained in:
Jared Boone 2016-04-12 10:56:00 -07:00
parent 60a0d5c469
commit cee5417a4a
3 changed files with 72 additions and 24 deletions

View File

@ -21,40 +21,62 @@
#include "capture_app.hpp" #include "capture_app.hpp"
#include "baseband_api.hpp" #include "portapack.hpp"
using namespace portapack;
#include "utility.hpp" #include "utility.hpp"
namespace ui { namespace ui {
CaptureAppView::CaptureAppView(NavigationView&) { CaptureAppView::CaptureAppView(NavigationView& nav) {
add_children({ { add_children({ {
&rssi,
&channel,
&field_frequency,
&field_lna,
&field_vga,
&button_start, &button_start,
&button_stop, &button_stop,
} }); } });
field_frequency.set_value(receiver_model.tuning_frequency());
field_frequency.set_step(receiver_model.frequency_step());
field_frequency.on_change = [this](rf::Frequency f) {
this->on_tuning_frequency_changed(f);
};
field_frequency.on_edit = [this, &nav]() {
// TODO: Provide separate modal method/scheme?
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
this->on_tuning_frequency_changed(f);
this->field_frequency.set_value(f);
};
};
field_lna.set_value(receiver_model.lna());
field_lna.on_change = [this](int32_t v) {
this->on_lna_changed(v);
};
field_vga.set_value(receiver_model.vga());
field_vga.on_change = [this](int32_t v_db) {
this->on_vga_changed(v_db);
};
button_start.on_select = [this](Button&){ this->on_start(); }; button_start.on_select = [this](Button&){ this->on_start(); };
button_stop.on_select = [this](Button&){ this->on_stop(); }; button_stop.on_select = [this](Button&){ this->on_stop(); };
radio::enable({ receiver_model.set_baseband_configuration({
tuning_frequency(), .mode = toUType(ReceiverModel::Mode::Capture),
sampling_rate,
baseband_bandwidth,
rf::Direction::Receive,
false, 16, 16,
1,
});
baseband::start({
.mode = 7,
.sampling_rate = sampling_rate, .sampling_rate = sampling_rate,
.decimation_factor = 1, .decimation_factor = 1,
}); });
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
receiver_model.enable();
} }
CaptureAppView::~CaptureAppView() { CaptureAppView::~CaptureAppView() {
baseband::stop(); receiver_model.disable();
radio::disable();
} }
void CaptureAppView::focus() { void CaptureAppView::focus() {
@ -71,12 +93,16 @@ void CaptureAppView::on_stop() {
capture_thread.reset(); capture_thread.reset();
} }
uint32_t CaptureAppView::target_frequency() const { void CaptureAppView::on_tuning_frequency_changed(rf::Frequency f) {
return initial_target_frequency; receiver_model.set_tuning_frequency(f);
} }
uint32_t CaptureAppView::tuning_frequency() const { void CaptureAppView::on_lna_changed(int32_t v_db) {
return target_frequency() - (sampling_rate / 4); receiver_model.set_lna(v_db);
}
void CaptureAppView::on_vga_changed(int32_t v_db) {
receiver_model.set_vga(v_db);
} }
} /* namespace ui */ } /* namespace ui */

View File

@ -24,6 +24,7 @@
#include "ui_widget.hpp" #include "ui_widget.hpp"
#include "ui_navigation.hpp" #include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "audio_thread.hpp" #include "audio_thread.hpp"
@ -42,18 +43,38 @@ public:
std::string title() const override { return "Capture"; }; std::string title() const override { return "Capture"; };
private: private:
static constexpr uint32_t initial_target_frequency = 91500000;
static constexpr uint32_t sampling_rate = 2457600; static constexpr uint32_t sampling_rate = 2457600;
static constexpr uint32_t baseband_bandwidth = 1750000; static constexpr uint32_t baseband_bandwidth = 1750000;
std::unique_ptr<AudioThread> capture_thread; std::unique_ptr<AudioThread> capture_thread;
uint32_t target_frequency() const;
uint32_t tuning_frequency() const;
void on_start(); void on_start();
void on_stop(); void on_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);
RSSI rssi {
{ 21 * 8, 0, 6 * 8, 4 },
};
Channel channel {
{ 21 * 8, 5, 6 * 8, 4 },
};
FrequencyField field_frequency {
{ 5 * 8, 0 * 16 },
};
LNAGainField field_lna {
{ 15 * 8, 0 * 16 }
};
VGAGainField field_vga {
{ 18 * 8, 0 * 16 }
};
Button button_start { Button button_start {
{ 16, 17 * 16, 96, 24 }, { 16, 17 * 16, 96, 24 },
"Start" "Start"

View File

@ -37,6 +37,7 @@ public:
NarrowbandFMAudio = 1, NarrowbandFMAudio = 1,
WidebandFMAudio = 2, WidebandFMAudio = 2,
SpectrumAnalysis = 4, SpectrumAnalysis = 4,
Capture = 7,
}; };
rf::Frequency tuning_frequency() const; rf::Frequency tuning_frequency() const;