Added RX gain control & UI modification

Thanks @euquiq for a more common solution to the bug.

Added RX gain control.
Now we have full gain controls!

Merged PTT and Voice activation into one option selector.(allowing RIGHT BUTTON to work with PTT off)
This commit is contained in:
dqs105 2020-08-22 14:57:55 +08:00 committed by GitHub
parent 2f54c11fea
commit 4197b5c083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 144 additions and 16 deletions

View File

@ -65,6 +65,8 @@ void MicTXView::set_tx(bool enable) {
rxaudio(false); //Then turn off audio RX rxaudio(false); //Then turn off audio RX
transmitting = true; transmitting = true;
configure_baseband(); configure_baseband();
transmitter_model.set_tx_gain(tx_gain);
transmitter_model.set_rf_amp(rf_amp);
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
} else { } else {
@ -133,6 +135,9 @@ void MicTXView::rxaudio(bool is_on) {
receiver_model.set_sampling_rate(3072000); receiver_model.set_sampling_rate(3072000);
receiver_model.set_baseband_bandwidth(1750000); receiver_model.set_baseband_bandwidth(1750000);
receiver_model.set_tuning_frequency(field_frequency.value()); //probably this too can be commented out. receiver_model.set_tuning_frequency(field_frequency.value()); //probably this too can be commented out.
receiver_model.set_lna(rx_lna);
receiver_model.set_vga(rx_vga);
receiver_model.set_rf_amp(rx_amp);
receiver_model.enable(); receiver_model.enable();
audio::output::start(); audio::output::start();
} else { //These incredibly convoluted steps are required for the vumeter to reappear when stopping RX. } else { //These incredibly convoluted steps are required for the vumeter to reappear when stopping RX.
@ -157,6 +162,12 @@ void MicTXView::on_headphone_volume_changed(int32_t v) {
//} //}
} }
void MicTXView::set_ptt_visibility(bool v) {
text_ptt_1.hidden(!v);
text_ptt_2.hidden(!v);
text_ptt_3.hidden(!v);
}
MicTXView::MicTXView( MicTXView::MicTXView(
NavigationView& nav NavigationView& nav
) )
@ -169,7 +180,8 @@ MicTXView::MicTXView(
&labels, &labels,
&vumeter, &vumeter,
&options_gain, &options_gain,
&check_va, // &check_va,
&field_va,
&field_va_level, &field_va_level,
&field_va_attack, &field_va_attack,
&field_va_decay, &field_va_decay,
@ -182,7 +194,12 @@ MicTXView::MicTXView(
&check_rxactive, &check_rxactive,
&field_volume, &field_volume,
&field_squelch, &field_squelch,
&text_ptt &field_rxlna,
&field_rxvga,
&field_rxamp,
&text_ptt_1,
&text_ptt_2,
&text_ptt_3
}); });
tone_keys_populate(options_tone_key); tone_keys_populate(options_tone_key);
@ -217,23 +234,56 @@ MicTXView::MicTXView(
}; };
field_bw.set_value(10); field_bw.set_value(10);
tx_gain = transmitter_model.tx_gain();
field_rfgain.on_change = [this](int32_t v) { field_rfgain.on_change = [this](int32_t v) {
transmitter_model.set_tx_gain(v); tx_gain = v;
};
field_rfgain.set_value(transmitter_model.tx_gain());
};
field_rfgain.set_value(tx_gain);
rf_amp = transmitter_model.rf_amp();
field_rfamp.on_change = [this](int32_t v) { field_rfamp.on_change = [this](int32_t v) {
transmitter_model.set_rf_amp((bool)v); rf_amp = (bool)v;
}; };
field_rfamp.set_value(transmitter_model.rf_amp() ? 14 : 0); field_rfamp.set_value(rf_amp ? 14 : 0);
/*
check_va.on_select = [this](Checkbox&, bool v) { check_va.on_select = [this](Checkbox&, bool v) {
va_enabled = v; va_enabled = v;
text_ptt.hidden(v); //hide / show PTT text text_ptt.hidden(v); //hide / show PTT text
check_rxactive.hidden(v); //hide / show the RX AUDIO check_rxactive.hidden(v); //hide / show the RX AUDIO
set_dirty(); //Refresh display set_dirty(); //Refresh display
}; };
*/
field_va.set_selected_index(1);
field_va.on_change = [this](size_t, int32_t v) {
switch(v) {
case 0:
va_enabled = 0;
this->set_ptt_visibility(0);
check_rxactive.hidden(0);
ptt_enabled = 0;
break;
case 1:
va_enabled = 0;
this->set_ptt_visibility(1);
check_rxactive.hidden(0);
ptt_enabled = 1;
break;
case 2:
if (!rx_enabled) {
va_enabled = 1;
this->set_ptt_visibility(0);
check_rxactive.hidden(1);
ptt_enabled = 0;
} else {
field_va.set_selected_index(1);
}
break;
}
set_dirty();
};
check_rogerbeep.on_select = [this](Checkbox&, bool v) { check_rogerbeep.on_select = [this](Checkbox&, bool v) {
rogerbeep_enabled = v; rogerbeep_enabled = v;
@ -258,7 +308,7 @@ MicTXView::MicTXView(
check_rxactive.on_select = [this](Checkbox&, bool v) { check_rxactive.on_select = [this](Checkbox&, bool v) {
// vumeter.set_value(0); //Start with a clean vumeter // vumeter.set_value(0); //Start with a clean vumeter
rx_enabled = v; rx_enabled = v;
check_va.hidden(v); //Hide or show voice activation // check_va.hidden(v); //Hide or show voice activation
rxaudio(v); //Activate-Deactivate audio rx accordingly rxaudio(v); //Activate-Deactivate audio rx accordingly
set_dirty(); //Refresh interface set_dirty(); //Refresh interface
}; };
@ -272,6 +322,28 @@ MicTXView::MicTXView(
field_squelch.set_value(0); field_squelch.set_value(0);
receiver_model.set_squelch_level(0); receiver_model.set_squelch_level(0);
rx_lna = receiver_model.lna();
field_rxlna.on_change = [this](int32_t v) {
rx_lna = v;
receiver_model.set_lna(v);
};
field_rxlna.set_value(rx_lna);
rx_vga = receiver_model.vga();
field_rxvga.on_change = [this](int32_t v) {
rx_vga = v;
receiver_model.set_vga(v);
};
field_rxvga.set_value(rx_vga);
rx_amp = receiver_model.rf_amp();
field_rxamp.on_change = [this](int32_t v) {
rx_amp = (bool)v;
receiver_model.set_rf_amp(rx_amp);
};
field_rxamp.set_value(rx_amp ? 14 : 0);
transmitter_model.set_sampling_rate(sampling_rate); transmitter_model.set_sampling_rate(sampling_rate);
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);

View File

@ -48,7 +48,7 @@ public:
// PTT: Enable through KeyEvent (only works with presses), disable by polling :( // PTT: Enable through KeyEvent (only works with presses), disable by polling :(
bool on_key(const KeyEvent key) { bool on_key(const KeyEvent key) {
if ((key == KeyEvent::Right) && (!va_enabled)) { if ((key == KeyEvent::Right) && (!va_enabled) && ptt_enabled) {
set_tx(true); set_tx(true);
return true; return true;
} else } else
@ -71,8 +71,11 @@ private:
void rxaudio(bool is_on); void rxaudio(bool is_on);
void on_headphone_volume_changed(int32_t v); void on_headphone_volume_changed(int32_t v);
void set_ptt_visibility(bool v);
bool transmitting { false }; bool transmitting { false };
bool va_enabled { false }; bool va_enabled { false };
bool ptt_enabled { true };
bool rogerbeep_enabled { false }; bool rogerbeep_enabled { false };
bool rx_enabled { false }; bool rx_enabled { false };
uint32_t tone_key_index { }; uint32_t tone_key_index { };
@ -83,6 +86,12 @@ private:
uint32_t decay_ms { }; uint32_t decay_ms { };
uint32_t attack_timer { 0 }; uint32_t attack_timer { 0 };
uint32_t decay_timer { 0 }; uint32_t decay_timer { 0 };
int32_t tx_gain { 47 };
bool rf_amp { false };
int32_t rx_lna { 32 };
int32_t rx_vga { 32 };
bool rx_amp { false };
Labels labels { Labels labels {
{ { 3 * 8, 1 * 8 }, "MIC. GAIN:", Color::light_grey() }, { { 3 * 8, 1 * 8 }, "MIC. GAIN:", Color::light_grey() },
@ -90,12 +99,16 @@ private:
{ { 3 * 8, 5 * 8 }, "BANDWIDTH: kHz", Color::light_grey() }, { { 3 * 8, 5 * 8 }, "BANDWIDTH: kHz", Color::light_grey() },
{ { 3 * 8, 7 * 8 }, "RFGAIN:", Color::light_grey() }, { { 3 * 8, 7 * 8 }, "RFGAIN:", Color::light_grey() },
{ {13 * 8, 7 * 8 }, "Amp:", Color::light_grey() }, { {13 * 8, 7 * 8 }, "Amp:", Color::light_grey() },
{ { 3 * 8, 10 * 8 }, "TX Activation:", Color::light_grey() },
{ { 7 * 8, 12 * 8 }, "LEVEL: /255", Color::light_grey() }, { { 7 * 8, 12 * 8 }, "LEVEL: /255", Color::light_grey() },
{ { 6 * 8, 14 * 8 }, "ATTACK: ms", Color::light_grey() }, { { 6 * 8, 14 * 8 }, "ATTACK: ms", Color::light_grey() },
{ { 7 * 8, 16 * 8 }, "DECAY: ms", Color::light_grey() }, { { 7 * 8, 16 * 8 }, "DECAY: ms", Color::light_grey() },
{ { 4 * 8, ( 19 * 8 ) - 2 }, "TONE KEY:", Color::light_grey() }, { { 4 * 8, ( 19 * 8 ) - 2 }, "TONE KEY:", Color::light_grey() },
{ { 9 * 8, 30 * 8 }, "VOL:", Color::light_grey() }, { { 9 * 8, 30 * 8 }, "VOL:", Color::light_grey() },
{ { 5 * 8, 32 * 8 }, "SQUELCH:", Color::light_grey() } { { 5 * 8, 32 * 8 }, "SQUELCH:", Color::light_grey() },
{ { 5 * 8, 34 * 8 }, "LNA:", Color::light_grey()},
{ {12 * 8, 34 * 8 }, "VGA:", Color::light_grey()},
{ {19 * 8, 34 * 8 }, "AMP:", Color::light_grey()}
}; };
VuMeter vumeter { VuMeter vumeter {
@ -140,13 +153,24 @@ private:
14, 14,
' ' ' '
}; };
/*
Checkbox check_va { Checkbox check_va {
{ 3 * 8, (10 * 8) - 4 }, { 3 * 8, (10 * 8) - 4 },
7, 7,
"Voice activation", "Voice activation",
false false
}; };
*/
OptionsField field_va {
{ 17 * 8, 10 * 8 },
3,
{
{" OFF", 0},
{" PTT", 1},
{"AUTO", 2}
}
};
NumberField field_va_level { NumberField field_va_level {
{ 13 * 8, 12 * 8 }, { 13 * 8, 12 * 8 },
@ -206,9 +230,41 @@ private:
' ', ' ',
}; };
Text text_ptt { NumberField field_rxlna {
{ 7 * 8, 35 * 8, 16 * 8, 16 }, { 9 * 8, 34 * 8 },
"PTT: RIGHT BUTTON" 2,
{ 0, 40 },
8,
' ',
};
NumberField field_rxvga {
{ 16 * 8, 34 * 8 },
2,
{ 0, 62 },
2,
' ',
};
NumberField field_rxamp {
{ 23 * 8, 34 * 8 },
2,
{ 0, 14 },
14,
' ',
};
Text text_ptt_1 {
{ 22 * 8, 13 * 8, 7 * 8, 8 },
"PTT: "
};
Text text_ptt_2 {
{ 22 * 8, 15 * 8, 7 * 8, 8 },
"RIGHT "
};
Text text_ptt_3 {
{ 22 * 8, 17 * 8, 7 * 8, 8 },
"BUTTON"
}; };