Tidy ups, readme, comments

This commit is contained in:
OneOfEleven 2023-09-22 22:02:03 +01:00
parent 3fb581760e
commit 2643d197c6
6 changed files with 39 additions and 36 deletions

View File

@ -31,6 +31,7 @@ ENABLE_COMPANDER := 1 compander option (per channel)
ENABLE_SHOW_CHARGE_LEVEL := 1 show the charge level when the radio is on charge
ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right)
ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation - ignore the on-screen RSSI (for now)
ENABLE_SQUELCH1_LOWER := 1 adjusts squelch setting '1' to be more sensitive - I plan to let user adjust it in the menu
ENABLE_AUDIO_BAR := 0 experimental, display an audo bar level when TX'ing
#ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented - single VFO on display when possible
#ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter

View File

@ -84,14 +84,14 @@ const uint16_t orig_pga = 6; // -3dB
uint16_t sum; // sum of all samples in the buffer
} moving_avg_rssi;
unsigned int am_fix_increase_counter = 0;
unsigned int am_gain_hold_counter = 0;
void APP_reset_AM_fix(void)
{
// reset the moving average filter
memset(&moving_avg_rssi, 0, sizeof(moving_avg_rssi));
am_fix_increase_counter = 0;
am_gain_hold_counter = 0;
}
#endif
@ -1403,27 +1403,27 @@ void APP_CheckKeys(void)
// -87dBm, any higher and the AM demodulator starts to saturate/clip (distort)
const uint16_t desired_rssi = (-87 + 160) * 2; // dBm to ADC sample
// start with current settings
// start with the current gain settings
register uint16_t new_lna_short = am_lna_short;
register uint16_t new_lna = am_lna;
register uint16_t new_mixer = am_mixer;
register uint16_t new_pga = am_pga;
// current RX frequency
const uint32_t rx_frequency = gRxVfo->pRX->Frequency;
// max gains to use
// uint16_t max_lna_short = orig_lna_short;
// uint16_t max_lna_short = orig_lna_short; // we're not altering this one
uint16_t max_lna = orig_lna;
uint16_t max_mixer = orig_mixer;
uint16_t max_pga = orig_pga;
const uint32_t rx_frequency = gRxVfo->pRX->Frequency;
// the RX gain abrutly reduces above this frequency
if (rx_frequency <= 22640000)
if (rx_frequency <= 22640000) // the RX gain abrutly reduces above this frequency
{
max_pga = 7;
}
else
{
{ // allow a bit more gain
// max_lna = 4;
max_lna = 7;
max_pga = 7;
@ -1443,7 +1443,8 @@ void APP_CheckKeys(void)
moving_avg_rssi.index = 0; // wrap-a-round
rssi = moving_avg_rssi.sum / moving_avg_rssi.count; // compute the average of the past 'n' samples
// the register adjustments below to be more inteligent in order to maintain a good stable setting
// the register adjustments below need to be more intelligent
// in order to maintain a good stable setting
if (rssi > desired_rssi)
{ // decrease gain
@ -1469,39 +1470,40 @@ void APP_CheckKeys(void)
// if (new_lna_short > 0)
// new_lna_short--;
am_fix_increase_counter = 50; // 500ms
am_gain_hold_counter = 50; // 500ms
}
if (am_fix_increase_counter > 0)
am_fix_increase_counter--;
if (am_gain_hold_counter > 0)
am_gain_hold_counter--;
if (am_fix_increase_counter == 0)
if (am_gain_hold_counter == 0)
{ // hold has been released, we're now free to increase gain
if (rssi < (desired_rssi - 10)) // 5dB hysterisis - to help prevent gain hunting
{ // increase gain
if (rssi < (desired_rssi - 10))
{ // increase gain
if (new_pga < max_pga)
{
new_pga++;
am_fix_increase_counter = 10; // 100ms
am_gain_hold_counter = 10; // 100ms
}
else
if (new_mixer < max_mixer)
{
new_mixer++;
am_fix_increase_counter = 10; // 100ms
am_gain_hold_counter = 10; // 100ms
}
else
if (new_lna < max_lna)
{
new_lna++;
am_fix_increase_counter = 10; // 100ms
am_gain_hold_counter = 10; // 100ms
}
// else
// if (new_lna_short < max_lna_short)
// {
// new_lna_short++;
// am_fix_increase_counter = 10; // 100ms
// am_gain_hold_counter = 10; // 100ms
// }
}
}
@ -1511,6 +1513,7 @@ void APP_CheckKeys(void)
// apply the new gain settings to the front end
// remember the new gain settings - for the next time this function is called
am_lna_short = new_lna_short;
am_lna = new_lna;
am_mixer = new_mixer;
@ -1519,7 +1522,6 @@ void APP_CheckKeys(void)
BK4819_WriteRegister(BK4819_REG_13, (am_lna_short << 8) | (am_lna << 5) | (am_mixer << 3) | (am_pga << 0));
// TODO: offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we've made here

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
#ifdef GIT_HASH
#define VER GIT_HASH
#else
#define VER "230922"
#define VER "230923"
#endif
const char Version[] = "OEFW-"VER;