mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 22:58:04 +03:00
Fix RSSI bar bug
This commit is contained in:
25
ui/main.c
25
ui/main.c
@ -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];
|
||||
@ -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];
|
||||
@ -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);
|
||||
|
Reference in New Issue
Block a user