0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-27 22:01:26 +03:00

fix little display digit overlap bug

This commit is contained in:
OneOfEleven 2023-11-01 08:51:56 +00:00
parent 010ee10516
commit b0f105572a
17 changed files with 179 additions and 179 deletions

View File

@ -12,7 +12,7 @@ ENABLE_OVERLAY := 0
ENABLE_LTO := 1
# UART Programming 2.9 kB
ENABLE_UART := 1
ENABLE_UART_DEBUG := 0
ENABLE_UART_DEBUG := 1
# AirCopy 2.5 kB
ENABLE_AIRCOPY := 0
ENABLE_AIRCOPY_REMEMBER_FREQ := 1
@ -35,7 +35,7 @@ ENABLE_REDUCE_LOW_MID_TX_POWER := 1
ENABLE_ALARM := 0
ENABLE_TX1750 := 0
# MDC1200 2.8 kB
ENABLE_MDC1200 := 1
ENABLE_MDC1200 := 0
ENABLE_MDC1200_SHOW_OP_ARG := 1
ENABLE_PWRON_PASSWORD := 0
ENABLE_RESET_AES_KEY := 1

View File

@ -1175,64 +1175,48 @@ void APP_check_keys(void)
if (ptt_pressed)
{ // PTT pressed
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_setting_tx_enable)
#ifdef ENABLE_AIRCOPY
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_setting_tx_enable && g_current_function != FUNCTION_TRANSMIT && g_current_display_screen != DISPLAY_AIRCOPY)
#else
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_setting_tx_enable && g_current_function != FUNCTION_TRANSMIT)
#endif
{
#ifdef ENABLE_KILL_REVIVE
if (!g_setting_radio_disabled)
#endif
{
#ifdef ENABLE_AIRCOPY
if (!g_ptt_is_pressed && g_current_display_screen != DISPLAY_AIRCOPY)
#else
if (!g_ptt_is_pressed)
#endif
{
if (++g_ptt_debounce >= 3) // 30ms debounce
{ // start TX'ing
if (++g_ptt_debounce >= 3) // 30ms debounce
{ // start TX'ing
g_boot_tick_10ms = 0; // cancel the boot-up screen
g_ptt_is_pressed = ptt_pressed;
g_ptt_was_released = false;
g_ptt_debounce = 0;
g_boot_tick_10ms = 0; // cancel the boot-up screen
g_ptt_is_pressed = ptt_pressed;
g_ptt_was_released = false;
g_ptt_debounce = 3;
APP_process_key(KEY_PTT, true, false);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
#endif
}
APP_process_key(KEY_PTT, true, false);
}
else
g_ptt_debounce = 0;
}
}
}
else
{ // PTT released
if (g_ptt_is_pressed && g_current_function == FUNCTION_TRANSMIT)
#ifdef ENABLE_KILL_REVIVE
if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0 || !g_setting_tx_enable || g_current_function == FUNCTION_TRANSMIT || g_setting_radio_disabled)
#else
if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0 || !g_setting_tx_enable || g_current_function == FUNCTION_TRANSMIT)
#endif
{
if (++g_ptt_debounce >= 3 || g_serial_config_tick_500ms > 0 || !g_setting_tx_enable) // 30ms debounce
if (--g_ptt_debounce <= 0)
{ // stop TX'ing
// g_ptt_is_pressed = false;
g_ptt_is_pressed = false;
g_ptt_was_released = true;
g_ptt_debounce = 0;
APP_process_key(KEY_PTT, false, false);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
#endif
}
}
else
{
g_ptt_debounce = 0;
if (g_ptt_is_pressed && !ptt_pressed)
g_ptt_is_pressed = false;
}
}
// *****************
@ -1262,10 +1246,6 @@ void APP_check_keys(void)
if (g_key_prev != KEY_INVALID)
{ // key now fully released
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf(" old key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
#endif
#ifdef ENABLE_AIRCOPY
if (g_current_display_screen != DISPLAY_AIRCOPY)
APP_process_key(g_key_prev, false, g_key_held);
@ -1279,10 +1259,10 @@ void APP_check_keys(void)
g_key_debounce_repeat = 0;
g_key_prev = KEY_INVALID;
g_key_held = false;
g_boot_tick_10ms = 0; // cancel the boot-up screen
g_boot_tick_10ms = 0; // cancel the boot-up screen
g_update_status = true;
g_update_display = true;
// g_update_display = true;
}
}
if (g_key_debounce_repeat > 0)
@ -1299,12 +1279,7 @@ void APP_check_keys(void)
{ // key now fully pressed
g_key_debounce_repeat = key_debounce_10ms;
g_key_held = false;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("\r\n new key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
#endif
g_key_prev = key;
g_key_prev = key;
#ifdef ENABLE_AIRCOPY
if (g_current_display_screen != DISPLAY_AIRCOPY)
@ -1316,7 +1291,7 @@ void APP_check_keys(void)
#endif
g_update_status = true;
g_update_display = true;
// g_update_display = true;
}
}
}
@ -1327,10 +1302,6 @@ void APP_check_keys(void)
{ // key long press
g_key_held = true;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("long key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
#endif
#ifdef ENABLE_AIRCOPY
if (g_current_display_screen != DISPLAY_AIRCOPY)
APP_process_key(g_key_prev, true, g_key_held);
@ -1339,13 +1310,15 @@ void APP_check_keys(void)
#else
APP_process_key(g_key_prev, true, g_key_held);
#endif
g_update_status = true;
}
}
else
if (key == KEY_UP || key == KEY_DOWN)
{ // only the up and down keys are repeatable
{ // only the up and down keys are made repeatable
// go much faster if the user is moving up/down freq/channel
// key repeat max 10ms speed if user is moving up/down in freq/channel
const uint8_t repeat_10ms = (g_manual_scanning && g_monitor_enabled && g_current_display_screen == DISPLAY_MAIN) ? 1 : key_repeat_10ms;
if (++g_key_debounce_repeat >= (key_long_press_10ms + repeat_10ms))
@ -1353,10 +1326,6 @@ void APP_check_keys(void)
g_key_debounce_repeat = key_long_press_10ms;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("rept key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
#endif
#ifdef ENABLE_AIRCOPY
if (g_current_display_screen != DISPLAY_AIRCOPY)
APP_process_key(g_key_prev, true, g_key_held);

View File

@ -404,7 +404,7 @@ void processFKeyFunction(const key_code_t Key)
case KEY_9: // CALL
if (!RADIO_CheckValidChannel(g_eeprom.chan_1_call, false, 0))
if (!RADIO_CheckValidChannel(g_eeprom2.config.call1, false, 0))
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
@ -414,12 +414,12 @@ void processFKeyFunction(const key_code_t Key)
APP_stop_scan();
g_eeprom.user_channel[Vfo] = g_eeprom.chan_1_call;
g_eeprom.screen_channel[Vfo] = g_eeprom.chan_1_call;
g_eeprom.user_channel[Vfo] = g_eeprom2.config.call1;
g_eeprom.screen_channel[Vfo] = g_eeprom2.config.call1;
#ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, g_eeprom.chan_1_call + 1);
AUDIO_SetDigitVoice(1, 1 + g_eeprom2.config.call1);
g_another_voice_id = (voice_id_t)0xFE;
#endif

View File

@ -685,7 +685,7 @@ void MENU_AcceptSetting(void)
return;
case MENU_1_CALL:
g_eeprom.chan_1_call = g_sub_menu_selection;
g_eeprom2.config.call1 = g_sub_menu_selection;
break;
case MENU_S_LIST:
@ -1160,7 +1160,7 @@ void MENU_ShowCurrentSetting(void)
return;
case MENU_1_CALL:
g_sub_menu_selection = g_eeprom.chan_1_call;
g_sub_menu_selection = g_eeprom2.config.call1;
break;
case MENU_S_LIST:

View File

@ -59,7 +59,7 @@ const uint8_t BITMAP_RX[8] =
{
__extension__ 0b00000000,
__extension__ 0b00111110,
__extension__ 0b00100010,
__extension__ 0b01100011,
__extension__ 0b01000001,
__extension__ 0b01000001,
__extension__ 0b01000001,
@ -94,7 +94,7 @@ const uint8_t BITMAP_RX[8] =
__extension__ 0b01000001,
__extension__ 0b01000001,
__extension__ 0b01000001,
__extension__ 0b00100010,
__extension__ 0b01100011,
__extension__ 0b00111110
};
#endif

View File

@ -522,9 +522,12 @@ void BOARD_eeprom_load(void)
// memset(Data, 0, sizeof(Data));
// sanity checks
g_eeprom2.config.call1 = IS_USER_CHANNEL(g_eeprom2.config.call1) ? g_eeprom2.config.call1 : USER_CHANNEL_FIRST;
// 0E70..0E77
EEPROM_ReadBuffer(0x0E70, Data, 8);
g_eeprom.chan_1_call = IS_USER_CHANNEL(Data[0]) ? Data[0] : USER_CHANNEL_FIRST;
// g_eeprom.chan_1_call = IS_USER_CHANNEL(Data[0]) ? Data[0] : USER_CHANNEL_FIRST;
g_eeprom.squelch_level = (Data[1] < 10) ? Data[1] : 1;
g_eeprom.tx_timeout_timer = (Data[2] < 11) ? Data[2] : 1;
#ifdef ENABLE_NOAA

View File

@ -22,7 +22,7 @@
void EEPROM_ReadBuffer(const uint16_t address, void *p_buffer, const unsigned int size)
{
if (p_buffer == NULL || (address + size) > 0x2000 || size == 0)
if ((address + size) > 0x2000 || size == 0)
return;
I2C_Start();

View File

@ -132,37 +132,37 @@ int I2C_Write(uint8_t Data)
return ret;
}
int I2C_ReadBuffer(void *pBuffer, uint8_t Size)
int I2C_ReadBuffer(void *pBuffer, const unsigned int Size)
{
uint8_t *pData = (uint8_t *)pBuffer;
uint8_t i;
unsigned int i;
if (Size == 1) {
if (Size == 1)
{
*pData = I2C_Read(true);
return 1;
}
for (i = 0; i < Size - 1; i++) {
SYSTICK_DelayUs(1);
for (i = 0; i < (Size - 1); i++)
{
// SYSTICK_DelayUs(1);
pData[i] = I2C_Read(false);
}
SYSTICK_DelayUs(1);
// SYSTICK_DelayUs(1);
pData[i++] = I2C_Read(true);
return Size;
}
int I2C_WriteBuffer(const void *pBuffer, uint8_t Size)
int I2C_WriteBuffer(const void *pBuffer, const unsigned int Size)
{
const uint8_t *pData = (const uint8_t *)pBuffer;
uint8_t i;
unsigned int i;
for (i = 0; i < Size; i++) {
if (I2C_Write(*pData++) < 0) {
for (i = 0; i < Size; i++)
if (I2C_Write(*pData++) < 0)
return -1;
}
}
return 0;
}

View File

@ -31,8 +31,8 @@ void I2C_Stop(void);
uint8_t I2C_Read(bool bFinal);
int I2C_Write(uint8_t Data);
int I2C_ReadBuffer(void *pBuffer, uint8_t Size);
int I2C_WriteBuffer(const void *pBuffer, uint8_t Size);
int I2C_ReadBuffer(void *pBuffer, unsigned int Size);
int I2C_WriteBuffer(const void *pBuffer, unsigned int Size);
#endif

View File

@ -22,7 +22,7 @@
#include "driver/i2c.h"
#include "misc.h"
uint8_t g_ptt_debounce;
int8_t g_ptt_debounce;
uint8_t g_key_debounce_press;
uint8_t g_key_debounce_repeat;
key_code_t g_key_prev = KEY_INVALID;

View File

@ -45,7 +45,7 @@ enum key_code_e {
};
typedef enum key_code_e key_code_t;
extern uint8_t g_ptt_debounce;
extern int8_t g_ptt_debounce;
extern uint8_t g_key_debounce_press;
extern uint8_t g_key_debounce_repeat;
extern key_code_t g_key_prev;

Binary file not shown.

Binary file not shown.

7
main.c
View File

@ -73,14 +73,15 @@ void Main(void)
UART_Init();
#endif
BOARD_Init();
#if defined(ENABLE_UART)
UART_SendText(UART_Version_str);
UART_SendText("\r\n");
#endif
// Not implementing authentic device checks
// load the entire EEPROM contents into memory
SETTINGS_read_eeprom();
BOARD_Init();
memset(&g_eeprom, 0, sizeof(g_eeprom));

View File

@ -24,8 +24,31 @@
#include "misc.h"
#include "settings.h"
t_eeprom g_eeprom2;
eeprom_config_t g_eeprom;
void SETTINGS_read_eeprom(void)
{
EEPROM_ReadBuffer(0, &g_eeprom2, sizeof(g_eeprom2));
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("config size %04X %u\r\n"
"calib size %04X %u\r\n"
"eeprom size %04X %u\r\n",
sizeof(g_eeprom2.config), sizeof(g_eeprom2.config),
sizeof(g_eeprom2.calib), sizeof(g_eeprom2.calib),
sizeof(g_eeprom2), sizeof(g_eeprom2));
#endif
}
void SETTINGS_write_eeprom_config(void)
{
uint32_t index;
for (index = 0; index < sizeof(g_eeprom2); index += 8)
EEPROM_WriteBuffer8(index, (uint8_t *)(&g_eeprom2) + index);
}
#ifdef ENABLE_FMRADIO
void SETTINGS_save_fm(void)
{
@ -77,7 +100,7 @@ void SETTINGS_save(void)
{
uint8_t State[8];
State[0] = g_eeprom.chan_1_call;
State[0] = g_eeprom2.config.call1;
State[1] = g_eeprom.squelch_level;
State[2] = g_eeprom.tx_timeout_timer;
#ifdef ENABLE_NOAA

View File

@ -200,78 +200,6 @@ typedef struct {
uint8_t scanlist1:1; // set if in scan list 1
} __attribute__((packed)) t_channel_attr; //
// 512 bytes
typedef struct {
// 0x1E00
struct {
uint8_t open_rssi_thresh[10]; //
uint8_t unused1[6]; // 0xff's
uint8_t close_rssi_thresh[10]; //
uint8_t unused2[6]; // 0xff's
uint8_t open_noise_thresh[10]; //
uint8_t unused3[6]; // 0xff's
uint8_t close_noise_thresh[10]; //
uint8_t unused4[6]; // 0xff's
uint8_t open_glitch_thresh[10]; //
uint8_t unused5[6]; // 0xff's
uint8_t close_glitch_thresh[10]; //
uint8_t unused6[6]; // 0xff's
} __attribute__((packed)) squelch_band_4567[6]; //
// 0x1E60
struct {
uint8_t open_rssi_thresh[10]; //
uint8_t unused1[6]; // 0xff's
uint8_t close_rssi_thresh[10]; //
uint8_t unused2[6]; // 0xff's
uint8_t open_noise_thresh[10]; //
uint8_t unused3[6]; // 0xff's
uint8_t close_noise_thresh[10]; //
uint8_t unused4[6]; // 0xff's
uint8_t open_glitch_thresh[10]; //
uint8_t unused5[6]; // 0xff's
uint8_t close_glitch_thresh[10]; //
uint8_t unused6[6]; // 0xff's
} __attribute__((packed)) squelch_band_123[6]; //
// 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
// 0x1ED0
struct
{
uint8_t low[3]; //
uint8_t mid[3]; //
uint8_t high[3]; //
uint8_t unused[7]; // 0xff's
} tx_band_power[7]; //
// 0x1F40
uint16_t battery[6]; //
uint8_t unused1[4]; // 0xff's
// 0x1F50
struct
{
uint16_t threshold[10]; //
uint8_t unused[4]; // 0xff's
} __attribute__((packed)) vox[2]; //
// 0x1F80
uint8_t mic_gain_dB2[5]; //
uint8_t unused4[3]; //
int16_t bk4819_xtal_freq_low; //
uint16_t unknown2; //
uint16_t unknown3; //
uint8_t volume_gain; //
uint8_t dac_gain; //
uint8_t unused5[8 * 10]; // 0xff's
} __attribute__((packed)) t_calibration;
// user configuration
typedef struct {
@ -455,19 +383,94 @@ typedef struct {
} __attribute__((packed)) t_config;
// 512 bytes
typedef struct {
// 0x1E00
struct {
uint8_t open_rssi_thresh[10]; //
uint8_t unused1[6]; // 0xff's
uint8_t close_rssi_thresh[10]; //
uint8_t unused2[6]; // 0xff's
uint8_t open_noise_thresh[10]; //
uint8_t unused3[6]; // 0xff's
uint8_t close_noise_thresh[10]; //
uint8_t unused4[6]; // 0xff's
uint8_t open_glitch_thresh[10]; //
uint8_t unused5[6]; // 0xff's
uint8_t close_glitch_thresh[10]; //
uint8_t unused6[6]; // 0xff's
} squelch_band_4567[6];
// 0x1E60
struct {
uint8_t open_rssi_thresh[10]; //
uint8_t unused1[6]; // 0xff's
uint8_t close_rssi_thresh[10]; //
uint8_t unused2[6]; // 0xff's
uint8_t open_noise_thresh[10]; //
uint8_t unused3[6]; // 0xff's
uint8_t close_noise_thresh[10]; //
uint8_t unused4[6]; // 0xff's
uint8_t open_glitch_thresh[10]; //
uint8_t unused5[6]; // 0xff's
uint8_t close_glitch_thresh[10]; //
uint8_t unused6[6]; // 0xff's
} squelch_band_123[6];
// 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
// 0x1ED0
struct
{
uint8_t low[3]; //
uint8_t mid[3]; //
uint8_t high[3]; //
uint8_t unused[7]; // 0xff's
} tx_band_power[7]; //
// 0x1F40
uint16_t battery[6]; //
uint8_t unused1[4]; // 0xff's
// 0x1F50
struct
{
uint16_t threshold[10]; //
uint8_t unused[4]; // 0xff's
} vox[2];
// 0x1F80
uint8_t mic_gain_dB2[5]; //
uint8_t unused4[3]; //
int16_t bk4819_xtal_freq_low; //
uint16_t unknown2; //
uint16_t unknown3; //
uint8_t volume_gain; //
uint8_t dac_gain; //
// 0x1F90
uint8_t unused5[16 * 7]; // 0xff's
// 0x2000
} __attribute__((packed)) t_calibration;
// entire eeprom
typedef struct {
// 0x0000
t_config config; // radios user config
t_config config; // radios user config
// 0x1D00
uint8_t unused14[256]; // does this belong to the config, or the calibration, or neither ?
uint8_t unused[256]; // does this belong to the config, or the calibration, or neither ?
// 0x1E00
t_calibration calibration; // calibration settings .. we DO NOT pass this through aircopy, it's radio specific
t_calibration calib; // calibration settings .. we DO NOT pass this through aircopy, it's radio specific
} __attribute__((packed)) t_eeprom; // 8192 bytes of eeprom
} __attribute__((packed)) t_eeprom; // 8192 (0x2000) bytes of eeprom
// ************************************************
// this and all the other variables are going to be replaced with the above t_eeprom
@ -534,7 +537,7 @@ typedef struct {
uint8_t key2_long_press_action;
uint8_t mic_sensitivity;
uint8_t mic_sensitivity_tuning;
uint8_t chan_1_call;
// uint8_t chan_1_call;
char ani_dtmf_id[8];
char kill_code[8];
char revive_code[8];
@ -583,8 +586,13 @@ typedef struct {
} eeprom_config_t;
extern t_eeprom g_eeprom2;
extern eeprom_config_t g_eeprom;
void SETTINGS_read_eeprom(void);
void SETTINGS_write_eeprom_config(void);
#ifdef ENABLE_FMRADIO
void SETTINGS_save_fm(void);
#endif

View File

@ -793,31 +793,27 @@ void UI_DisplayMain(void)
const uint8_t freq_in_channel = g_eeprom.vfo_info[vfo_num].freq_in_channel;
// const uint8_t freq_in_channel = BOARD_find_channel(frequency); // currently way to slow
// if (g_eeprom.vfo_info[vfo_num].compand)
if (g_eeprom.vfo_info[vfo_num].compand)
{
strcpy(str, " ");
strcpy(str, " ");
if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST)
{ // the channel number that contains this VFO frequency
// strcpy(str, "F");
sprintf(str, "%03u", freq_in_channel);
}
str[0] = 'F'; // channel number that contains this VFO frequency
if (g_eeprom.vfo_info[vfo_num].compand)
strcat(str, "C");
str[1] = 'C'; // compander is enabled
// UI_PrintStringSmall(str, LCD_WIDTH - (7 * 2), 0, line + 1);
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 4), 0, line + 1);
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 2), 0, line + 1);
}
/* else
else
{
if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST)
{ // the channel number that contains this VFO frequency
{ // channel number that contains this VFO frequency
sprintf(str, "%03u", freq_in_channel);
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 3), 0, line + 1);
}
}
*/ }
}
#endif
}