mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-18 22:29:50 +03:00
fixed VFO freq/band bug
This commit is contained in:
105
ui/main.c
105
ui/main.c
@ -285,56 +285,62 @@ void UI_update_rssi(const int16_t rssi, const uint16_t glitch, const uint16_t no
|
||||
{ // original little RS bars
|
||||
|
||||
// const int16_t dBm = (rssi / 2) - 160;
|
||||
const uint8_t Line = (vfo == 0) ? 3 : 7;
|
||||
uint8_t *p_line = g_frame_buffer[Line - 1];
|
||||
uint8_t rssi_level = 0;
|
||||
|
||||
// TODO: sort out all 8 values from the eeprom
|
||||
const uint8_t line = (vfo == 0) ? 3 : 7;
|
||||
uint8_t *pline = g_frame_buffer[line - 1];
|
||||
unsigned int rssi_level = 0;
|
||||
int16_t rssi_cal[7];
|
||||
|
||||
#if 1
|
||||
const unsigned int band = g_rx_vfo->channel_attributes.band;
|
||||
const int16_t level0 = g_eeprom_rssi_calib[band][0];
|
||||
const int16_t level1 = g_eeprom_rssi_calib[band][1];
|
||||
const int16_t level2 = g_eeprom_rssi_calib[band][2];
|
||||
const int16_t level3 = g_eeprom_rssi_calib[band][3];
|
||||
if (g_tx_vfo->channel_attributes.band < 3)
|
||||
{
|
||||
rssi_cal[0] = g_eeprom.calib.rssi_cal.band_123[0];
|
||||
rssi_cal[2] = g_eeprom.calib.rssi_cal.band_123[1];
|
||||
rssi_cal[4] = g_eeprom.calib.rssi_cal.band_123[2];
|
||||
rssi_cal[6] = g_eeprom.calib.rssi_cal.band_123[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
rssi_cal[0] = g_eeprom.calib.rssi_cal.band_4567[0];
|
||||
rssi_cal[2] = g_eeprom.calib.rssi_cal.band_4567[1];
|
||||
rssi_cal[4] = g_eeprom.calib.rssi_cal.band_4567[2];
|
||||
rssi_cal[6] = g_eeprom.calib.rssi_cal.band_4567[3];
|
||||
}
|
||||
#else
|
||||
const int16_t level0 = (-115 + 160) * 2; // -115dBm
|
||||
const int16_t level1 = ( -89 + 160) * 2; // -89dBm
|
||||
const int16_t level2 = ( -64 + 160) * 2; // -64dBm
|
||||
const int16_t level3 = ( -39 + 160) * 2; // -39dBm
|
||||
rssi_cal[0] = (-110 + 160) * 2; // -110 dBm
|
||||
rssi_cal[2] = ( -90 + 160) * 2; // -90 dBm
|
||||
rssi_cal[4] = ( -70 + 160) * 2; // -70 dBm
|
||||
rssi_cal[6] = ( -50 + 160) * 2; // -50 dBm
|
||||
#endif
|
||||
// create intermediate threshold values (linear interpolation) to make full use of the available RSSI bars/graphics
|
||||
const int16_t level01 = (level0 + level1) / 2;
|
||||
const int16_t level12 = (level1 + level2) / 2;
|
||||
const int16_t level23 = (level2 + level3) / 2;
|
||||
// linear interpolate the 4 values into 7
|
||||
rssi_cal[1] = (rssi_cal[0] + rssi_cal[2]) / 2;
|
||||
rssi_cal[3] = (rssi_cal[2] + rssi_cal[4]) / 2;
|
||||
rssi_cal[5] = (rssi_cal[4] + rssi_cal[6]) / 2;
|
||||
|
||||
g_vfo_rssi[vfo] = rssi;
|
||||
|
||||
if (rssi >= level3)
|
||||
if (rssi >= rssi_cal[6])
|
||||
rssi_level = 7;
|
||||
else
|
||||
if (rssi >= level23)
|
||||
if (rssi >= rssi_cal[5])
|
||||
rssi_level = 6;
|
||||
else
|
||||
if (rssi >= level2)
|
||||
if (rssi >= rssi_cal[4])
|
||||
rssi_level = 5;
|
||||
else
|
||||
if (rssi >= level12)
|
||||
if (rssi >= rssi_cal[3])
|
||||
rssi_level = 4;
|
||||
else
|
||||
if (rssi >= level1)
|
||||
if (rssi >= rssi_cal[2])
|
||||
rssi_level = 3;
|
||||
else
|
||||
if (rssi >= level01)
|
||||
if (rssi >= rssi_cal[1])
|
||||
rssi_level = 2;
|
||||
else
|
||||
if (rssi >= level0 || g_current_function == FUNCTION_NEW_RECEIVE)
|
||||
{
|
||||
if (rssi >= rssi_cal[0] || g_current_function == FUNCTION_NEW_RECEIVE)
|
||||
rssi_level = 1;
|
||||
}
|
||||
|
||||
if (g_vfo_rssi_bar_level[vfo] == rssi_level)
|
||||
return;
|
||||
// if (g_vfo_rssi_bar_level[vfo] == rssi_level)
|
||||
// return;
|
||||
|
||||
g_vfo_rssi_bar_level[vfo] = rssi_level;
|
||||
|
||||
@ -348,18 +354,18 @@ void UI_update_rssi(const int16_t rssi, const uint16_t glitch, const uint16_t no
|
||||
if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
|
||||
return; // display is in use
|
||||
|
||||
p_line = g_frame_buffer[Line - 1];
|
||||
pline = g_frame_buffer[line - 1];
|
||||
|
||||
memset(p_line, 0, 23);
|
||||
memset(pline, 0, 23);
|
||||
|
||||
// untested !!!
|
||||
|
||||
if (rssi_level == 0)
|
||||
p_line = NULL;
|
||||
pline = NULL;
|
||||
else
|
||||
UI_drawBars(p_line, rssi_level);
|
||||
UI_drawBars(pline, rssi_level);
|
||||
|
||||
ST7565_DrawLine(0, Line, 23, p_line);
|
||||
ST7565_DrawLine(0, line, 23, pline);
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,31 +774,20 @@ void UI_DisplayMain(void)
|
||||
const uint8_t freq_in_channel = g_vfo_info[vfo_num].freq_in_channel;
|
||||
// const uint8_t freq_in_channel = SETTINGS_find_channel(frequency); // currently way to slow
|
||||
|
||||
// if (g_vfo_info[vfo_num].channel.compand)
|
||||
{
|
||||
strcpy(str, " ");
|
||||
strcpy(str, " ");
|
||||
|
||||
#ifdef ENABLE_SCAN_IGNORE_LIST
|
||||
if (FI_freq_ignored(frequency) >= 0)
|
||||
str[0] = 'I'; // frequency is in the ignore list
|
||||
#endif
|
||||
#ifdef ENABLE_SCAN_IGNORE_LIST
|
||||
if (FI_freq_ignored(frequency) >= 0)
|
||||
str[0] = 'I'; // frequency is in the ignore list
|
||||
#endif
|
||||
|
||||
if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST)
|
||||
str[1] = 'F'; // channel number that contains this VFO frequency
|
||||
if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST)
|
||||
str[1] = 'F'; // this VFO frequency is also found in a channel
|
||||
|
||||
if (g_vfo_info[vfo_num].channel.compand)
|
||||
str[2] = 'C'; // compander is enabled
|
||||
if (g_vfo_info[vfo_num].channel.compand)
|
||||
str[2] = 'C'; // compander is enabled
|
||||
|
||||
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 3), 0, line + 1);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST)
|
||||
// { // channel number that contains this VFO frequency
|
||||
// sprintf(str, "%03u", freq_in_channel);
|
||||
// UI_PrintStringSmall(str, LCD_WIDTH - (7 * 3), 0, line + 1);
|
||||
// }
|
||||
// }
|
||||
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 3), 0, line + 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user