mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-11 07:19:34 -05:00
Use receiver/transmitter models everywhere (#1056)
* Use receiver/transmitter models everywhere * Run formatter * Fix a copy-paste bug, make transmitter_model actually set tx_gain. --------- Co-authored-by: kallanreed <kallanreed@outlook.com>
This commit is contained in:
parent
22c9dd31bf
commit
637bcfdbc7
@ -395,7 +395,7 @@ AISAppView::AISAppView(NavigationView& nav)
|
|||||||
receiver_model.set_tuning_frequency(tuning_frequency());
|
receiver_model.set_tuning_frequency(tuning_frequency());
|
||||||
receiver_model.set_sampling_rate(sampling_rate);
|
receiver_model.set_sampling_rate(sampling_rate);
|
||||||
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
receiver_model.enable(); // Before using radio::enable(), but not updating Ant.DC-Bias.
|
receiver_model.enable();
|
||||||
|
|
||||||
options_channel.on_change = [this](size_t, OptionsField::value_t v) {
|
options_channel.on_change = [this](size_t, OptionsField::value_t v) {
|
||||||
this->on_frequency_changed(v);
|
this->on_frequency_changed(v);
|
||||||
@ -420,7 +420,7 @@ AISAppView::~AISAppView() {
|
|||||||
app_settings.rx_frequency = target_frequency_;
|
app_settings.rx_frequency = target_frequency_;
|
||||||
settings.save("rx_ais", &app_settings);
|
settings.save("rx_ais", &app_settings);
|
||||||
|
|
||||||
receiver_model.disable(); // to switch off all, including DC bias.
|
receiver_model.disable();
|
||||||
|
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ void AISAppView::on_frequency_changed(const uint32_t new_target_frequency) {
|
|||||||
|
|
||||||
void AISAppView::set_target_frequency(const uint32_t new_value) {
|
void AISAppView::set_target_frequency(const uint32_t new_value) {
|
||||||
target_frequency_ = new_value;
|
target_frequency_ = new_value;
|
||||||
radio::set_tuning_frequency(tuning_frequency());
|
receiver_model.set_tuning_frequency(tuning_frequency());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AISAppView::target_frequency() const {
|
uint32_t AISAppView::target_frequency() const {
|
||||||
|
@ -121,17 +121,7 @@ ERTAppView::ERTAppView(NavigationView&) {
|
|||||||
receiver_model.set_tuning_frequency(initial_target_frequency);
|
receiver_model.set_tuning_frequency(initial_target_frequency);
|
||||||
receiver_model.set_sampling_rate(sampling_rate);
|
receiver_model.set_sampling_rate(sampling_rate);
|
||||||
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
receiver_model.enable(); // Before using radio::enable(), but not updating Ant.DC-Bias.
|
receiver_model.enable();
|
||||||
|
|
||||||
/* radio::enable({
|
|
||||||
initial_target_frequency,
|
|
||||||
sampling_rate,
|
|
||||||
baseband_bandwidth,
|
|
||||||
rf::Direction::Receive,
|
|
||||||
receiver_model.rf_amp(),
|
|
||||||
static_cast<int8_t>(receiver_model.lna()),
|
|
||||||
static_cast<int8_t>(receiver_model.vga()),
|
|
||||||
}); */
|
|
||||||
|
|
||||||
logger = std::make_unique<ERTLogger>();
|
logger = std::make_unique<ERTLogger>();
|
||||||
if (logger) {
|
if (logger) {
|
||||||
@ -143,7 +133,7 @@ ERTAppView::~ERTAppView() {
|
|||||||
// save app settings
|
// save app settings
|
||||||
settings.save("rx_ert", &app_settings);
|
settings.save("rx_ert", &app_settings);
|
||||||
|
|
||||||
receiver_model.disable(); // to switch off all, including DC bias and change flag enabled_
|
receiver_model.disable();
|
||||||
|
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
|
@ -141,15 +141,9 @@ void GpsSimAppView::start() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rf_amp = (transmitter_model.rf_amp()); // recover rf_amp settings applied from ui_transmiter.cpp
|
transmitter_model.set_sampling_rate(sample_rate);
|
||||||
|
transmitter_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
radio::enable({receiver_model.tuning_frequency(),
|
transmitter_model.enable();
|
||||||
sample_rate,
|
|
||||||
baseband_bandwidth,
|
|
||||||
rf::Direction::Transmit,
|
|
||||||
rf_amp, // previous code line : "receiver_model.rf_amp()," was passing the same rf_amp of all Receiver Apps
|
|
||||||
static_cast<int8_t>(receiver_model.lna()),
|
|
||||||
static_cast<int8_t>(receiver_model.vga())});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpsSimAppView::stop(const bool do_loop) {
|
void GpsSimAppView::stop(const bool do_loop) {
|
||||||
@ -159,7 +153,7 @@ void GpsSimAppView::stop(const bool do_loop) {
|
|||||||
if (do_loop && check_loop.value()) {
|
if (do_loop && check_loop.value()) {
|
||||||
start();
|
start();
|
||||||
} else {
|
} else {
|
||||||
radio::disable();
|
transmitter_model.disable();
|
||||||
button_play.set_bitmap(&bitmap_play);
|
button_play.set_bitmap(&bitmap_play);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +218,7 @@ GpsSimAppView::GpsSimAppView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
GpsSimAppView::~GpsSimAppView() {
|
GpsSimAppView::~GpsSimAppView() {
|
||||||
radio::disable();
|
transmitter_model.disable();
|
||||||
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit .
|
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit .
|
||||||
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
|
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
|
||||||
}
|
}
|
||||||
|
@ -141,18 +141,9 @@ void ReplayAppView::start() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable Bias Tee if selected
|
transmitter_model.set_sampling_rate(sample_rate * 8);
|
||||||
radio::set_antenna_bias(portapack::get_antenna_bias());
|
transmitter_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
|
transmitter_model.enable();
|
||||||
rf_amp = (transmitter_model.rf_amp()); // recover rf_amp settings applied from ui_transmiter.cpp
|
|
||||||
|
|
||||||
radio::enable({receiver_model.tuning_frequency(),
|
|
||||||
sample_rate * 8,
|
|
||||||
baseband_bandwidth,
|
|
||||||
rf::Direction::Transmit,
|
|
||||||
rf_amp, // previous code line : "receiver_model.rf_amp()," was passing the same rf_amp of all Receiver Apps
|
|
||||||
static_cast<int8_t>(receiver_model.lna()),
|
|
||||||
static_cast<int8_t>(receiver_model.vga())});
|
|
||||||
|
|
||||||
if (portapack::persistent_memory::stealth_mode()) {
|
if (portapack::persistent_memory::stealth_mode()) {
|
||||||
DisplaySleepMessage message;
|
DisplaySleepMessage message;
|
||||||
@ -167,8 +158,7 @@ void ReplayAppView::stop(const bool do_loop) {
|
|||||||
if (do_loop && check_loop.value()) {
|
if (do_loop && check_loop.value()) {
|
||||||
start();
|
start();
|
||||||
} else {
|
} else {
|
||||||
radio::set_antenna_bias(false); // Turn off Bias Tee
|
transmitter_model.disable();
|
||||||
radio::disable();
|
|
||||||
button_play.set_bitmap(&bitmap_play);
|
button_play.set_bitmap(&bitmap_play);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +223,7 @@ ReplayAppView::ReplayAppView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReplayAppView::~ReplayAppView() {
|
ReplayAppView::~ReplayAppView() {
|
||||||
radio::disable();
|
transmitter_model.disable();
|
||||||
|
|
||||||
display.fill_rectangle({0, 0, 240, 320}, Color::black()); // Solving sometimes visible bottom waterfall artifacts, clearing all LCD pixels.
|
display.fill_rectangle({0, 0, 240, 320}, Color::black()); // Solving sometimes visible bottom waterfall artifacts, clearing all LCD pixels.
|
||||||
chThdSleepMilliseconds(40); // (that happened sometimes if we interrupt the waterfall play at the beggining of the play around 25% and exit )
|
chThdSleepMilliseconds(40); // (that happened sometimes if we interrupt the waterfall play at the beggining of the play around 25% and exit )
|
||||||
|
@ -170,17 +170,7 @@ TPMSAppView::TPMSAppView(NavigationView&) {
|
|||||||
receiver_model.set_tuning_frequency(tuning_frequency());
|
receiver_model.set_tuning_frequency(tuning_frequency());
|
||||||
receiver_model.set_sampling_rate(sampling_rate);
|
receiver_model.set_sampling_rate(sampling_rate);
|
||||||
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
receiver_model.enable(); // Before using radio::enable(), but not updating Ant.DC-Bias.
|
receiver_model.enable();
|
||||||
|
|
||||||
/* radio::enable({
|
|
||||||
tuning_frequency(),
|
|
||||||
sampling_rate,
|
|
||||||
baseband_bandwidth,
|
|
||||||
rf::Direction::Receive,
|
|
||||||
receiver_model.rf_amp(),
|
|
||||||
static_cast<int8_t>(receiver_model.lna()),
|
|
||||||
static_cast<int8_t>(receiver_model.vga()),
|
|
||||||
}); */
|
|
||||||
|
|
||||||
options_band.on_change = [this](size_t, OptionsField::value_t v) {
|
options_band.on_change = [this](size_t, OptionsField::value_t v) {
|
||||||
this->on_band_changed(v);
|
this->on_band_changed(v);
|
||||||
@ -212,8 +202,7 @@ TPMSAppView::~TPMSAppView() {
|
|||||||
app_settings.rx_frequency = target_frequency_;
|
app_settings.rx_frequency = target_frequency_;
|
||||||
settings.save("rx_tpms", &app_settings);
|
settings.save("rx_tpms", &app_settings);
|
||||||
|
|
||||||
receiver_model.disable(); // to switch off all, including DC bias and change flag enabled_
|
receiver_model.disable();
|
||||||
|
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +247,7 @@ void TPMSAppView::on_band_changed(const uint32_t new_band_frequency) {
|
|||||||
|
|
||||||
void TPMSAppView::set_target_frequency(const uint32_t new_value) {
|
void TPMSAppView::set_target_frequency(const uint32_t new_value) {
|
||||||
target_frequency_ = new_value;
|
target_frequency_ = new_value;
|
||||||
radio::set_tuning_frequency(tuning_frequency());
|
receiver_model.set_tuning_frequency(tuning_frequency());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TPMSAppView::target_frequency() const {
|
uint32_t TPMSAppView::target_frequency() const {
|
||||||
|
@ -286,7 +286,6 @@ void JammerView::stop_tx() {
|
|||||||
button_transmit.set_style(&style_val);
|
button_transmit.set_style(&style_val);
|
||||||
button_transmit.set_text("START");
|
button_transmit.set_text("START");
|
||||||
transmitter_model.disable();
|
transmitter_model.disable();
|
||||||
radio::disable();
|
|
||||||
baseband::set_jammer(false, JammerType::TYPE_FSK, 0);
|
baseband::set_jammer(false, JammerType::TYPE_FSK, 0);
|
||||||
jamming = false;
|
jamming = false;
|
||||||
cooling = false;
|
cooling = false;
|
||||||
|
@ -97,8 +97,10 @@ void GlassView::adjust_range(int64_t* f_min, int64_t* f_max, int64_t width) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GlassView::retune() {
|
void GlassView::retune() {
|
||||||
// Start a new sweep
|
// Start a new sweep.
|
||||||
radio::set_tuning_frequency(f_center); // tune rx for this new slice directly, faster than using persistent memory saving
|
// Tune rx for this new slice directly because the model
|
||||||
|
// saves to persistent memory which is slower.
|
||||||
|
radio::set_tuning_frequency(f_center);
|
||||||
chThdSleepMilliseconds(5);
|
chThdSleepMilliseconds(5);
|
||||||
baseband::spectrum_streaming_start(); // Do the RX
|
baseband::spectrum_streaming_start(); // Do the RX
|
||||||
}
|
}
|
||||||
|
@ -193,20 +193,9 @@ void PlaylistView::start() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable Bias Tee if selected
|
transmitter_model.set_sampling_rate(sample_rate * 8);
|
||||||
radio::set_antenna_bias(portapack::get_antenna_bias());
|
transmitter_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
|
transmitter_model.enable();
|
||||||
rf_amp = (transmitter_model.rf_amp()); // recover rf_amp settings applied from ui_transmiter.cpp
|
|
||||||
|
|
||||||
radio::enable({receiver_model.tuning_frequency(),
|
|
||||||
sample_rate * 8,
|
|
||||||
baseband_bandwidth,
|
|
||||||
rf::Direction::Transmit,
|
|
||||||
rf_amp, // previous code line : "receiver_model.rf_amp()," was passing the same rf_amp of all Receiver Apps
|
|
||||||
static_cast<int8_t>(receiver_model.lna()),
|
|
||||||
static_cast<int8_t>(receiver_model.vga())});
|
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistView::stop(const bool do_loop) {
|
void PlaylistView::stop(const bool do_loop) {
|
||||||
@ -231,8 +220,7 @@ void PlaylistView::stop(const bool do_loop) {
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
radio::set_antenna_bias(false); // Turn off Bias Tee
|
transmitter_model.disable();
|
||||||
radio::disable();
|
|
||||||
button_play.set_bitmap(&bitmap_play);
|
button_play.set_bitmap(&bitmap_play);
|
||||||
}
|
}
|
||||||
} else if (!check_loop.value()) {
|
} else if (!check_loop.value()) {
|
||||||
@ -244,8 +232,7 @@ void PlaylistView::stop(const bool do_loop) {
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
radio::set_antenna_bias(false); // Turn off Bias Tee
|
transmitter_model.disable();
|
||||||
radio::disable();
|
|
||||||
button_play.set_bitmap(&bitmap_play);
|
button_play.set_bitmap(&bitmap_play);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,7 +301,7 @@ PlaylistView::PlaylistView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlaylistView::~PlaylistView() {
|
PlaylistView::~PlaylistView() {
|
||||||
radio::disable();
|
transmitter_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +196,15 @@ SetRadioView::SetRadioView(
|
|||||||
check_bias.set_value(portapack::get_antenna_bias());
|
check_bias.set_value(portapack::get_antenna_bias());
|
||||||
check_bias.on_select = [this](Checkbox&, bool v) {
|
check_bias.on_select = [this](Checkbox&, bool v) {
|
||||||
portapack::set_antenna_bias(v);
|
portapack::set_antenna_bias(v);
|
||||||
|
|
||||||
|
// Update the radio.
|
||||||
|
receiver_model.set_antenna_bias();
|
||||||
|
transmitter_model.set_antenna_bias();
|
||||||
|
// The models won't actually disable this if they are not 'enabled_'.
|
||||||
|
// Be extra sure this is turned off.
|
||||||
|
if (!v)
|
||||||
|
radio::set_antenna_bias(false);
|
||||||
|
|
||||||
StatusRefreshMessage message{};
|
StatusRefreshMessage message{};
|
||||||
EventDispatcher::send_message(message);
|
EventDispatcher::send_message(message);
|
||||||
};
|
};
|
||||||
|
@ -107,7 +107,7 @@ SondeView::SondeView(NavigationView& nav) {
|
|||||||
receiver_model.set_tuning_frequency(tuning_frequency());
|
receiver_model.set_tuning_frequency(tuning_frequency());
|
||||||
receiver_model.set_sampling_rate(sampling_rate);
|
receiver_model.set_sampling_rate(sampling_rate);
|
||||||
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
receiver_model.enable(); // Before using radio::enable(), but not updating Ant.DC-Bias.
|
receiver_model.enable();
|
||||||
|
|
||||||
// QR code with geo URI
|
// QR code with geo URI
|
||||||
button_see_qr.on_select = [this, &nav](Button&) {
|
button_see_qr.on_select = [this, &nav](Button&) {
|
||||||
@ -155,7 +155,7 @@ SondeView::~SondeView() {
|
|||||||
|
|
||||||
baseband::set_pitch_rssi(0, false);
|
baseband::set_pitch_rssi(0, false);
|
||||||
|
|
||||||
receiver_model.disable(); // to switch off all, including DC bias.
|
receiver_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
audio::output::stop();
|
audio::output::stop();
|
||||||
}
|
}
|
||||||
@ -258,8 +258,6 @@ void SondeView::on_headphone_volume_changed(int32_t v) {
|
|||||||
|
|
||||||
void SondeView::set_target_frequency(const uint32_t new_value) {
|
void SondeView::set_target_frequency(const uint32_t new_value) {
|
||||||
target_frequency_ = new_value;
|
target_frequency_ = new_value;
|
||||||
// radio::set_tuning_frequency(tuning_frequency());
|
|
||||||
// we better remember the tuned frequency, by using this function instead:
|
|
||||||
receiver_model.set_tuning_frequency(target_frequency_);
|
receiver_model.set_tuning_frequency(target_frequency_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,16 +93,9 @@ SpectrumPainterView::SpectrumPainterView(
|
|||||||
if (tx_mode == 0 && image_input_avaliable == false)
|
if (tx_mode == 0 && image_input_avaliable == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Enable Bias Tee if selected
|
portapack::transmitter_model.set_sampling_rate(3072000U);
|
||||||
radio::set_antenna_bias(portapack::get_antenna_bias());
|
portapack::transmitter_model.set_baseband_bandwidth(1750000);
|
||||||
|
portapack::transmitter_model.enable();
|
||||||
radio::enable({portapack::receiver_model.tuning_frequency(),
|
|
||||||
3072000U,
|
|
||||||
1750000,
|
|
||||||
rf::Direction::Transmit,
|
|
||||||
rf_amp,
|
|
||||||
static_cast<int8_t>(portapack::receiver_model.lna()),
|
|
||||||
static_cast<int8_t>(portapack::receiver_model.vga())});
|
|
||||||
|
|
||||||
if (portapack::persistent_memory::stealth_mode()) {
|
if (portapack::persistent_memory::stealth_mode()) {
|
||||||
DisplaySleepMessage message;
|
DisplaySleepMessage message;
|
||||||
|
@ -81,19 +81,14 @@ TestView::TestView(NavigationView& nav) {
|
|||||||
if (logger)
|
if (logger)
|
||||||
logger->append("saucepan.txt");
|
logger->append("saucepan.txt");
|
||||||
|
|
||||||
radio::enable({
|
receiver_model.set_tuning_frequency(tuning_frequency());
|
||||||
tuning_frequency(),
|
receiver_model.set_sampling_rate(sampling_rate);
|
||||||
sampling_rate,
|
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
baseband_bandwidth,
|
receiver_model.enable();
|
||||||
rf::Direction::Receive,
|
|
||||||
receiver_model.rf_amp(),
|
|
||||||
static_cast<int8_t>(receiver_model.lna()),
|
|
||||||
static_cast<int8_t>(receiver_model.vga()),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TestView::~TestView() {
|
TestView::~TestView() {
|
||||||
radio::disable();
|
receiver_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +122,6 @@ void TestView::on_packet(const testapp::Packet& packet) {
|
|||||||
if (logger && logging)
|
if (logger && logging)
|
||||||
logger->log_raw_data(packet, raw_alt - cal_value);
|
logger->log_raw_data(packet, raw_alt - cal_value);
|
||||||
|
|
||||||
// radio::disable();
|
|
||||||
|
|
||||||
/*text_serial.set(packet.serial_number());
|
/*text_serial.set(packet.serial_number());
|
||||||
text_voltage.set(unit_auto_scale(packet.battery_voltage(), 2, 3) + "V");
|
text_voltage.set(unit_auto_scale(packet.battery_voltage(), 2, 3) + "V");
|
||||||
|
|
||||||
@ -139,7 +132,7 @@ void TestView::on_packet(const testapp::Packet& packet) {
|
|||||||
|
|
||||||
void TestView::set_target_frequency(const uint32_t new_value) {
|
void TestView::set_target_frequency(const uint32_t new_value) {
|
||||||
target_frequency_ = new_value;
|
target_frequency_ = new_value;
|
||||||
radio::set_tuning_frequency(tuning_frequency());
|
receiver_model.set_tuning_frequency(tuning_frequency());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TestView::tuning_frequency() const {
|
uint32_t TestView::tuning_frequency() const {
|
||||||
|
@ -521,7 +521,8 @@ void shutdown(const bool leave_screen_on) {
|
|||||||
display.shutdown();
|
display.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
radio::disable();
|
receiver_model.disable();
|
||||||
|
transmitter_model.disable();
|
||||||
audio::shutdown();
|
audio::shutdown();
|
||||||
|
|
||||||
hackrf::cpld::init_from_eeprom();
|
hackrf::cpld::init_from_eeprom();
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
#include "clock_manager.hpp"
|
#include "clock_manager.hpp"
|
||||||
#include "temperature_logger.hpp"
|
#include "temperature_logger.hpp"
|
||||||
|
|
||||||
|
/* TODO: This would be better as a class to add
|
||||||
|
* guardrails on setting properties. */
|
||||||
namespace portapack {
|
namespace portapack {
|
||||||
|
|
||||||
extern portapack::IO io;
|
extern portapack::IO io;
|
||||||
@ -59,6 +61,8 @@ extern bool antenna_bias;
|
|||||||
|
|
||||||
extern TemperatureLogger temperature_logger;
|
extern TemperatureLogger temperature_logger;
|
||||||
|
|
||||||
|
/* Get or set the antenna_bias flag.
|
||||||
|
* NB: Does not actually update the radio state. */
|
||||||
void set_antenna_bias(const bool v);
|
void set_antenna_bias(const bool v);
|
||||||
bool get_antenna_bias();
|
bool get_antenna_bias();
|
||||||
|
|
||||||
|
@ -42,6 +42,9 @@ using namespace hackrf::one;
|
|||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
#include "portapack_persistent_memory.hpp"
|
#include "portapack_persistent_memory.hpp"
|
||||||
|
|
||||||
|
/* Direct access to the radio. Setting values incorrectly can damage
|
||||||
|
* the device. Applications should use ReceiverModel or TransmitterModel
|
||||||
|
* instead of calling these functions directly. */
|
||||||
namespace radio {
|
namespace radio {
|
||||||
|
|
||||||
static constexpr uint32_t ssp1_cpsr = 2;
|
static constexpr uint32_t ssp1_cpsr = 2;
|
||||||
@ -245,18 +248,7 @@ void set_antenna_bias(const bool on) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void disable() {
|
/*void enable(Configuration configuration) {
|
||||||
set_antenna_bias(false);
|
|
||||||
baseband_codec.set_mode(max5864::Mode::Shutdown);
|
|
||||||
second_if->set_mode(max2837::Mode::Standby);
|
|
||||||
first_if.disable();
|
|
||||||
set_rf_amp(false);
|
|
||||||
|
|
||||||
led_rx.off();
|
|
||||||
led_tx.off();
|
|
||||||
}
|
|
||||||
|
|
||||||
void enable(Configuration configuration) {
|
|
||||||
configure(configuration);
|
configure(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +260,17 @@ void configure(Configuration configuration) {
|
|||||||
set_baseband_rate(configuration.baseband_rate);
|
set_baseband_rate(configuration.baseband_rate);
|
||||||
set_baseband_filter_bandwidth(configuration.baseband_filter_bandwidth);
|
set_baseband_filter_bandwidth(configuration.baseband_filter_bandwidth);
|
||||||
set_direction(configuration.direction);
|
set_direction(configuration.direction);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void disable() {
|
||||||
|
set_antenna_bias(false);
|
||||||
|
baseband_codec.set_mode(max5864::Mode::Shutdown);
|
||||||
|
second_if->set_mode(max2837::Mode::Standby);
|
||||||
|
first_if.disable();
|
||||||
|
set_rf_amp(false);
|
||||||
|
|
||||||
|
led_rx.off();
|
||||||
|
led_tx.off();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace debug {
|
namespace debug {
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
/* Direct access to the radio. Setting values incorrectly can damage
|
||||||
|
* the device. Applications should use ReceiverModel or TransmitterModel
|
||||||
|
* instead of calling these functions directly. */
|
||||||
namespace radio {
|
namespace radio {
|
||||||
|
|
||||||
struct Configuration {
|
struct Configuration {
|
||||||
@ -51,8 +54,9 @@ void set_baseband_filter_bandwidth(const uint32_t bandwidth_minimum);
|
|||||||
void set_baseband_rate(const uint32_t rate);
|
void set_baseband_rate(const uint32_t rate);
|
||||||
void set_antenna_bias(const bool on);
|
void set_antenna_bias(const bool on);
|
||||||
|
|
||||||
void enable(Configuration configuration);
|
/* Use ReceiverModel or TransmitterModel instead. */
|
||||||
void configure(Configuration configuration);
|
// void enable(Configuration configuration);
|
||||||
|
// void configure(Configuration configuration);
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
namespace debug {
|
namespace debug {
|
||||||
|
@ -118,14 +118,14 @@ void ReceiverModel::set_vga(int32_t v_db) {
|
|||||||
update_vga();
|
update_vga();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ReceiverModel::tx_gain() const {
|
/*int32_t ReceiverModel::tx_gain() const {
|
||||||
return tx_gain_db_;
|
return tx_gain_db_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReceiverModel::set_tx_gain(int32_t v_db) {
|
void ReceiverModel::set_tx_gain(int32_t v_db) {
|
||||||
tx_gain_db_ = v_db;
|
tx_gain_db_ = v_db;
|
||||||
update_tx_gain();
|
update_tx_gain();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
uint32_t ReceiverModel::sampling_rate() const {
|
uint32_t ReceiverModel::sampling_rate() const {
|
||||||
return sampling_rate_;
|
return sampling_rate_;
|
||||||
@ -171,7 +171,7 @@ void ReceiverModel::enable() {
|
|||||||
update_rf_amp();
|
update_rf_amp();
|
||||||
update_lna();
|
update_lna();
|
||||||
update_vga();
|
update_vga();
|
||||||
update_tx_gain();
|
// update_tx_gain();
|
||||||
update_baseband_bandwidth();
|
update_baseband_bandwidth();
|
||||||
update_sampling_rate();
|
update_sampling_rate();
|
||||||
update_modulation();
|
update_modulation();
|
||||||
@ -185,7 +185,6 @@ void ReceiverModel::enable() {
|
|||||||
|
|
||||||
void ReceiverModel::disable() {
|
void ReceiverModel::disable() {
|
||||||
enabled_ = false;
|
enabled_ = false;
|
||||||
radio::set_antenna_bias(false);
|
|
||||||
|
|
||||||
// TODO: Responsibility for enabling/disabling the radio is muddy.
|
// TODO: Responsibility for enabling/disabling the radio is muddy.
|
||||||
// Some happens in ReceiverModel, some inside radio namespace.
|
// Some happens in ReceiverModel, some inside radio namespace.
|
||||||
@ -230,9 +229,9 @@ void ReceiverModel::update_vga() {
|
|||||||
radio::set_vga_gain(vga_gain_db_);
|
radio::set_vga_gain(vga_gain_db_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReceiverModel::update_tx_gain() {
|
/*void ReceiverModel::update_tx_gain() {
|
||||||
radio::set_tx_gain(tx_gain_db_);
|
radio::set_tx_gain(tx_gain_db_);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void ReceiverModel::set_am_configuration(const size_t n) {
|
void ReceiverModel::set_am_configuration(const size_t n) {
|
||||||
if (n < am_configs.size()) {
|
if (n < am_configs.size()) {
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "max283x.hpp"
|
#include "max283x.hpp"
|
||||||
#include "volume.hpp"
|
#include "volume.hpp"
|
||||||
|
|
||||||
|
// TODO: consider a base class for ReceiverModel & TransmitterModel.
|
||||||
class ReceiverModel {
|
class ReceiverModel {
|
||||||
public:
|
public:
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
@ -60,8 +61,9 @@ class ReceiverModel {
|
|||||||
int32_t vga() const;
|
int32_t vga() const;
|
||||||
void set_vga(int32_t v_db);
|
void set_vga(int32_t v_db);
|
||||||
|
|
||||||
int32_t tx_gain() const;
|
// TODO: Why does receiver need tx_gain?
|
||||||
void set_tx_gain(int32_t v_db);
|
// int32_t tx_gain() const;
|
||||||
|
// void set_tx_gain(int32_t v_db);
|
||||||
|
|
||||||
uint32_t sampling_rate() const;
|
uint32_t sampling_rate() const;
|
||||||
void set_sampling_rate(uint32_t v);
|
void set_sampling_rate(uint32_t v);
|
||||||
@ -87,7 +89,13 @@ class ReceiverModel {
|
|||||||
size_t wfm_configuration() const;
|
size_t wfm_configuration() const;
|
||||||
void set_wfm_configuration(const size_t n);
|
void set_wfm_configuration(const size_t n);
|
||||||
|
|
||||||
void set_configuration_without_init(const Mode new_mode, const rf::Frequency new_frequency_step, const size_t new_am_config_index, const size_t new_nbfm_config_index, const size_t new_wfm_config_index, uint8_t new_squelch_level);
|
void set_configuration_without_init(
|
||||||
|
const Mode new_mode,
|
||||||
|
const rf::Frequency new_frequency_step,
|
||||||
|
const size_t new_am_config_index,
|
||||||
|
const size_t new_nbfm_config_index,
|
||||||
|
const size_t new_wfm_config_index,
|
||||||
|
uint8_t new_squelch_level);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rf::Frequency frequency_step_{25000};
|
rf::Frequency frequency_step_{25000};
|
||||||
@ -96,7 +104,7 @@ class ReceiverModel {
|
|||||||
int32_t lna_gain_db_{32};
|
int32_t lna_gain_db_{32};
|
||||||
uint32_t baseband_bandwidth_{max283x::filter::bandwidth_minimum};
|
uint32_t baseband_bandwidth_{max283x::filter::bandwidth_minimum};
|
||||||
int32_t vga_gain_db_{32};
|
int32_t vga_gain_db_{32};
|
||||||
int32_t tx_gain_db_{47};
|
// int32_t tx_gain_db_{47};
|
||||||
Mode mode_{Mode::NarrowbandFMAudio};
|
Mode mode_{Mode::NarrowbandFMAudio};
|
||||||
uint32_t sampling_rate_{3072000};
|
uint32_t sampling_rate_{3072000};
|
||||||
size_t am_config_index = 0;
|
size_t am_config_index = 0;
|
||||||
@ -113,7 +121,7 @@ class ReceiverModel {
|
|||||||
void update_lna();
|
void update_lna();
|
||||||
void update_baseband_bandwidth();
|
void update_baseband_bandwidth();
|
||||||
void update_vga();
|
void update_vga();
|
||||||
void update_tx_gain();
|
// void update_tx_gain();
|
||||||
void update_sampling_rate();
|
void update_sampling_rate();
|
||||||
void update_headphone_volume();
|
void update_headphone_volume();
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@ void TransmitterModel::enable() {
|
|||||||
update_vga();
|
update_vga();
|
||||||
update_baseband_bandwidth();
|
update_baseband_bandwidth();
|
||||||
update_sampling_rate();
|
update_sampling_rate();
|
||||||
|
update_tx_gain();
|
||||||
|
|
||||||
led_tx.on();
|
led_tx.on();
|
||||||
signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
|
signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
|
||||||
@ -138,7 +139,6 @@ void TransmitterModel::enable() {
|
|||||||
|
|
||||||
void TransmitterModel::disable() {
|
void TransmitterModel::disable() {
|
||||||
enabled_ = false;
|
enabled_ = false;
|
||||||
radio::set_antenna_bias(false);
|
|
||||||
|
|
||||||
// TODO: Responsibility for enabling/disabling the radio is muddy.
|
// TODO: Responsibility for enabling/disabling the radio is muddy.
|
||||||
// Some happens in ReceiverModel, some inside radio namespace.
|
// Some happens in ReceiverModel, some inside radio namespace.
|
||||||
|
@ -307,11 +307,10 @@ void SystemStatusView::on_stealth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SystemStatusView::on_bias_tee() {
|
void SystemStatusView::on_bias_tee() {
|
||||||
if (!portapack::antenna_bias) {
|
if (!portapack::get_antenna_bias()) {
|
||||||
nav_.display_modal("Bias voltage", "Enable DC voltage on\nantenna connector?", YESNO, [this](bool v) {
|
nav_.display_modal("Bias voltage", "Enable DC voltage on\nantenna connector?", YESNO, [this](bool v) {
|
||||||
if (v) {
|
if (v) {
|
||||||
portapack::set_antenna_bias(true);
|
portapack::set_antenna_bias(true);
|
||||||
// radio::set_antenna_bias(true);
|
|
||||||
receiver_model.set_antenna_bias();
|
receiver_model.set_antenna_bias();
|
||||||
transmitter_model.set_antenna_bias();
|
transmitter_model.set_antenna_bias();
|
||||||
refresh();
|
refresh();
|
||||||
@ -319,9 +318,12 @@ void SystemStatusView::on_bias_tee() {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
portapack::set_antenna_bias(false);
|
portapack::set_antenna_bias(false);
|
||||||
// radio::set_antenna_bias(false);
|
|
||||||
receiver_model.set_antenna_bias();
|
receiver_model.set_antenna_bias();
|
||||||
transmitter_model.set_antenna_bias();
|
transmitter_model.set_antenna_bias();
|
||||||
|
|
||||||
|
// Ensure this is disabled. The models don't actually
|
||||||
|
// update the radio unless they are 'enabled_'.
|
||||||
|
radio::set_antenna_bias(false);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user