0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

Fixed power save and added display contrast menu

This commit is contained in:
OneOfEleven
2023-10-10 03:56:28 +01:00
parent a552b040d8
commit 6660d0078f
19 changed files with 219 additions and 132 deletions

View File

@ -77,7 +77,7 @@ void ACTION_Monitor(void)
if (g_current_function != FUNCTION_MONITOR)
{ // enable the monitor
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
#ifdef g_power_save_expired
if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST && g_is_noaa_mode)
g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST;
#endif
@ -95,7 +95,7 @@ void ACTION_Monitor(void)
g_scan_pause_mode = true;
}
#ifdef ENABLE_NOAA
#ifdef g_power_save_expired
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode)
{
g_noaa_count_down_10ms = noaa_count_down_10ms;
@ -180,7 +180,7 @@ void ACTION_Scan(bool bRestart)
RADIO_SelectVfos();
#ifdef ENABLE_NOAA
#ifdef g_power_save_expired
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
#endif
{

167
app/app.c
View File

@ -208,13 +208,13 @@ static void APP_HandleIncoming(void)
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_count_down_10ms > 0)
{
g_noaa_count_down_10ms = 0;
flag = true;
flag = true;
}
#endif
if (g_CTCSS_lost && g_current_code_type == CODE_TYPE_CONTINUOUS_TONE)
{
flag = true;
flag = true;
g_found_CTCSS = false;
}
@ -322,7 +322,7 @@ static void APP_HandleReceive(void)
{
if (g_CxCSS_tail_found)
{
Mode = END_OF_RX_MODE_TTE;
Mode = END_OF_RX_MODE_TTE;
g_CxCSS_tail_found = false;
}
}
@ -336,13 +336,13 @@ static void APP_HandleReceive(void)
else
if (!g_found_CTCSS)
{
g_found_CTCSS = true;
g_found_CTCSS = true;
g_found_CTCSS_count_down_10ms = 100; // 1 sec
}
if (g_CxCSS_tail_found)
{
Mode = END_OF_RX_MODE_TTE;
Mode = END_OF_RX_MODE_TTE;
g_CxCSS_tail_found = false;
}
break;
@ -356,7 +356,7 @@ static void APP_HandleReceive(void)
else
if (!g_found_CDCSS)
{
g_found_CDCSS = true;
g_found_CDCSS = true;
g_found_CDCSS_count_down_10ms = 100; // 1 sec
}
@ -375,15 +375,19 @@ static void APP_HandleReceive(void)
else
Mode = END_OF_RX_MODE_END;
if (!g_end_of_rx_detected_maybe &&
Mode == END_OF_RX_MODE_SKIP &&
g_next_time_slice_40ms &&
if (!g_end_of_rx_detected_maybe &&
Mode == END_OF_RX_MODE_SKIP &&
g_next_time_slice_40ms &&
g_eeprom.tail_note_elimination &&
(g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL) &&
BK4819_GetCTCType() == 1)
{
Mode = END_OF_RX_MODE_TTE;
}
else
{
g_next_time_slice_40ms = false;
}
Skip:
switch (Mode)
@ -520,7 +524,6 @@ void APP_StartListening(function_type_t Function, const bool reset_am_fix)
g_rx_vfo->pRX->frequency = NoaaFrequencyTable[g_noaa_channel];
g_rx_vfo->pTX->frequency = NoaaFrequencyTable[g_noaa_channel];
g_eeprom.screen_channel[chan] = g_rx_vfo->channel_save;
g_noaa_count_down_10ms = 500; // 5 sec
g_schedule_noaa = false;
}
@ -873,15 +876,15 @@ void APP_CheckRadioInterrupts(void)
#ifdef ENABLE_VOX
if (interrupt_status_bits & BK4819_REG_02_VOX_LOST)
{
g_vox_lost = true;
g_vox_lost = true;
g_vox_pause_count_down = 10;
if (g_eeprom.vox_switch)
{
if (g_current_function == FUNCTION_POWER_SAVE && !g_rx_idle_mode)
{
g_power_save_10ms = power_save2_10ms;
g_power_save_count_down_expired = 0;
g_power_save_10ms = power_save2_10ms;
g_power_save_expired = false;
}
if (g_eeprom.dual_watch != DUAL_WATCH_OFF && (g_schedule_dual_watch || g_dual_watch_count_down_10ms < dual_watch_count_after_vox_10ms))
@ -1117,16 +1120,16 @@ void APP_Update(void)
#ifdef ENABLE_NOAA
#ifdef ENABLE_VOICE
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa && g_voice_write_index == 0)
#else
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa)
if (g_voice_write_index == 0)
#endif
{
NOAA_IncreaseChannel();
RADIO_SetupRegisters(false);
g_noaa_count_down_10ms = 7; // 70ms
g_schedule_noaa = false;
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa)
{
NOAA_IncreaseChannel();
RADIO_SetupRegisters(false);
g_noaa_count_down_10ms = 7; // 70ms
g_schedule_noaa = false;
}
}
#endif
@ -1187,7 +1190,7 @@ void APP_Update(void)
#ifdef ENABLE_NOAA
if (
#ifdef ENABLE_FMRADIO
g_fm_radio_mode ||
g_fm_radio_mode ||
#endif
g_ptt_is_pressed ||
g_key_held ||
@ -1200,7 +1203,9 @@ void APP_Update(void)
g_battery_save_count_down_10ms = battery_save_count_10ms;
}
else
if ((IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) && IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1])) || !g_is_noaa_mode)
if ((IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) &&
IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[1])) ||
!g_is_noaa_mode)
{
FUNCTION_Select(FUNCTION_POWER_SAVE);
}
@ -1211,7 +1216,7 @@ void APP_Update(void)
#else
if (
#ifdef ENABLE_FMRADIO
g_fm_radio_mode ||
g_fm_radio_mode ||
#endif
g_ptt_is_pressed ||
g_key_held ||
@ -1227,69 +1232,76 @@ void APP_Update(void)
{
FUNCTION_Select(FUNCTION_POWER_SAVE);
}
g_schedule_power_save = false;
#endif
g_schedule_power_save = false;
}
#ifdef ENABLE_VOICE
if (g_power_save_count_down_expired && g_current_function == FUNCTION_POWER_SAVE && g_voice_write_index == 0)
#else
if (g_power_save_count_down_expired && g_current_function == FUNCTION_POWER_SAVE)
#endif
{ // wake up, enable RX then go back to sleep
#ifdef ENABLE_VOICE
if (g_voice_write_index == 0)
#endif
{
if (g_power_save_expired && g_current_function == FUNCTION_POWER_SAVE)
{ // wake up, enable RX then go back to sleep
if (g_rx_idle_mode)
{
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("ps wake up\r\n");
#endif
if (g_rx_idle_mode)
{
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
#ifdef ENABLE_VOX
if (g_eeprom.vox_switch)
BK4819_EnableVox(g_eeprom.vox1_threshold, g_eeprom.vox0_threshold);
#endif
#ifdef ENABLE_VOX
if (g_eeprom.vox_switch)
BK4819_EnableVox(g_eeprom.vox1_threshold, g_eeprom.vox0_threshold);
#endif
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
g_scan_state_dir == SCAN_OFF &&
g_css_scan_mode == CSS_SCAN_MODE_OFF)
{ // dual watch mode, toggle between the two VFO's
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
g_scan_state_dir == SCAN_OFF &&
g_css_scan_mode == CSS_SCAN_MODE_OFF)
{ // dual watch mode, toggle between the two VFO's
DUALWATCH_Alternate();
g_update_rssi = false;
}
FUNCTION_Init();
g_power_save_10ms = power_save1_10ms; // come back here in a bit
g_rx_idle_mode = false; // RX is awake
}
else
if (g_eeprom.dual_watch == DUAL_WATCH_OFF ||
g_scan_state_dir != SCAN_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_update_rssi)
{ // dual watch mode, go back to sleep
updateRSSI(g_eeprom.rx_vfo);
// go back to sleep
g_power_save_10ms = g_eeprom.battery_save * 10;
g_rx_idle_mode = true;
BK4819_DisableVox();
BK4819_Sleep();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false);
// Authentic device checked removed
}
else
{
// toggle between the two VFO's
DUALWATCH_Alternate();
g_update_rssi = false;
g_update_rssi = true;
g_power_save_10ms = power_save1_10ms;
}
FUNCTION_Init();
g_power_save_10ms = power_save1_10ms; // come back here in a bit
g_rx_idle_mode = false; // RX is awake
g_power_save_expired = false;
}
else
if (g_eeprom.dual_watch == DUAL_WATCH_OFF || g_scan_state_dir != SCAN_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF || g_update_rssi)
{ // dual watch mode, go back to sleep
updateRSSI(g_eeprom.rx_vfo);
// go back to sleep
g_power_save_10ms = g_eeprom.battery_save * 10;
g_rx_idle_mode = true;
BK4819_DisableVox();
BK4819_Sleep();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false);
// Authentic device checked removed
}
else
{
// toggle between the two VFO's
DUALWATCH_Alternate();
g_update_rssi = true;
g_power_save_10ms = power_save1_10ms;
}
g_power_save_count_down_expired = false;
}
}
@ -2061,8 +2073,7 @@ void APP_TimeSlice500ms(void)
g_reduced_service = true;
//if (g_current_function != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);
FUNCTION_Select(FUNCTION_POWER_SAVE);
ST7565_HardwareReset();

View File

@ -31,6 +31,7 @@
#include "driver/eeprom.h"
#include "driver/gpio.h"
#include "driver/keyboard.h"
#include "driver/st7565.h"
#include "frequencies.h"
#include "helper/battery.h"
#include "misc.h"
@ -214,6 +215,13 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
*pMax = ARRAY_SIZE(g_sub_menu_rx_tx) - 1;
break;
case MENU_CONTRAST:
// *pMin = 0;
// *pMax = 63;
*pMin = 26;
*pMax = 45;
break;
#ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1:
*pMin = 0;
@ -537,6 +545,11 @@ void MENU_AcceptSetting(void)
g_setting_backlight_on_tx_rx = g_sub_menu_selection;
break;
case MENU_CONTRAST:
g_setting_contrast = g_sub_menu_selection;
ST7565_SetContrast(g_setting_contrast);
break;
case MENU_TDR:
// g_eeprom.dual_watch = g_sub_menu_selection;
g_eeprom.dual_watch = (g_sub_menu_selection > 0) ? 1 + g_eeprom.tx_vfo : DUAL_WATCH_OFF;
@ -1003,6 +1016,10 @@ void MENU_ShowCurrentSetting(void)
g_sub_menu_selection = g_setting_backlight_on_tx_rx;
break;
case MENU_CONTRAST:
g_sub_menu_selection = g_setting_contrast;
break;
case MENU_TDR:
// g_sub_menu_selection = g_eeprom.dual_watch;
g_sub_menu_selection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1;

View File

@ -395,11 +395,11 @@ static void CMD_052F(const uint8_t *pBuffer)
{
const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer;
g_eeprom.dual_watch = DUAL_WATCH_OFF;
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
g_eeprom.rx_vfo = 0;
g_eeprom.dtmf_side_tone = false;
g_eeprom.vfo_info[0].frequency_reverse = false;
g_eeprom.dual_watch = DUAL_WATCH_OFF;
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
g_eeprom.rx_vfo = 0;
g_eeprom.dtmf_side_tone = false;
g_eeprom.vfo_info[0].frequency_reverse = false;
g_eeprom.vfo_info[0].pRX = &g_eeprom.vfo_info[0].freq_config_rx;
g_eeprom.vfo_info[0].pTX = &g_eeprom.vfo_info[0].freq_config_tx;
g_eeprom.vfo_info[0].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF;