mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-12 07:49:32 -05:00
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:
parent
60a0d5c469
commit
cee5417a4a
@ -21,40 +21,62 @@
|
||||
|
||||
#include "capture_app.hpp"
|
||||
|
||||
#include "baseband_api.hpp"
|
||||
#include "portapack.hpp"
|
||||
using namespace portapack;
|
||||
|
||||
#include "utility.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
CaptureAppView::CaptureAppView(NavigationView&) {
|
||||
CaptureAppView::CaptureAppView(NavigationView& nav) {
|
||||
add_children({ {
|
||||
&rssi,
|
||||
&channel,
|
||||
&field_frequency,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&button_start,
|
||||
&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_stop.on_select = [this](Button&){ this->on_stop(); };
|
||||
|
||||
radio::enable({
|
||||
tuning_frequency(),
|
||||
sampling_rate,
|
||||
baseband_bandwidth,
|
||||
rf::Direction::Receive,
|
||||
false, 16, 16,
|
||||
1,
|
||||
});
|
||||
|
||||
baseband::start({
|
||||
.mode = 7,
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = toUType(ReceiverModel::Mode::Capture),
|
||||
.sampling_rate = sampling_rate,
|
||||
.decimation_factor = 1,
|
||||
});
|
||||
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||
receiver_model.enable();
|
||||
}
|
||||
|
||||
CaptureAppView::~CaptureAppView() {
|
||||
baseband::stop();
|
||||
radio::disable();
|
||||
receiver_model.disable();
|
||||
}
|
||||
|
||||
void CaptureAppView::focus() {
|
||||
@ -71,12 +93,16 @@ void CaptureAppView::on_stop() {
|
||||
capture_thread.reset();
|
||||
}
|
||||
|
||||
uint32_t CaptureAppView::target_frequency() const {
|
||||
return initial_target_frequency;
|
||||
void CaptureAppView::on_tuning_frequency_changed(rf::Frequency f) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
}
|
||||
|
||||
uint32_t CaptureAppView::tuning_frequency() const {
|
||||
return target_frequency() - (sampling_rate / 4);
|
||||
void CaptureAppView::on_lna_changed(int32_t v_db) {
|
||||
receiver_model.set_lna(v_db);
|
||||
}
|
||||
|
||||
void CaptureAppView::on_vga_changed(int32_t v_db) {
|
||||
receiver_model.set_vga(v_db);
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "ui_widget.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
|
||||
#include "audio_thread.hpp"
|
||||
|
||||
@ -42,18 +43,38 @@ public:
|
||||
std::string title() const override { return "Capture"; };
|
||||
|
||||
private:
|
||||
static constexpr uint32_t initial_target_frequency = 91500000;
|
||||
static constexpr uint32_t sampling_rate = 2457600;
|
||||
static constexpr uint32_t baseband_bandwidth = 1750000;
|
||||
|
||||
std::unique_ptr<AudioThread> capture_thread;
|
||||
|
||||
uint32_t target_frequency() const;
|
||||
uint32_t tuning_frequency() const;
|
||||
|
||||
void on_start();
|
||||
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 {
|
||||
{ 16, 17 * 16, 96, 24 },
|
||||
"Start"
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
NarrowbandFMAudio = 1,
|
||||
WidebandFMAudio = 2,
|
||||
SpectrumAnalysis = 4,
|
||||
Capture = 7,
|
||||
};
|
||||
|
||||
rf::Frequency tuning_frequency() const;
|
||||
|
Loading…
Reference in New Issue
Block a user