Fixed RSSI calibration

This commit is contained in:
Krzysiek Egzmont 2023-10-16 12:22:56 +02:00
parent ec4bec5b1f
commit d817ff7e6a
7 changed files with 19 additions and 40 deletions

View File

@ -505,7 +505,7 @@ void MENU_AcceptSetting(void)
gEeprom.VOX_SWITCH = gSubMenuSelection != 0; gEeprom.VOX_SWITCH = gSubMenuSelection != 0;
if (gEeprom.VOX_SWITCH) if (gEeprom.VOX_SWITCH)
gEeprom.VOX_LEVEL = gSubMenuSelection - 1; gEeprom.VOX_LEVEL = gSubMenuSelection - 1;
BOARD_EEPROM_LoadMoreSettings(); BOARD_EEPROM_LoadCalibration();
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
gUpdateStatus = true; gUpdateStatus = true;
break; break;
@ -579,7 +579,7 @@ void MENU_AcceptSetting(void)
case MENU_MIC: case MENU_MIC:
gEeprom.MIC_SENSITIVITY = gSubMenuSelection; gEeprom.MIC_SENSITIVITY = gSubMenuSelection;
BOARD_EEPROM_LoadMoreSettings(); BOARD_EEPROM_LoadCalibration();
gFlagReconfigureVfos = true; gFlagReconfigureVfos = true;
break; break;

10
board.c
View File

@ -739,14 +739,14 @@ void BOARD_EEPROM_Init(void)
} }
} }
void BOARD_EEPROM_LoadMoreSettings(void) void BOARD_EEPROM_LoadCalibration(void)
{ {
// uint8_t Mic; // uint8_t Mic;
EEPROM_ReadBuffer(0x1EC0, gEEPROM_1EC0_0, 8); EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[3], 8);
memmove(gEEPROM_1EC0_1, gEEPROM_1EC0_0, 8); memcpy(gEEPROM_RSSI_CALIB[4], gEEPROM_RSSI_CALIB[3], 8);
memmove(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8); memcpy(gEEPROM_RSSI_CALIB[5], gEEPROM_RSSI_CALIB[3], 8);
memmove(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8); memcpy(gEEPROM_RSSI_CALIB[6], gEEPROM_RSSI_CALIB[3], 8);
// 8 * 16-bit values // 8 * 16-bit values
EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[0], 8); EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[0], 8);

View File

@ -27,7 +27,7 @@ void BOARD_ADC_Init(void);
void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent); void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
void BOARD_Init(void); void BOARD_Init(void);
void BOARD_EEPROM_Init(void); void BOARD_EEPROM_Init(void);
void BOARD_EEPROM_LoadMoreSettings(void); void BOARD_EEPROM_LoadCalibration(void);
uint32_t BOARD_fetchChannelFrequency(const int channel); uint32_t BOARD_fetchChannelFrequency(const int channel);
void BOARD_fetchChannelName(char *s, const int channel); void BOARD_fetchChannelName(char *s, const int channel);
void BOARD_FactoryReset(bool bIsAll); void BOARD_FactoryReset(bool bIsAll);

2
main.c
View File

@ -84,7 +84,7 @@ void Main(void)
BOARD_EEPROM_Init(); BOARD_EEPROM_Init();
BOARD_EEPROM_LoadMoreSettings(); BOARD_EEPROM_LoadCalibration();
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD); RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);

7
misc.c
View File

@ -110,12 +110,7 @@ bool bHasCustomAesKey;
uint32_t gChallenge[4]; uint32_t gChallenge[4];
uint8_t gTryCount; uint8_t gTryCount;
uint8_t gEEPROM_1EC0_0[8]; uint16_t gEEPROM_RSSI_CALIB[7][4];
uint8_t gEEPROM_1EC0_1[8];
uint8_t gEEPROM_1EC0_2[8];
uint8_t gEEPROM_1EC0_3[8];
uint16_t gEEPROM_RSSI_CALIB[2][4];
uint16_t gEEPROM_1F8A; uint16_t gEEPROM_1F8A;
uint16_t gEEPROM_1F8C; uint16_t gEEPROM_1F8C;

7
misc.h
View File

@ -184,12 +184,7 @@ extern bool bHasCustomAesKey;
extern uint32_t gChallenge[4]; extern uint32_t gChallenge[4];
extern uint8_t gTryCount; extern uint8_t gTryCount;
extern uint8_t gEEPROM_1EC0_0[8]; extern uint16_t gEEPROM_RSSI_CALIB[7][4];
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[2][4];
extern uint16_t gEEPROM_1F8A; extern uint16_t gEEPROM_1F8A;
extern uint16_t gEEPROM_1F8C; extern uint16_t gEEPROM_1F8C;

View File

@ -58,8 +58,8 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
case 4: memmove(p + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3)); case 4: memmove(p + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
case 3: memmove(p + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2)); case 3: memmove(p + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
case 2: memmove(p + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); case 2: memmove(p + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
case 1: memmove(p + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); case 1: memmove(p + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); break;
case 0: break; case 0: memset( p + 0, 0, sizeof(BITMAP_Antenna)); break;
} }
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
@ -218,24 +218,13 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
const uint8_t Line = (vfo == 0) ? 3 : 7; const uint8_t Line = (vfo == 0) ? 3 : 7;
uint8_t *p_line = gFrameBuffer[Line - 1]; uint8_t *p_line = gFrameBuffer[Line - 1];
// TODO: sort out all 8 values from the eeprom
#if 0 const unsigned int band = gRxVfo->Band;
// dBm -105 -100 -95 -90 -70 -65 -60 -55 const int16_t level0 = gEEPROM_RSSI_CALIB[band][0];
// RSSI 110 120 130 140 180 190 200 210 const int16_t level1 = gEEPROM_RSSI_CALIB[band][1];
// 0000C0 6E 00 78 00 82 00 8C 00 B4 00 BE 00 C8 00 D2 00 const int16_t level2 = gEEPROM_RSSI_CALIB[band][2];
// const int16_t level3 = gEEPROM_RSSI_CALIB[band][3];
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];
const int16_t level3 = gEEPROM_RSSI_CALIB[band][3];
#else
const int16_t level0 = (-115 + 160) * 2; // dB
const int16_t level1 = ( -89 + 160) * 2; // dB
const int16_t level2 = ( -64 + 160) * 2; // dB
const int16_t level3 = ( -39 + 160) * 2; // dB
#endif
const int16_t level01 = (level0 + level1) / 2; const int16_t level01 = (level0 + level1) / 2;
const int16_t level12 = (level1 + level2) / 2; const int16_t level12 = (level1 + level2) / 2;
const int16_t level23 = (level2 + level3) / 2; const int16_t level23 = (level2 + level3) / 2;