mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-18 22:29:50 +03:00
fixed key lock compile bug
This commit is contained in:
@ -44,19 +44,20 @@
|
|||||||
// payloads ................ 0xABCD + 2 byte eeprom address + 64 byte payload + 2 byte CRC + 0xDCBA
|
// payloads ................ 0xABCD + 2 byte eeprom address + 64 byte payload + 2 byte CRC + 0xDCBA
|
||||||
// 1of11 req/ack additon ... 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA
|
// 1of11 req/ack additon ... 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA
|
||||||
|
|
||||||
#define AIRCOPY_MAGIC_START_REQ 0xBCDA // used to request a block resend
|
#define AIRCOPY_MAGIC_START_REQ 0xBCDA // used to request a block resend
|
||||||
#define AIRCOPY_MAGIC_END_REQ 0xCDBA // used to request a block resend
|
#define AIRCOPY_MAGIC_END_REQ 0xCDBA // used to request a block resend
|
||||||
|
|
||||||
#define AIRCOPY_MAGIC_START 0xABCD // normal start value
|
#define AIRCOPY_MAGIC_START 0xABCD // normal start value
|
||||||
#define AIRCOPY_MAGIC_END 0xDCBA // normal end value
|
#define AIRCOPY_MAGIC_END 0xDCBA // normal end value
|
||||||
|
|
||||||
#define AIRCOPY_LAST_EEPROM_ADDR 0x1E00 // size of eeprom transferred
|
#define AIRCOPY_LAST_EEPROM_ADDR 0x1E00 // size of eeprom transferred
|
||||||
|
//#define AIRCOPY_LAST_EEPROM_ADDR (sizeof(t_config)) //
|
||||||
|
|
||||||
// FSK payload data length
|
// FSK payload data length
|
||||||
#define AIRCOPY_DATA_PACKET_SIZE (2 + 2 + 64 + 2 + 2)
|
#define AIRCOPY_DATA_PACKET_SIZE (2 + 2 + 64 + 2 + 2)
|
||||||
|
|
||||||
// FSK req/ack data length .. 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA
|
// FSK req/ack data length .. 0xBCDA + 2 byte eeprom address + 2 byte CRC + 0xCDBA
|
||||||
#define AIRCOPY_REQ_PACKET_SIZE (2 + 2 + 2 + 2)
|
#define AIRCOPY_REQ_PACKET_SIZE (2 + 2 + 2 + 2)
|
||||||
|
|
||||||
// **********************
|
// **********************
|
||||||
|
|
||||||
@ -590,8 +591,11 @@ void AIRCOPY_process_fsk_rx_10ms(void)
|
|||||||
data[2] = 0;
|
data[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM_WriteBuffer8(eeprom_addr, data); // 8 bytes at a time
|
if (eeprom_addr < sizeof(t_config)) // don't allow writing to the calibration data area
|
||||||
// memcpy(((uint8_t *)&g_eeprom) + eeprom_addr, data, 8);
|
{
|
||||||
|
EEPROM_WriteBuffer8(eeprom_addr, data); // 8 bytes at a time
|
||||||
|
// memcpy(((uint8_t *)&g_eeprom) + eeprom_addr, data, 8);
|
||||||
|
}
|
||||||
|
|
||||||
data += write_size / sizeof(data[0]);
|
data += write_size / sizeof(data[0]);
|
||||||
eeprom_addr += write_size;
|
eeprom_addr += write_size;
|
||||||
@ -605,6 +609,9 @@ void AIRCOPY_process_fsk_rx_10ms(void)
|
|||||||
g_aircopy_state = AIRCOPY_RX_COMPLETE;
|
g_aircopy_state = AIRCOPY_RX_COMPLETE;
|
||||||
AUDIO_PlayBeep(BEEP_880HZ_60MS_TRIPLE_BEEP);
|
AUDIO_PlayBeep(BEEP_880HZ_60MS_TRIPLE_BEEP);
|
||||||
|
|
||||||
|
// save the received data to the EEPROM chip
|
||||||
|
// SETTINGS_write_eeprom_config();
|
||||||
|
|
||||||
#ifdef ENABLE_AIRCOPY_RX_REBOOT
|
#ifdef ENABLE_AIRCOPY_RX_REBOOT
|
||||||
#if defined(ENABLE_OVERLAY)
|
#if defined(ENABLE_OVERLAY)
|
||||||
overlay_FLASH_RebootToBootloader();
|
overlay_FLASH_RebootToBootloader();
|
||||||
@ -613,9 +620,9 @@ void AIRCOPY_process_fsk_rx_10ms(void)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
send_req:
|
send_req:
|
||||||
g_fsk_write_index = 0;
|
g_fsk_write_index = 0;
|
||||||
|
|
||||||
|
173
app/app.c
173
app/app.c
@ -1849,7 +1849,7 @@ void APP_process_power_save(void)
|
|||||||
// go back to sleep
|
// go back to sleep
|
||||||
|
|
||||||
g_power_save_tick_10ms = g_eeprom.config.setting.battery_save_ratio * 10;
|
g_power_save_tick_10ms = g_eeprom.config.setting.battery_save_ratio * 10;
|
||||||
g_rx_idle_mode = true;
|
g_rx_idle_mode = true;
|
||||||
|
|
||||||
BK4819_DisableVox();
|
BK4819_DisableVox();
|
||||||
BK4819_Sleep();
|
BK4819_Sleep();
|
||||||
@ -1870,15 +1870,6 @@ void APP_time_slice_500ms(void)
|
|||||||
{
|
{
|
||||||
bool exit_menu = false;
|
bool exit_menu = false;
|
||||||
|
|
||||||
if (g_serial_config_tick_500ms > 0)
|
|
||||||
{ // config upload/download is running
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_keypad_locked > 0)
|
|
||||||
if (--g_keypad_locked == 0)
|
|
||||||
g_update_display = true;
|
|
||||||
|
|
||||||
if (g_key_input_count_down > 0)
|
if (g_key_input_count_down > 0)
|
||||||
{
|
{
|
||||||
if (--g_key_input_count_down == 0)
|
if (--g_key_input_count_down == 0)
|
||||||
@ -1887,12 +1878,32 @@ void APP_time_slice_500ms(void)
|
|||||||
|
|
||||||
if (g_beep_to_play != BEEP_NONE)
|
if (g_beep_to_play != BEEP_NONE)
|
||||||
{
|
{
|
||||||
AUDIO_PlayBeep(g_beep_to_play);
|
if (g_serial_config_tick_500ms == 0)
|
||||||
|
AUDIO_PlayBeep(g_beep_to_play);
|
||||||
g_beep_to_play = BEEP_NONE;
|
g_beep_to_play = BEEP_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_AIRCOPY
|
||||||
|
if (g_current_display_screen == DISPLAY_AIRCOPY)
|
||||||
|
{ // we're in AIRCOPY mode
|
||||||
|
|
||||||
|
BOARD_ADC_GetBatteryInfo(&g_usb_current_voltage, &g_usb_current);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (g_keypad_locked > 0)
|
||||||
|
if (--g_keypad_locked == 0)
|
||||||
|
g_update_display = true;
|
||||||
|
|
||||||
|
if (g_serial_config_tick_500ms > 0)
|
||||||
|
{ // config upload/download is running
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_update_screen_tick_500ms > 0)
|
if (g_update_screen_tick_500ms > 0)
|
||||||
{ // update display once every 500ms
|
{ // update display once every 500ms
|
||||||
if (--g_update_screen_tick_500ms == 0)
|
if (--g_update_screen_tick_500ms == 0)
|
||||||
@ -2010,24 +2021,19 @@ void APP_time_slice_500ms(void)
|
|||||||
if (g_fm_scan_state_dir == FM_SCAN_STATE_DIR_OFF || g_ask_to_save)
|
if (g_fm_scan_state_dir == FM_SCAN_STATE_DIR_OFF || g_ask_to_save)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_AIRCOPY
|
if (g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
||||||
if (g_current_display_screen != DISPLAY_AIRCOPY)
|
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||||
#endif
|
(g_current_display_screen != DISPLAY_SEARCH ||
|
||||||
|
g_search_css_state == SEARCH_CSS_STATE_FOUND ||
|
||||||
|
g_search_css_state == SEARCH_CSS_STATE_FAILED ||
|
||||||
|
g_search_css_state == SEARCH_CSS_STATE_REPEAT))
|
||||||
{
|
{
|
||||||
if (g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
#ifdef ENABLE_KEYLOCK
|
||||||
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
|
||||||
(g_current_display_screen != DISPLAY_SEARCH ||
|
|
||||||
g_search_css_state == SEARCH_CSS_STATE_FOUND ||
|
|
||||||
g_search_css_state == SEARCH_CSS_STATE_FAILED ||
|
|
||||||
g_search_css_state == SEARCH_CSS_STATE_REPEAT))
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef ENABLE_KEYLOCK
|
|
||||||
if (g_eeprom.config.setting.auto_key_lock != 0 &&
|
if (g_eeprom.config.setting.auto_key_lock != 0 &&
|
||||||
g_key_lock_tick_500ms > 0 &&
|
g_key_lock_tick_500ms > 0 &&
|
||||||
!g_dtmf_input_mode &&
|
!g_dtmf_input_mode &&
|
||||||
g_input_box_index == 0 &&
|
g_input_box_index == 0 &&
|
||||||
g_current_display_screen != DISPLAY_MENU)
|
g_current_display_screen != DISPLAY_MENU)
|
||||||
{
|
{
|
||||||
if (--g_key_lock_tick_500ms == 0)
|
if (--g_key_lock_tick_500ms == 0)
|
||||||
{ // lock the keyboard
|
{ // lock the keyboard
|
||||||
@ -2035,69 +2041,68 @@ void APP_time_slice_500ms(void)
|
|||||||
g_update_status = true;
|
g_update_status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (exit_menu)
|
if (exit_menu)
|
||||||
|
{
|
||||||
|
g_menu_tick_10ms = 0;
|
||||||
|
|
||||||
|
if (g_eeprom.config.setting.backlight_time == 0)
|
||||||
{
|
{
|
||||||
g_menu_tick_10ms = 0;
|
g_backlight_tick_500ms = 0;
|
||||||
|
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||||
if (g_eeprom.config.setting.backlight_time == 0)
|
}
|
||||||
{
|
|
||||||
g_backlight_tick_500ms = 0;
|
if (g_input_box_index > 0 || g_dtmf_input_mode)
|
||||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
||||||
}
|
/*
|
||||||
|
if (g_current_display_screen == DISPLAY_SEARCH)
|
||||||
if (g_input_box_index > 0 || g_dtmf_input_mode)
|
{
|
||||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
BK4819_StopScan();
|
||||||
/*
|
|
||||||
if (g_current_display_screen == DISPLAY_SEARCH)
|
RADIO_configure_channel(0, VFO_CONFIGURE_RELOAD);
|
||||||
{
|
RADIO_configure_channel(1, VFO_CONFIGURE_RELOAD);
|
||||||
BK4819_StopScan();
|
|
||||||
|
RADIO_setup_registers(true);
|
||||||
RADIO_configure_channel(0, VFO_CONFIGURE_RELOAD);
|
}
|
||||||
RADIO_configure_channel(1, VFO_CONFIGURE_RELOAD);
|
*/
|
||||||
|
DTMF_clear_input_box();
|
||||||
RADIO_setup_registers(true);
|
|
||||||
}
|
g_fkey_pressed = false;
|
||||||
*/
|
g_input_box_index = 0;
|
||||||
DTMF_clear_input_box();
|
|
||||||
|
g_ask_to_save = false;
|
||||||
g_fkey_pressed = false;
|
g_ask_to_delete = false;
|
||||||
g_input_box_index = 0;
|
|
||||||
|
g_update_status = true;
|
||||||
g_ask_to_save = false;
|
g_update_display = true;
|
||||||
g_ask_to_delete = false;
|
|
||||||
|
{
|
||||||
g_update_status = true;
|
gui_display_type_t disp = DISPLAY_INVALID;
|
||||||
g_update_display = true;
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
{
|
if (g_fm_radio_mode &&
|
||||||
gui_display_type_t disp = DISPLAY_INVALID;
|
g_current_function != FUNCTION_RECEIVE &&
|
||||||
|
g_current_function != FUNCTION_TRANSMIT &&
|
||||||
#ifdef ENABLE_FMRADIO
|
!g_monitor_enabled)
|
||||||
if (g_fm_radio_mode &&
|
|
||||||
g_current_function != FUNCTION_RECEIVE &&
|
|
||||||
g_current_function != FUNCTION_TRANSMIT &&
|
|
||||||
!g_monitor_enabled)
|
|
||||||
{
|
|
||||||
disp = DISPLAY_FM;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (disp == DISPLAY_INVALID)
|
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_CODE_SEARCH_TIMEOUT
|
disp = DISPLAY_FM;
|
||||||
if (g_current_display_screen != DISPLAY_SEARCH)
|
|
||||||
#endif
|
|
||||||
disp = DISPLAY_MAIN;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (disp != DISPLAY_INVALID)
|
|
||||||
GUI_SelectNextDisplay(disp);
|
if (disp == DISPLAY_INVALID)
|
||||||
|
{
|
||||||
|
#ifndef ENABLE_CODE_SEARCH_TIMEOUT
|
||||||
|
if (g_current_display_screen != DISPLAY_SEARCH)
|
||||||
|
#endif
|
||||||
|
disp = DISPLAY_MAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (disp != DISPLAY_INVALID)
|
||||||
|
GUI_SelectNextDisplay(disp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
|
if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
|
||||||
@ -2496,7 +2501,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
|||||||
|
|
||||||
if (key_held)
|
if (key_held)
|
||||||
{ // unlock the keypad
|
{ // unlock the keypad
|
||||||
g_eeprom.config.setting.g_eeprom.key_lock = false;
|
g_eeprom.config.setting.key_lock = false;
|
||||||
g_request_save_settings = true;
|
g_request_save_settings = true;
|
||||||
g_update_status = true;
|
g_update_status = true;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
|
|||||||
g_another_voice_id = g_eeprom.config.setting.key_lock ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
|
g_another_voice_id = g_eeprom.config.setting.key_lock ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_eeprom.config.setting.key_lock = (g_eeprom.key_lock + 1) & 1u;
|
g_eeprom.config.setting.key_lock = (g_eeprom.config.setting.key_lock + 1) & 1u;
|
||||||
g_request_save_settings = true;
|
g_request_save_settings = true;
|
||||||
g_update_status = true;
|
g_update_status = true;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#ifndef BK1080_REGS_H
|
#ifndef BK1080_REGS_H
|
||||||
#define BK1080_REGS_H
|
#define BK1080_REGS_H
|
||||||
|
|
||||||
enum BK1080_Register_t {
|
enum BK1080_register_e {
|
||||||
BK1080_REG_00 = 0x00U,
|
BK1080_REG_00 = 0x00U,
|
||||||
BK1080_REG_02_POWER_CONFIGURATION = 0x02U,
|
BK1080_REG_02_POWER_CONFIGURATION = 0x02U,
|
||||||
BK1080_REG_03_CHANNEL = 0x03U,
|
BK1080_REG_03_CHANNEL = 0x03U,
|
||||||
@ -26,8 +26,7 @@ enum BK1080_Register_t {
|
|||||||
BK1080_REG_10 = 0x0AU,
|
BK1080_REG_10 = 0x0AU,
|
||||||
BK1080_REG_25_INTERNAL = 0x19U,
|
BK1080_REG_25_INTERNAL = 0x19U,
|
||||||
};
|
};
|
||||||
|
typedef enum BK1080_register_e BK1080_register_t;
|
||||||
typedef enum BK1080_Register_t BK1080_Register_t;
|
|
||||||
|
|
||||||
// REG 07
|
// REG 07
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ void BK1080_Init(const uint16_t frequency, const bool initialise)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t BK1080_ReadRegister(BK1080_Register_t Register)
|
uint16_t BK1080_ReadRegister(BK1080_register_t Register)
|
||||||
{
|
{
|
||||||
uint8_t Value[2];
|
uint8_t Value[2];
|
||||||
I2C_Start();
|
I2C_Start();
|
||||||
@ -190,7 +190,7 @@ uint16_t BK1080_ReadRegister(BK1080_Register_t Register)
|
|||||||
return (Value[0] << 8) | Value[1];
|
return (Value[0] << 8) | Value[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value)
|
void BK1080_WriteRegister(BK1080_register_t Register, uint16_t Value)
|
||||||
{
|
{
|
||||||
I2C_Start();
|
I2C_Start();
|
||||||
I2C_Write(0x80);
|
I2C_Write(0x80);
|
||||||
|
@ -28,8 +28,8 @@ extern uint16_t BK1080_freq_base;
|
|||||||
extern int16_t BK1080_freq_offset;
|
extern int16_t BK1080_freq_offset;
|
||||||
|
|
||||||
void BK1080_Init(const uint16_t frequency, const bool initialise);
|
void BK1080_Init(const uint16_t frequency, const bool initialise);
|
||||||
uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
|
uint16_t BK1080_ReadRegister(BK1080_register_t Register);
|
||||||
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
|
void BK1080_WriteRegister(BK1080_register_t Register, uint16_t Value);
|
||||||
void BK1080_Mute(const bool Mute);
|
void BK1080_Mute(const bool Mute);
|
||||||
void BK1080_SetFrequency(uint16_t Frequency);
|
void BK1080_SetFrequency(uint16_t Frequency);
|
||||||
int16_t BK1080_get_freq_offset(const uint16_t Frequency);
|
int16_t BK1080_get_freq_offset(const uint16_t Frequency);
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
@ -308,9 +308,9 @@ void SETTINGS_read_eeprom(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SETTINGS_write_eeprom_config(void)
|
void SETTINGS_write_eeprom_config(void)
|
||||||
{ // save the entire EEPROM contents
|
{ // save the entire EEPROM config contents
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
for (index = 0; index < sizeof(g_eeprom); index += 8)
|
for (index = 0; index < sizeof(g_eeprom.config); index += 8)
|
||||||
EEPROM_WriteBuffer8(index, (uint8_t *)(&g_eeprom) + index);
|
EEPROM_WriteBuffer8(index, (uint8_t *)(&g_eeprom) + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
ui/main.c
20
ui/main.c
@ -257,8 +257,8 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
|
|||||||
char s[16];
|
char s[16];
|
||||||
|
|
||||||
#ifdef ENABLE_KEYLOCK
|
#ifdef ENABLE_KEYLOCK
|
||||||
if (g_eeprom.key_lock && g_keypad_locked > 0)
|
if (g_eeprom.config.setting.key_lock && g_keypad_locked > 0)
|
||||||
return false; // display is in use
|
return false; // display is in use
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (g_current_function == FUNCTION_TRANSMIT ||
|
if (g_current_function == FUNCTION_TRANSMIT ||
|
||||||
@ -446,14 +446,14 @@ void UI_DisplayMain(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_KEYLOCK
|
#ifdef ENABLE_KEYLOCK
|
||||||
if (g_eeprom.config.setting.key_lock && g_keypad_locked > 0)
|
if (g_eeprom.config.setting.key_lock && g_keypad_locked > 0)
|
||||||
{ // tell user how to unlock the keyboard
|
{ // tell user how to unlock the keyboard
|
||||||
backlight_turn_on(10); // 5 seconds
|
backlight_turn_on(10); // 5 seconds
|
||||||
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
|
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
|
||||||
UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8);
|
UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8);
|
||||||
ST7565_BlitFullScreen();
|
ST7565_BlitFullScreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (vfo_num = 0; vfo_num < 2; vfo_num++)
|
for (vfo_num = 0; vfo_num < 2; vfo_num++)
|
||||||
|
Reference in New Issue
Block a user