Skip to content

Commit

Permalink
Fix frequency band error from yesterday
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Oct 3, 2023
1 parent 010ea03 commit c5c86d0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 50 deletions.
2 changes: 1 addition & 1 deletion am_fix.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@

#if 0
if (gain_table_index[vfo] == gain_table_index_prev[vfo])
return; // no gain change
return; // no gain change - this is to reduce writing to the BK chip on ever call
#endif

#endif
Expand Down
76 changes: 31 additions & 45 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,47 +543,33 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)

// ******************************************

// original setting
uint16_t lna_short = orig_lna_short;
uint16_t lna = orig_lna;
uint16_t mixer = orig_mixer;
uint16_t pga = orig_pga;

if (gRxVfo->AM_mode)
{ // AM
/*
#ifndef ENABLE_AM_FIX
const uint32_t rx_frequency = gRxVfo->pRX->Frequency;
// the RX gain abrutly reduces above this frequency
// I guess this is (one of) the freq the hardware switches the front ends over ?
if (rx_frequency <= 22640000)
{ // decrease front end gain - AM demodulator saturates at a slightly higher signal level
lna_short = 3; // 3 original
lna = 2; // 2 original
mixer = 3; // 3 original
pga = 3; // 6 original, 3 reduced
}
else
{ // increase the front end to compensate the reduced gain, but more gain decreases dynamic range :(
lna_short = 3; // 3 original
lna = 4; // 2 original, 4 increased
mixer = 3; // 3 original
pga = 7; // 6 original, 7 increased
}
#endif
*/
// what do these 4 other gain settings do ???
//BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 000000 11 011 11 011
//BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 000000 10 011 11 011
//BK4819_WriteRegister(BK4819_REG_10, 0x007A); // 000000 00 011 11 010
//BK4819_WriteRegister(BK4819_REG_14, 0x0019); // 000000 00 000 11 001
{
// original setting
uint16_t lna_short = orig_lna_short;
uint16_t lna = orig_lna;
uint16_t mixer = orig_mixer;
uint16_t pga = orig_pga;

#ifdef ENABLE_AM_FIX


// TODO:

gNeverUsed = 0;
}

// apply the front end gain settings
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
// if (gRxVfo->AM_mode)
// { // AM RX
// if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix)
// {
// AM_fix_10ms(gEeprom.RX_CHANNEL);
// }
// }
// else
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
#else
// apply the front end gain settings
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
#endif
}

// ******************************************

Expand Down Expand Up @@ -1739,7 +1725,7 @@ void APP_TimeSlice500ms(void)
{
// gReducedService = true; // a serial config upload/download is in progress
}

// Skipped authentic device check

#ifdef ENABLE_FMRADIO
Expand Down Expand Up @@ -1794,7 +1780,7 @@ void APP_TimeSlice500ms(void)
gUpdateDisplay = true;
#endif
}

if (gCurrentFunction != FUNCTION_POWER_SAVE)
updateRSSI(gEeprom.RX_CHANNEL);

Expand All @@ -1817,7 +1803,7 @@ void APP_TimeSlice500ms(void)
#endif
{
bool exit_menu = false;

if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode)
{
if (--gKeyLockCountdown == 0)
Expand All @@ -1829,11 +1815,11 @@ void APP_TimeSlice500ms(void)
if (gMenuCountdown > 0)
if (--gMenuCountdown == 0)
exit_menu = true; // exit menu mode

if (exit_menu)
{
gMenuCountdown = 0;

if (gEeprom.BACKLIGHT == 0 && gScreenToDisplay == DISPLAY_MENU)
{
gBacklightCountdown = 0;
Expand Down Expand Up @@ -2127,7 +2113,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
if (gScreenToDisplay == DISPLAY_MENU) // 1of11
gMenuCountdown = menu_timeout_500ms;

BACKLIGHT_TurnOn();

if (gDTMF_DecodeRingCountdown_500ms > 0)
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
1 change: 0 additions & 1 deletion misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ uint8_t gScanDelay_10ms;
uint8_t gAircopySendCountdown;
#endif
uint8_t gFSKWriteIndex;
uint8_t gNeverUsed;

#ifdef ENABLE_NOAA
bool gIsNoaaMode;
Expand Down
1 change: 0 additions & 1 deletion misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ extern uint8_t gScanDelay_10ms;
extern uint8_t gAircopySendCountdown;
#endif
extern uint8_t gFSKWriteIndex;
extern uint8_t gNeverUsed;
#ifdef ENABLE_NOAA
extern bool gIsNoaaMode;
extern uint8_t gNoaaChannel;
Expand Down
4 changes: 2 additions & 2 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
if (Frequency < frequencyBandTable[Band].lower)
Frequency = frequencyBandTable[Band].lower;
else
if (Frequency > frequencyBandTable[Band + 1].upper)
Frequency = frequencyBandTable[Band + 1].upper;
if (Frequency > frequencyBandTable[Band].upper)
Frequency = frequencyBandTable[Band].upper;
else
if (Channel >= FREQ_CHANNEL_FIRST)
Frequency = FREQUENCY_FloorToStep(Frequency, gEeprom.VfoInfo[VFO].StepFrequency, frequencyBandTable[Band].lower);
Expand Down

0 comments on commit c5c86d0

Please sign in to comment.