mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-05-18 16:01:18 +03:00
Limit screen update rate in AM fixer
This commit is contained in:
parent
8acbfbc80d
commit
9d178c549a
63
am_fix.c
63
am_fix.c
@ -296,6 +296,10 @@ const uint8_t orig_pga = 6; // -3dB
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
unsigned int counter = 0;
|
||||||
|
|
||||||
|
int16_t orig_dB_gain = -17;
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
#ifdef ENABLE_AM_FIX_TEST1
|
||||||
unsigned int am_fix_gain_table_index[2] = {1 + gSetting_AM_fix_test1, 1 + gSetting_AM_fix_test1};
|
unsigned int am_fix_gain_table_index[2] = {1 + gSetting_AM_fix_test1, 1 + gSetting_AM_fix_test1};
|
||||||
#else
|
#else
|
||||||
@ -317,26 +321,23 @@ const uint8_t orig_pga = 6; // -3dB
|
|||||||
// used to limit the max front end gain
|
// used to limit the max front end gain
|
||||||
unsigned int max_index = ARRAY_SIZE(am_fix_gain_table) - 1;
|
unsigned int max_index = ARRAY_SIZE(am_fix_gain_table) - 1;
|
||||||
|
|
||||||
void AM_fix_reset(const int vfo)
|
void AM_fix_init(void)
|
||||||
{ // reset the AM fixer
|
{
|
||||||
|
/* unsigned int i;
|
||||||
prev_rssi[vfo] = 0;
|
for (i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
am_gain_hold_counter[vfo] = 0;
|
|
||||||
|
|
||||||
rssi_db_gain_diff[vfo] = 0;
|
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_TEST1
|
#ifdef ENABLE_AM_FIX_TEST1
|
||||||
am_fix_gain_table_index[vfo] = 1 + gSetting_AM_fix_test1;
|
am_fix_gain_table_index[i] = 1 + gSetting_AM_fix_test1;
|
||||||
#else
|
#else
|
||||||
am_fix_gain_table_index[vfo] = original_index; // re-start with original QS setting
|
am_fix_gain_table_index[i] = original_index; // re-start with original QS setting
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
am_fix_gain_table_index_prev[vfo] = 0;
|
*/
|
||||||
|
orig_dB_gain = lna_short_dB[orig_lna_short] + lna_dB[orig_lna] + mixer_dB[orig_mixer] + pga_dB[orig_pga];
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{ // set the maximum gain we want to use
|
{ // set the maximum gain we want to use
|
||||||
// const int16_t max_gain_dB = lna_short_dB[orig_lna_short] + lna_dB[orig_lna] + mixer_dB[orig_mixer] + pga_dB[orig_pga];
|
// const int16_t max_gain_dB = orig_dB_gain;
|
||||||
const int16_t max_gain_dB = -10;
|
const int16_t max_gain_dB = -10;
|
||||||
max_index = ARRAY_SIZE(am_fix_gain_table);
|
max_index = ARRAY_SIZE(am_fix_gain_table);
|
||||||
while (--max_index > 1)
|
while (--max_index > 1)
|
||||||
@ -355,6 +356,26 @@ const uint8_t orig_pga = 6; // -3dB
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AM_fix_reset(const int vfo)
|
||||||
|
{ // reset the AM fixer
|
||||||
|
|
||||||
|
prev_rssi[vfo] = 0;
|
||||||
|
|
||||||
|
am_gain_hold_counter[vfo] = 0;
|
||||||
|
|
||||||
|
rssi_db_gain_diff[vfo] = 0;
|
||||||
|
|
||||||
|
#ifdef ENABLE_AM_FIX_TEST1
|
||||||
|
am_fix_gain_table_index[vfo] = 1 + gSetting_AM_fix_test1;
|
||||||
|
#else
|
||||||
|
am_fix_gain_table_index[vfo] = original_index; // re-start with original QS setting
|
||||||
|
#endif
|
||||||
|
|
||||||
|
am_fix_gain_table_index_prev[vfo] = 0;
|
||||||
|
|
||||||
|
// AM_fix_init(); // bootup calls this
|
||||||
|
}
|
||||||
|
|
||||||
// adjust the RX RF gain to try and prevent the AM demodulator from
|
// adjust the RX RF gain to try and prevent the AM demodulator from
|
||||||
// saturating/overloading/clipping (distorted AM audio)
|
// saturating/overloading/clipping (distorted AM audio)
|
||||||
//
|
//
|
||||||
@ -372,6 +393,8 @@ const uint8_t orig_pga = 6; // -3dB
|
|||||||
const int16_t desired_rssi = (-89 + 160) * 2; // dBm to ADC sample
|
const int16_t desired_rssi = (-89 + 160) * 2; // dBm to ADC sample
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
|
||||||
// but we're not in FM mode, we're in AM mode
|
// but we're not in FM mode, we're in AM mode
|
||||||
|
|
||||||
switch (gCurrentFunction)
|
switch (gCurrentFunction)
|
||||||
@ -404,7 +427,7 @@ const uint8_t orig_pga = 6; // -3dB
|
|||||||
if (gCurrentRSSI[vfo] != new_rssi)
|
if (gCurrentRSSI[vfo] != new_rssi)
|
||||||
{
|
{
|
||||||
gCurrentRSSI[vfo] = new_rssi;
|
gCurrentRSSI[vfo] = new_rssi;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = ((counter & 15u) == 0); // limit the screen update rate to once every 150ms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,16 +528,14 @@ const uint8_t orig_pga = 6; // -3dB
|
|||||||
const uint8_t lna = am_fix_gain_table[index].lna;
|
const uint8_t lna = am_fix_gain_table[index].lna;
|
||||||
const uint8_t mixer = am_fix_gain_table[index].mixer;
|
const uint8_t mixer = am_fix_gain_table[index].mixer;
|
||||||
const uint8_t pga = am_fix_gain_table[index].pga;
|
const uint8_t pga = am_fix_gain_table[index].pga;
|
||||||
|
const int16_t gain_dB = lna_short_dB[lna_short] + lna_dB[lna] + mixer_dB[mixer] + pga_dB[pga];
|
||||||
const int16_t orig_dB_gain = lna_short_dB[orig_lna_short] + lna_dB[orig_lna] + mixer_dB[orig_mixer] + pga_dB[orig_pga];
|
|
||||||
const int16_t am_dB_gain = lna_short_dB[lna_short] + lna_dB[lna] + mixer_dB[mixer] + pga_dB[pga];
|
|
||||||
|
|
||||||
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
|
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
|
||||||
|
|
||||||
// offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we make
|
// offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we make
|
||||||
|
|
||||||
// gain difference from original QS setting
|
// gain difference from original QS setting
|
||||||
rssi_db_gain_diff[vfo] = am_dB_gain - orig_dB_gain;
|
rssi_db_gain_diff[vfo] = gain_dB - orig_dB_gain;
|
||||||
|
|
||||||
// remember the new table index
|
// remember the new table index
|
||||||
am_fix_gain_table_index_prev[vfo] = index;
|
am_fix_gain_table_index_prev[vfo] = index;
|
||||||
@ -524,13 +545,13 @@ const uint8_t orig_pga = 6; // -3dB
|
|||||||
if (gCurrentRSSI[vfo] != new_rssi)
|
if (gCurrentRSSI[vfo] != new_rssi)
|
||||||
{
|
{
|
||||||
gCurrentRSSI[vfo] = new_rssi;
|
gCurrentRSSI[vfo] = new_rssi;
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = ((counter & 15u) == 0); // limit the screen update rate to once every 150ms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
gUpdateDisplay = true;
|
gUpdateDisplay = ((counter & 15u) == 0); // limit the screen update rate to once every 150ms
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
am_fix.h
1
am_fix.h
@ -28,6 +28,7 @@ extern const uint8_t orig_pga;
|
|||||||
#ifdef ENABLE_AM_FIX
|
#ifdef ENABLE_AM_FIX
|
||||||
extern int16_t rssi_db_gain_diff[2];
|
extern int16_t rssi_db_gain_diff[2];
|
||||||
|
|
||||||
|
void AM_fix_init(void);
|
||||||
void AM_fix_reset(const int vfo);
|
void AM_fix_reset(const int vfo);
|
||||||
void AM_fix_adjust_frontEnd_10ms(const int vfo);
|
void AM_fix_adjust_frontEnd_10ms(const int vfo);
|
||||||
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
#ifdef ENABLE_AM_FIX_SHOW_DATA
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
7
main.c
7
main.c
@ -17,6 +17,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h> // NULL
|
#include <stdio.h> // NULL
|
||||||
|
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
#include "am_fix.h"
|
||||||
|
#endif
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/dtmf.h"
|
#include "app/dtmf.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
@ -94,6 +97,10 @@ void Main(void)
|
|||||||
|
|
||||||
BATTERY_GetReadings(false);
|
BATTERY_GetReadings(false);
|
||||||
|
|
||||||
|
#ifdef ENABLE_AM_FIX
|
||||||
|
AM_fix_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
// count the number of menu list items
|
// count the number of menu list items
|
||||||
gMenuListCount = 0;
|
gMenuListCount = 0;
|
||||||
while (MenuList[gMenuListCount].name[0] != '\0')
|
while (MenuList[gMenuListCount].name[0] != '\0')
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
del /S /Q *.~*
|
del /S /Q *.~*
|
||||||
del /S /Q *.map
|
del /S /Q *.map
|
||||||
del /S /Q *.tds
|
del /S /Q *.tds
|
||||||
@ -10,8 +11,14 @@ del /S /Q *.ilf
|
|||||||
del /S /Q *.ils
|
del /S /Q *.ils
|
||||||
del /S /Q *.dcu
|
del /S /Q *.dcu
|
||||||
del /S /Q *.dsk
|
del /S /Q *.dsk
|
||||||
|
|
||||||
rd /S /Q Debug
|
rd /S /Q Debug
|
||||||
rd /S /Q Release
|
rd /S /Q Release
|
||||||
rd /S /Q ipch
|
rd /S /Q ipch
|
||||||
|
|
||||||
|
del /S gain_table.c
|
||||||
|
del /S uv-k5_small.c
|
||||||
|
del /S uv-k5_small_bold.c
|
||||||
|
|
||||||
::pause
|
::pause
|
||||||
@echo on
|
@echo on
|
||||||
|
Loading…
x
Reference in New Issue
Block a user