Skip to content

Commit

Permalink
Fix RSSI bar bug
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Sep 29, 2023
1 parent 99ef859 commit fd0e166
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 23 deletions.
17 changes: 15 additions & 2 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,23 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
#else
// toggle scanlist-1
// toggle scanlist-1 and scanlist 2
if (gScreenToDisplay != DISPLAY_SCANNER)
{
gTxVfo->SCANLIST1_PARTICIPATION = gTxVfo->SCANLIST1_PARTICIPATION ? 0 : 1;
if (gTxVfo->SCANLIST1_PARTICIPATION)
{
if (gTxVfo->SCANLIST2_PARTICIPATION)
gTxVfo->SCANLIST1_PARTICIPATION = 0;
else
gTxVfo->SCANLIST2_PARTICIPATION = 1;
}
else
{
if (gTxVfo->SCANLIST2_PARTICIPATION)
gTxVfo->SCANLIST2_PARTICIPATION = 0;
else
gTxVfo->SCANLIST1_PARTICIPATION = 1;
}
SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true);
gVfoConfigureMode = VFO_CONFIGURE;
gFlagResetVfos = true;
Expand Down
9 changes: 3 additions & 6 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,12 +744,9 @@ void BOARD_EEPROM_LoadMoreSettings(void)
memmove(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8);
memmove(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8);

// 3 bands, 4 * 16-bit values per band
// both my radios are -70dBm, -65dBm, -60dBm, -55dBm (0xB4, 0xBE, 0xC8, 0xD2)
// -93, -75, -57, -39 seems to be a better choice (0x86, 0xAA, 0xCE, 0xF2)
EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[0], 8);
memmove(gEEPROM_RSSI_CALIB[1], gEEPROM_RSSI_CALIB[0], 8);
memmove(gEEPROM_RSSI_CALIB[2], gEEPROM_RSSI_CALIB[0], 8);
// 8 * 16-bit values
EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[0], 8);
EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[1], 8);

EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12);
if (gBatteryCalibration[0] >= 5000)
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ uint8_t gEEPROM_1EC0_1[8];
uint8_t gEEPROM_1EC0_2[8];
uint8_t gEEPROM_1EC0_3[8];

uint16_t gEEPROM_RSSI_CALIB[3][4];
uint16_t gEEPROM_RSSI_CALIB[2][4];

uint16_t gEEPROM_1F8A;
uint16_t gEEPROM_1F8C;
Expand Down
2 changes: 1 addition & 1 deletion misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ extern uint8_t gEEPROM_1EC0_1[8];
extern uint8_t gEEPROM_1EC0_2[8];
extern uint8_t gEEPROM_1EC0_3[8];

extern uint16_t gEEPROM_RSSI_CALIB[3][4];
extern uint16_t gEEPROM_RSSI_CALIB[2][4];

extern uint16_t gEEPROM_1F8A;
extern uint16_t gEEPROM_1F8C;
Expand Down
5 changes: 3 additions & 2 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
if (gEeprom.VfoInfo[VFO].AM_mode)
{ // freq/chan is in AM mode
gEeprom.VfoInfo[VFO].SCRAMBLING_TYPE = 0;
gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use it on SSB
// gEeprom.VfoInfo[VFO].DTMF_DECODING_ENABLE = false; // no reason to disable DTMF decoding, aircraft use it on SSB
gEeprom.VfoInfo[VFO].freq_config_RX.CodeType = CODE_TYPE_OFF;
gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF;
}
Expand Down Expand Up @@ -749,7 +749,8 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
#if 0
// there's no reason the DTMF decoder can't be used in AM RX mode too
// aircraft comms use it on HF (AM and SSB)
if (gRxVfo->AM_mode || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED))
// if (gRxVfo->AM_mode || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED))
if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED)
{
BK4819_DisableDTMF();
}
Expand Down
25 changes: 14 additions & 11 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@
char s[16];
unsigned int i;

const unsigned int max_dB = -33;
const unsigned int min_dB = -127;
const int16_t max_dB = -33; // S9+40dB
const int16_t min_dB = -127; // S0

const unsigned int txt_width = 7 * 8; // 8 text chars
const unsigned int bar_x = txt_width + 4;
const unsigned int bar_width = LCD_WIDTH - 1 - bar_x;

const int16_t dBm = (rssi / 2) - 160;
const unsigned int clamped_dBm = (dBm < min_dB) ? min_dB : (dBm > max_dB) ? max_dB : dBm;
const unsigned int width = max_dB - min_dB;
const unsigned int len = (((clamped_dBm - min_dB) * bar_width) + (width / 2)) / width;
const int16_t clamped_dBm = (dBm <= min_dB) ? min_dB : (dBm >= max_dB) ? max_dB : dBm;
const unsigned int range_dB = max_dB - min_dB;
const unsigned int len = ((clamped_dBm - min_dB) * bar_width) / range_dB;

const unsigned int line = 3;
uint8_t *pLine = gFrameBuffer[line];
Expand Down Expand Up @@ -191,13 +191,18 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)

#else

// const int16_t dBm = (rssi / 2) - 160;
const uint8_t Line = (vfo == 0) ? 3 : 7;
uint8_t *pLine = gFrameBuffer[Line - 1];
// const int16_t dBm = (rssi / 2) - 160;

// TODO: sort out all 8 values from the eeprom

#if 0
//const unsigned int band = gRxVfo->Band;
const unsigned int band = 0;
// dBm -105 -100 -95 -90 -70 -65 -60 -55
// RSSI 110 120 130 140 180 190 200 210
// 0000C0 6E 00 78 00 82 00 8C 00 B4 00 BE 00 C8 00 D2 00
//
const unsigned int band = 1;
const int16_t level0 = gEEPROM_RSSI_CALIB[band][0];
const int16_t level1 = gEEPROM_RSSI_CALIB[band][1];
const int16_t level2 = gEEPROM_RSSI_CALIB[band][2];
Expand Down Expand Up @@ -716,9 +721,7 @@ void UI_DisplayMain(void)
if (gSetting_live_DTMF_decoder && gDTMF_ReceivedSaved[0] >= 32)
{ // show live DTMF decode
const unsigned int len = strlen(gDTMF_ReceivedSaved);
unsigned int idx = 0;
while ((len - idx) > (17 - 5)) // display the last 'n' on-screen fittable chars
idx++;
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // just the last 'n' chars
strcpy(String, "DTMF ");
strcat(String, gDTMF_ReceivedSaved + idx);
UI_PrintStringSmall(String, 2, 0, 3);
Expand Down

0 comments on commit fd0e166

Please sign in to comment.