mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
fixed VFO freq/band bug
This commit is contained in:
parent
29a77d111b
commit
359fa3bf47
2
Makefile
2
Makefile
@ -29,7 +29,7 @@ ENABLE_NOAA := 0
|
||||
ENABLE_VOICE := 0
|
||||
ENABLE_MUTE_RADIO_FOR_VOICE := 0
|
||||
# Tx on Voice 1.0 kB
|
||||
ENABLE_VOX := 0
|
||||
ENABLE_VOX := 1
|
||||
ENABLE_VOX_MORE_SENSITIVE := 1
|
||||
ENABLE_REDUCE_LOW_MID_TX_POWER := 1
|
||||
# Tx Alarm 600 B
|
||||
|
26
app/main.c
26
app/main.c
@ -194,7 +194,6 @@ void toggle_chan_scanlist(void)
|
||||
|
||||
void processFKeyFunction(const key_code_t Key)
|
||||
{
|
||||
uint8_t Band;
|
||||
uint8_t vfo = g_eeprom.config.setting.tx_vfo_num;
|
||||
|
||||
if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen == DISPLAY_MENU)
|
||||
@ -245,23 +244,28 @@ void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
APP_stop_scan();
|
||||
|
||||
Band = g_tx_vfo->channel_attributes.band + 1;
|
||||
if (g_eeprom.config.setting.enable_350 || Band != BAND5_350MHz)
|
||||
{
|
||||
if (Band > BAND7_470MHz)
|
||||
Band = BAND1_50MHz; // wrap-a-round
|
||||
}
|
||||
else
|
||||
Band = BAND6_400MHz; // jump to next band
|
||||
g_tx_vfo->channel_attributes.band = Band;
|
||||
unsigned int band = g_tx_vfo->channel_attributes.band;
|
||||
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = FREQ_CHANNEL_FIRST + Band;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].frequency = FREQ_CHANNEL_FIRST + Band;
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("band %u\r\n", band);
|
||||
#endif
|
||||
|
||||
if (++band > BAND7_470MHz)
|
||||
band = BAND1_50MHz;
|
||||
if (!g_eeprom.config.setting.enable_350 && band == BAND5_350MHz)
|
||||
band = BAND6_400MHz; // jump to next band
|
||||
g_tx_vfo->channel_attributes.band = band;
|
||||
|
||||
g_eeprom.config.setting.indices.vfo[vfo].screen = FREQ_CHANNEL_FIRST + band;
|
||||
g_eeprom.config.setting.indices.vfo[vfo].frequency = FREQ_CHANNEL_FIRST + band;
|
||||
}
|
||||
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
|
||||
break;
|
||||
|
||||
case KEY_2: // A/B
|
||||
|
16
driver/i2c.c
16
driver/i2c.c
@ -56,31 +56,31 @@ uint8_t I2C_Read_fast(bool bFinal)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(1);
|
||||
SYSTICK_Delay250ns(2);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(1);
|
||||
SYSTICK_Delay250ns(2);
|
||||
Data <<= 1;
|
||||
SYSTICK_Delay250ns(1);
|
||||
SYSTICK_Delay250ns(2);
|
||||
if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA))
|
||||
Data |= 1U;
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(1);
|
||||
SYSTICK_Delay250ns(2);
|
||||
}
|
||||
|
||||
PORTCON_PORTA_IE &= ~PORTCON_PORTA_IE_A11_MASK;
|
||||
PORTCON_PORTA_OD |= PORTCON_PORTA_OD_A11_BITS_ENABLE;
|
||||
GPIOA->DIR |= GPIO_DIR_11_BITS_OUTPUT;
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(1);
|
||||
SYSTICK_Delay250ns(2);
|
||||
if (bFinal)
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
else
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA);
|
||||
SYSTICK_Delay250ns(1);
|
||||
SYSTICK_Delay250ns(2);
|
||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(1);
|
||||
SYSTICK_Delay250ns(2);
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL);
|
||||
SYSTICK_Delay250ns(1);
|
||||
SYSTICK_Delay250ns(2);
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
2
misc.c
2
misc.c
@ -90,8 +90,6 @@ bool g_monitor_enabled;
|
||||
bool g_has_aes_key;
|
||||
uint32_t g_challenge[4];
|
||||
|
||||
uint16_t g_eeprom_rssi_calib[7][4];
|
||||
|
||||
volatile uint16_t g_schedule_power_save_tick_10ms = battery_save_count_10ms;
|
||||
volatile bool g_schedule_power_save;
|
||||
|
||||
|
2
misc.h
2
misc.h
@ -183,8 +183,6 @@ extern const uint32_t g_default_aes_key[4];
|
||||
extern bool g_has_aes_key;
|
||||
extern uint32_t g_challenge[4];
|
||||
|
||||
extern uint16_t g_eeprom_rssi_calib[7][4];
|
||||
|
||||
extern volatile uint16_t g_schedule_power_save_tick_10ms;
|
||||
extern volatile bool g_schedule_power_save;
|
||||
|
||||
|
2
radio.c
2
radio.c
@ -350,9 +350,9 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
|
||||
RADIO_ConfigureSquelchAndOutputPower(p_vfo);
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
AM_fix_reset(VFO);
|
||||
if (p_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix)
|
||||
{
|
||||
AM_fix_reset(VFO);
|
||||
AM_fix_10ms(VFO);
|
||||
}
|
||||
else
|
||||
|
36
settings.c
36
settings.c
@ -329,7 +329,6 @@ void SETTINGS_read_eeprom(void)
|
||||
// EEPROM cleaning
|
||||
|
||||
#if 1
|
||||
|
||||
memset(&g_eeprom.config.unused13, 0xff, sizeof(g_eeprom.config.unused13));
|
||||
|
||||
memset(&g_eeprom.unused, 0xff, sizeof(g_eeprom.unused));
|
||||
@ -347,38 +346,25 @@ void SETTINGS_read_eeprom(void)
|
||||
{ // used channel
|
||||
g_eeprom.config.channel_attributes[index].unused = 0x00;
|
||||
memset(g_eeprom.config.channel_name[index].unused, 0x00, sizeof(g_eeprom.config.channel_name[index].unused));
|
||||
|
||||
// ensure the channel band attribute is correct
|
||||
if (g_eeprom.config.channel[index].frequency > 0 && g_eeprom.config.channel[index].frequency < 0xffffffff)
|
||||
g_eeprom.config.channel_attributes[index].band = FREQUENCY_GetBand(g_eeprom.config.channel[index].frequency);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
// ensure the channel band attribute is correct
|
||||
for (index = 0; index < 200; index++)
|
||||
if (g_eeprom.config.channel_attributes[index].band <= BAND7_470MHz &&
|
||||
g_eeprom.config.channel[index].frequency > 0 &&
|
||||
g_eeprom.config.channel[index].frequency < 0xffffffff)
|
||||
g_eeprom.config.channel_attributes[index].band = FREQUENCY_GetBand(g_eeprom.config.channel[index].frequency);
|
||||
|
||||
// 0D60 .. force default VFO attributes
|
||||
for (index = 0; index < 7; index++)
|
||||
g_eeprom.config.channel_attributes[200 + index].attributes = 0xC0 | index;
|
||||
g_eeprom.config.channel_attributes[200 + 7].attributes = 0x00;
|
||||
#endif
|
||||
// force default VFO attributes
|
||||
for (index = 200; index < 207; index++)
|
||||
g_eeprom.config.channel_attributes[index].attributes = 0xC0 | (index - 200);
|
||||
g_eeprom.config.channel_attributes[207].attributes = 0x00;
|
||||
|
||||
SETTINGS_save_attributes();
|
||||
#endif
|
||||
|
||||
// ****************************************
|
||||
// eeprom calibration data
|
||||
|
||||
memset(&g_eeprom.calib.unused3, 0xff, sizeof(g_eeprom.calib.unused3));
|
||||
|
||||
memcpy(&g_eeprom_rssi_calib[0], &g_eeprom.calib.rssi_band_123, 8);
|
||||
memcpy(&g_eeprom_rssi_calib[1], &g_eeprom_rssi_calib[0], 8);
|
||||
memcpy(&g_eeprom_rssi_calib[2], &g_eeprom_rssi_calib[0], 8);
|
||||
memcpy(&g_eeprom_rssi_calib[3], &g_eeprom.calib.rssi_band_4567, 8);
|
||||
memcpy(&g_eeprom_rssi_calib[4], &g_eeprom_rssi_calib[3], 8);
|
||||
memcpy(&g_eeprom_rssi_calib[5], &g_eeprom_rssi_calib[3], 8);
|
||||
memcpy(&g_eeprom_rssi_calib[6], &g_eeprom_rssi_calib[3], 8);
|
||||
// memset(&g_eeprom.calib.unused3, 0xff, sizeof(g_eeprom.calib.unused3));
|
||||
|
||||
if (g_eeprom.calib.battery[0] >= 5000)
|
||||
{
|
||||
|
@ -455,9 +455,11 @@ typedef struct {
|
||||
uint8_t unused6[6]; // 0xff's
|
||||
} __attribute__((packed)) squelch_band[2]; // 0 = bands 4567, 1 = bands 123
|
||||
|
||||
// 0x1EC0
|
||||
uint16_t rssi_band_4567[4]; // RSSI bargraph thresholds .. (dBm + 160) * 2
|
||||
uint16_t rssi_band_123[4]; // RSSI bargraph thresholds .. (dBm + 160) * 2
|
||||
// 0x1EC0 .. mine = 006E 0078 0082 008C 0086 00AA 00CE 00F2
|
||||
struct { // RSSI bargraph thresholds .. (dBm + 160) * 2
|
||||
uint16_t band_4567[4]; //
|
||||
uint16_t band_123[4]; //
|
||||
} __attribute__((packed)) rssi_cal;
|
||||
|
||||
// 0x1ED0
|
||||
struct
|
||||
|
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user