Merge pull request #1 from furrtek/master

Few improvements in ui_transmitter (#332)
This commit is contained in:
Erwin Ried 2020-04-18 13:17:39 +02:00 committed by GitHub
commit bf92aeb704
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 93 additions and 43 deletions

View File

@ -240,7 +240,6 @@ void LGEView::start_tx() {
tx_view.set_dirty(); tx_view.set_dirty();
} }
transmitter_model.set_sampling_rate(2280000); transmitter_model.set_sampling_rate(2280000);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -310,7 +310,6 @@ void ADSBTxView::start_tx() {
generate_frames(); generate_frames();
transmitter_model.set_sampling_rate(4000000U); transmitter_model.set_sampling_rate(4000000U);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(10000000); transmitter_model.set_baseband_bandwidth(10000000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -58,7 +58,6 @@ void APRSTXView::start_tx() {
transmitter_model.set_tuning_frequency(persistent_memory::tuned_frequency()); transmitter_model.set_tuning_frequency(persistent_memory::tuned_frequency());
transmitter_model.set_sampling_rate(AFSK_TX_SAMPLERATE); transmitter_model.set_sampling_rate(AFSK_TX_SAMPLERATE);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();
@ -108,7 +107,10 @@ APRSTXView::APRSTXView(NavigationView& nav) {
}; };
tx_view.on_edit_frequency = [this, &nav]() { tx_view.on_edit_frequency = [this, &nav]() {
return; auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
receiver_model.set_tuning_frequency(f);
};
}; };
tx_view.on_start = [this]() { tx_view.on_start = [this]() {

View File

@ -37,7 +37,6 @@ void BHTView::focus() {
void BHTView::start_tx() { void BHTView::start_tx() {
baseband::shutdown(); baseband::shutdown();
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
if (target_system == XYLOS) { if (target_system == XYLOS) {

View File

@ -68,7 +68,6 @@ void CoasterPagerView::start_tx() {
generate_frame(); generate_frame();
transmitter_model.set_sampling_rate(2280000); transmitter_model.set_sampling_rate(2280000);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -186,7 +186,6 @@ void KeyfobView::start_tx() {
size_t bitstream_length = generate_frame(); size_t bitstream_length = generate_frame();
transmitter_model.set_sampling_rate(OOK_SAMPLERATE); transmitter_model.set_sampling_rate(OOK_SAMPLERATE);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -130,7 +130,6 @@ void LCRView::start_tx(const bool scan) {
transmitter_model.set_tuning_frequency(persistent_memory::tuned_frequency()); transmitter_model.set_tuning_frequency(persistent_memory::tuned_frequency());
transmitter_model.set_sampling_rate(AFSK_TX_SAMPLERATE); transmitter_model.set_sampling_rate(AFSK_TX_SAMPLERATE);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -63,7 +63,6 @@ void MicTXView::set_tx(bool enable) {
if (enable) { if (enable) {
transmitting = true; transmitting = true;
configure_baseband(); configure_baseband();
transmitter_model.set_rf_amp(true);
transmitter_model.enable(); transmitter_model.enable();
portapack::pin_i2s0_rx_sda.mode(3); // This is already done in audio::init but gets changed by the CPLD overlay reprogramming portapack::pin_i2s0_rx_sda.mode(3); // This is already done in audio::init but gets changed by the CPLD overlay reprogramming
//gpio_tx.write(1); //gpio_tx.write(1);
@ -75,7 +74,6 @@ void MicTXView::set_tx(bool enable) {
} else { } else {
transmitting = false; transmitting = false;
configure_baseband(); configure_baseband();
transmitter_model.set_rf_amp(false);
transmitter_model.disable(); transmitter_model.disable();
//gpio_tx.write(0); //gpio_tx.write(0);
//led_tx.off(); //led_tx.off();
@ -207,7 +205,6 @@ MicTXView::MicTXView(
field_va_decay.set_value(1000); field_va_decay.set_value(1000);
transmitter_model.set_sampling_rate(sampling_rate); transmitter_model.set_sampling_rate(sampling_rate);
transmitter_model.set_rf_amp(false);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
set_tx(false); set_tx(false);

View File

@ -100,7 +100,6 @@ bool MorseView::start_tx() {
progressbar.set_max(symbol_count); progressbar.set_max(symbol_count);
transmitter_model.set_sampling_rate(1536000U); transmitter_model.set_sampling_rate(1536000U);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -79,9 +79,6 @@ bool POCSAGTXView::start_tx() {
progressbar.set_max(total_frames); progressbar.set_max(total_frames);
transmitter_model.set_sampling_rate(2280000); transmitter_model.set_sampling_rate(2280000);
transmitter_model.set_rf_amp(true);
transmitter_model.set_lna(40);
transmitter_model.set_vga(40);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -204,7 +204,6 @@ void RDSView::start_tx() {
frame_datetime.clear(); frame_datetime.clear();
transmitter_model.set_sampling_rate(2280000U); transmitter_model.set_sampling_rate(2280000U);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -166,7 +166,6 @@ void SSTVTXView::start_tx() {
prepare_scanline(); // Preload one scanline prepare_scanline(); // Preload one scanline
transmitter_model.set_sampling_rate(3072000U); transmitter_model.set_sampling_rate(3072000U);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();

View File

@ -66,7 +66,7 @@ public:
private: private:
bool enabled_ { false }; bool enabled_ { false };
bool rf_amp_ { true }; bool rf_amp_ { false };
int32_t lna_gain_db_ { 0 }; int32_t lna_gain_db_ { 0 };
uint32_t channel_bandwidth_ { 1 }; uint32_t channel_bandwidth_ { 1 };
uint32_t baseband_bandwidth_ { max2837::filter::bandwidth_minimum }; uint32_t baseband_bandwidth_ { max2837::filter::bandwidth_minimum };

View File

@ -33,24 +33,6 @@ using namespace portapack;
namespace ui { namespace ui {
/* TXGainField **********************************************************/
TXGainField::TXGainField(
Point parent_pos
) : NumberField {
parent_pos, 2,
{ max2837::tx::gain_db_range.minimum, max2837::tx::gain_db_range.maximum },
max2837::tx::gain_db_step,
' ',
}
{
set_value(transmitter_model.tx_gain());
on_change = [](int32_t v) {
transmitter_model.set_tx_gain(v);
};
}
/* TransmitterView *******************************************************/ /* TransmitterView *******************************************************/
void TransmitterView::paint(Painter& painter) { void TransmitterView::paint(Painter& painter) {
@ -79,6 +61,34 @@ void TransmitterView::on_channel_bandwidth_changed(uint32_t channel_bandwidth) {
transmitter_model.set_channel_bandwidth(channel_bandwidth); transmitter_model.set_channel_bandwidth(channel_bandwidth);
} }
void TransmitterView::on_tx_gain_changed(int32_t tx_gain) {
transmitter_model.set_tx_gain(tx_gain);
update_gainlevel_styles();
}
void TransmitterView::on_tx_amp_changed(bool rf_amp) {
transmitter_model.set_rf_amp(rf_amp);
update_gainlevel_styles();
}
void TransmitterView::update_gainlevel_styles() {
const Style *new_style_ptr = NULL;
int8_t tot_gain = transmitter_model.tx_gain() + (transmitter_model.rf_amp() ? 14 : 0);
if(tot_gain > POWER_THRESHOLD_HIGH) {
new_style_ptr = &style_power_high;
} else if(tot_gain > POWER_THRESHOLD_MED) {
new_style_ptr = &style_power_med;
} else if(tot_gain > POWER_THRESHOLD_LOW) {
new_style_ptr = &style_power_low;
}
field_gain.set_style(new_style_ptr);
text_gain.set_style(new_style_ptr);
field_amp.set_style(new_style_ptr);
text_amp.set_style(new_style_ptr);
}
void TransmitterView::set_transmitting(const bool transmitting) { void TransmitterView::set_transmitting(const bool transmitting) {
if (transmitting) { if (transmitting) {
button_start.set_text("STOP"); button_start.set_text("STOP");
@ -93,6 +103,11 @@ void TransmitterView::set_transmitting(const bool transmitting) {
void TransmitterView::on_show() { void TransmitterView::on_show() {
field_frequency.set_value(transmitter_model.tuning_frequency()); field_frequency.set_value(transmitter_model.tuning_frequency());
field_gain.set_value(transmitter_model.tx_gain());
field_amp.set_value(transmitter_model.rf_amp() ? 14 : 0);
update_gainlevel_styles();
} }
void TransmitterView::focus() { void TransmitterView::focus() {
@ -109,7 +124,9 @@ TransmitterView::TransmitterView(
&field_frequency, &field_frequency,
&text_gain, &text_gain,
&field_gain, &field_gain,
&button_start &button_start,
&text_amp,
&field_amp,
}); });
set_transmitting(false); set_transmitting(false);
@ -140,8 +157,13 @@ TransmitterView::TransmitterView(
if (on_edit_frequency) if (on_edit_frequency)
on_edit_frequency(); on_edit_frequency();
}; };
field_frequency.on_change = [this](rf::Frequency f) {
transmitter_model.set_tuning_frequency(f); field_gain.on_change = [this](uint32_t tx_gain) {
on_tx_gain_changed(tx_gain);
};
field_amp.on_change = [this](uint32_t rf_amp) {
on_tx_amp_changed((bool) rf_amp);
}; };
button_start.on_select = [this](Button&){ button_start.on_select = [this](Button&){

View File

@ -37,6 +37,10 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#define POWER_THRESHOLD_HIGH 47
#define POWER_THRESHOLD_MED 38
#define POWER_THRESHOLD_LOW 17
namespace ui { namespace ui {
class TXGainField : public NumberField { class TXGainField : public NumberField {
@ -83,6 +87,21 @@ private:
.background = Color::black(), .background = Color::black(),
.foreground = Color::dark_grey(), .foreground = Color::dark_grey(),
}; };
const Style style_power_low {
.font = font::fixed_8x16,
.background = Color::black(),
.foreground = Color::yellow(),
};
const Style style_power_med {
.font = font::fixed_8x16,
.background = Color::black(),
.foreground = Color::orange(),
};
const Style style_power_high {
.font = font::fixed_8x16,
.background = Color::black(),
.foreground = Color::red(),
};
bool lock_ { false }; bool lock_ { false };
bool transmitting_ { false }; bool transmitting_ { false };
@ -95,8 +114,13 @@ private:
{ 0, 3 * 8, 5 * 8, 1 * 16 }, { 0, 3 * 8, 5 * 8, 1 * 16 },
"Gain:" "Gain:"
}; };
TXGainField field_gain {
{ 5 * 8, 3 * 8 } NumberField field_gain {
{ 5 * 8, 3 * 8 },
2,
{ max2837::tx::gain_db_range.minimum, max2837::tx::gain_db_range.maximum },
max2837::tx::gain_db_step,
' '
}; };
Text text_bw { Text text_bw {
@ -111,6 +135,19 @@ private:
' ' ' '
}; };
Text text_amp {
{ 11 * 8, 3 * 8, 5 * 8, 1 * 16 },
"Amp:"
};
NumberField field_amp {
{ 16 * 8, 3 * 8 },
2,
{ 0, 14 },
14,
' '
};
Button button_start { Button button_start {
{ 21 * 8, 1 * 8, 9 * 8, 32 }, { 21 * 8, 1 * 8, 9 * 8, 32 },
"START" "START"
@ -118,6 +155,10 @@ private:
void on_tuning_frequency_changed(rf::Frequency f); void on_tuning_frequency_changed(rf::Frequency f);
void on_channel_bandwidth_changed(uint32_t channel_bandwidth); void on_channel_bandwidth_changed(uint32_t channel_bandwidth);
void on_tx_gain_changed(int32_t tx_gain);
void on_tx_amp_changed(bool rf_amp);
void update_gainlevel_styles(void);
}; };
} /* namespace ui */ } /* namespace ui */