0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-19 00:11:18 +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

@ -9,7 +9,7 @@ ENABLE_OVERLAY := 0
ENABLE_LTO := 1 ENABLE_LTO := 1
ENABLE_UART := 1 ENABLE_UART := 1
ENABLE_UART_DEBUG := 1 ENABLE_UART_DEBUG := 1
ENABLE_AIRCOPY := 1 ENABLE_AIRCOPY := 0
ENABLE_FMRADIO := 1 ENABLE_FMRADIO := 1
ENABLE_NOAA := 1 ENABLE_NOAA := 1
ENABLE_VOICE := 0 ENABLE_VOICE := 0

View File

@ -77,7 +77,7 @@ void ACTION_Monitor(void)
if (g_current_function != FUNCTION_MONITOR) if (g_current_function != FUNCTION_MONITOR)
{ // enable the monitor { // enable the monitor
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef g_power_save_expired
if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST && g_is_noaa_mode) if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST && g_is_noaa_mode)
g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST; g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST;
#endif #endif
@ -95,7 +95,7 @@ void ACTION_Monitor(void)
g_scan_pause_mode = true; 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) if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode)
{ {
g_noaa_count_down_10ms = noaa_count_down_10ms; g_noaa_count_down_10ms = noaa_count_down_10ms;
@ -180,7 +180,7 @@ void ACTION_Scan(bool bRestart)
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifdef ENABLE_NOAA #ifdef g_power_save_expired
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save)) if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
#endif #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) if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_count_down_10ms > 0)
{ {
g_noaa_count_down_10ms = 0; g_noaa_count_down_10ms = 0;
flag = true; flag = true;
} }
#endif #endif
if (g_CTCSS_lost && g_current_code_type == CODE_TYPE_CONTINUOUS_TONE) if (g_CTCSS_lost && g_current_code_type == CODE_TYPE_CONTINUOUS_TONE)
{ {
flag = true; flag = true;
g_found_CTCSS = false; g_found_CTCSS = false;
} }
@ -322,7 +322,7 @@ static void APP_HandleReceive(void)
{ {
if (g_CxCSS_tail_found) if (g_CxCSS_tail_found)
{ {
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
g_CxCSS_tail_found = false; g_CxCSS_tail_found = false;
} }
} }
@ -336,13 +336,13 @@ static void APP_HandleReceive(void)
else else
if (!g_found_CTCSS) if (!g_found_CTCSS)
{ {
g_found_CTCSS = true; g_found_CTCSS = true;
g_found_CTCSS_count_down_10ms = 100; // 1 sec g_found_CTCSS_count_down_10ms = 100; // 1 sec
} }
if (g_CxCSS_tail_found) if (g_CxCSS_tail_found)
{ {
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
g_CxCSS_tail_found = false; g_CxCSS_tail_found = false;
} }
break; break;
@ -356,7 +356,7 @@ static void APP_HandleReceive(void)
else else
if (!g_found_CDCSS) if (!g_found_CDCSS)
{ {
g_found_CDCSS = true; g_found_CDCSS = true;
g_found_CDCSS_count_down_10ms = 100; // 1 sec g_found_CDCSS_count_down_10ms = 100; // 1 sec
} }
@ -375,15 +375,19 @@ static void APP_HandleReceive(void)
else else
Mode = END_OF_RX_MODE_END; Mode = END_OF_RX_MODE_END;
if (!g_end_of_rx_detected_maybe && if (!g_end_of_rx_detected_maybe &&
Mode == END_OF_RX_MODE_SKIP && Mode == END_OF_RX_MODE_SKIP &&
g_next_time_slice_40ms && g_next_time_slice_40ms &&
g_eeprom.tail_note_elimination && g_eeprom.tail_note_elimination &&
(g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL) && (g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL) &&
BK4819_GetCTCType() == 1) BK4819_GetCTCType() == 1)
{
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
}
else else
{
g_next_time_slice_40ms = false; g_next_time_slice_40ms = false;
}
Skip: Skip:
switch (Mode) 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->pRX->frequency = NoaaFrequencyTable[g_noaa_channel];
g_rx_vfo->pTX->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_eeprom.screen_channel[chan] = g_rx_vfo->channel_save;
g_noaa_count_down_10ms = 500; // 5 sec g_noaa_count_down_10ms = 500; // 5 sec
g_schedule_noaa = false; g_schedule_noaa = false;
} }
@ -873,15 +876,15 @@ void APP_CheckRadioInterrupts(void)
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
if (interrupt_status_bits & BK4819_REG_02_VOX_LOST) if (interrupt_status_bits & BK4819_REG_02_VOX_LOST)
{ {
g_vox_lost = true; g_vox_lost = true;
g_vox_pause_count_down = 10; g_vox_pause_count_down = 10;
if (g_eeprom.vox_switch) if (g_eeprom.vox_switch)
{ {
if (g_current_function == FUNCTION_POWER_SAVE && !g_rx_idle_mode) if (g_current_function == FUNCTION_POWER_SAVE && !g_rx_idle_mode)
{ {
g_power_save_10ms = power_save2_10ms; g_power_save_10ms = power_save2_10ms;
g_power_save_count_down_expired = 0; 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)) 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_NOAA
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa && g_voice_write_index == 0) if (g_voice_write_index == 0)
#else
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa)
#endif #endif
{ {
NOAA_IncreaseChannel(); if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode && g_schedule_noaa)
RADIO_SetupRegisters(false); {
NOAA_IncreaseChannel();
g_noaa_count_down_10ms = 7; // 70ms RADIO_SetupRegisters(false);
g_schedule_noaa = false; g_noaa_count_down_10ms = 7; // 70ms
g_schedule_noaa = false;
}
} }
#endif #endif
@ -1187,7 +1190,7 @@ void APP_Update(void)
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if ( if (
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
g_fm_radio_mode || g_fm_radio_mode ||
#endif #endif
g_ptt_is_pressed || g_ptt_is_pressed ||
g_key_held || g_key_held ||
@ -1200,7 +1203,9 @@ void APP_Update(void)
g_battery_save_count_down_10ms = battery_save_count_10ms; g_battery_save_count_down_10ms = battery_save_count_10ms;
} }
else 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); FUNCTION_Select(FUNCTION_POWER_SAVE);
} }
@ -1211,7 +1216,7 @@ void APP_Update(void)
#else #else
if ( if (
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
g_fm_radio_mode || g_fm_radio_mode ||
#endif #endif
g_ptt_is_pressed || g_ptt_is_pressed ||
g_key_held || g_key_held ||
@ -1227,69 +1232,76 @@ void APP_Update(void)
{ {
FUNCTION_Select(FUNCTION_POWER_SAVE); FUNCTION_Select(FUNCTION_POWER_SAVE);
} }
g_schedule_power_save = false;
#endif #endif
g_schedule_power_save = false;
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
if (g_power_save_count_down_expired && g_current_function == FUNCTION_POWER_SAVE && g_voice_write_index == 0) if (g_voice_write_index == 0)
#else #endif
if (g_power_save_count_down_expired && g_current_function == FUNCTION_POWER_SAVE) {
#endif if (g_power_save_expired && g_current_function == FUNCTION_POWER_SAVE)
{ // wake up, enable RX then go back to sleep { // 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 #ifdef ENABLE_VOX
if (g_eeprom.vox_switch) if (g_eeprom.vox_switch)
BK4819_EnableVox(g_eeprom.vox1_threshold, g_eeprom.vox0_threshold); BK4819_EnableVox(g_eeprom.vox1_threshold, g_eeprom.vox0_threshold);
#endif #endif
if (g_eeprom.dual_watch != DUAL_WATCH_OFF && if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
g_scan_state_dir == SCAN_OFF && g_scan_state_dir == SCAN_OFF &&
g_css_scan_mode == CSS_SCAN_MODE_OFF) g_css_scan_mode == CSS_SCAN_MODE_OFF)
{ // dual watch mode, toggle between the two VFO's { // 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(); DUALWATCH_Alternate();
g_update_rssi = false; g_update_rssi = true;
g_power_save_10ms = power_save1_10ms;
} }
FUNCTION_Init(); g_power_save_expired = false;
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 = 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; g_reduced_service = true;
//if (g_current_function != FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_POWER_SAVE);
FUNCTION_Select(FUNCTION_POWER_SAVE);
ST7565_HardwareReset(); ST7565_HardwareReset();

View File

@ -31,6 +31,7 @@
#include "driver/eeprom.h" #include "driver/eeprom.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/keyboard.h" #include "driver/keyboard.h"
#include "driver/st7565.h"
#include "frequencies.h" #include "frequencies.h"
#include "helper/battery.h" #include "helper/battery.h"
#include "misc.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; *pMax = ARRAY_SIZE(g_sub_menu_rx_tx) - 1;
break; break;
case MENU_CONTRAST:
// *pMin = 0;
// *pMax = 63;
*pMin = 26;
*pMax = 45;
break;
#ifdef ENABLE_AM_FIX_TEST1 #ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1: case MENU_AM_FIX_TEST1:
*pMin = 0; *pMin = 0;
@ -537,6 +545,11 @@ void MENU_AcceptSetting(void)
g_setting_backlight_on_tx_rx = g_sub_menu_selection; g_setting_backlight_on_tx_rx = g_sub_menu_selection;
break; break;
case MENU_CONTRAST:
g_setting_contrast = g_sub_menu_selection;
ST7565_SetContrast(g_setting_contrast);
break;
case MENU_TDR: case MENU_TDR:
// g_eeprom.dual_watch = g_sub_menu_selection; // 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; 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; g_sub_menu_selection = g_setting_backlight_on_tx_rx;
break; break;
case MENU_CONTRAST:
g_sub_menu_selection = g_setting_contrast;
break;
case MENU_TDR: case MENU_TDR:
// g_sub_menu_selection = g_eeprom.dual_watch; // g_sub_menu_selection = g_eeprom.dual_watch;
g_sub_menu_selection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1; 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; const CMD_052F_t *pCmd = (const CMD_052F_t *)pBuffer;
g_eeprom.dual_watch = DUAL_WATCH_OFF; g_eeprom.dual_watch = DUAL_WATCH_OFF;
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
g_eeprom.rx_vfo = 0; g_eeprom.rx_vfo = 0;
g_eeprom.dtmf_side_tone = false; g_eeprom.dtmf_side_tone = false;
g_eeprom.vfo_info[0].frequency_reverse = 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].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].pTX = &g_eeprom.vfo_info[0].freq_config_tx;
g_eeprom.vfo_info[0].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF; g_eeprom.vfo_info[0].tx_offset_freq_dir = TX_OFFSET_FREQ_DIR_OFF;

View File

@ -540,6 +540,7 @@ void BOARD_EEPROM_Init(void)
// 0E78..0E7F // 0E78..0E7F
EEPROM_ReadBuffer(0x0E78, Data, 8); EEPROM_ReadBuffer(0x0E78, Data, 8);
g_setting_contrast = (Data[0] > 45) ? 31 : (Data[0] < 26) ? 31 : Data[0];
g_eeprom.channel_display_mode = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode g_eeprom.channel_display_mode = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode
g_eeprom.cross_vfo_rx_tx = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; g_eeprom.cross_vfo_rx_tx = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
g_eeprom.battery_save = (Data[3] < 5) ? Data[3] : 4; g_eeprom.battery_save = (Data[3] < 5) ? Data[3] : 4;

View File

@ -27,6 +27,7 @@
uint8_t g_status_line[128]; uint8_t g_status_line[128];
uint8_t g_frame_buffer[7][128]; uint8_t g_frame_buffer[7][128];
uint8_t contrast = 31; // 0 ~ 63
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap) void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap)
{ {
@ -64,6 +65,10 @@ void ST7565_BlitFullScreen(void)
{ {
unsigned int Line; unsigned int Line;
// reset some of the displays settings to try and overcome the
// radios hardware problem - RF corrupting the display
ST7565_Init(false);
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
ST7565_WriteByte(0x40); ST7565_WriteByte(0x40);
@ -82,7 +87,7 @@ void ST7565_BlitFullScreen(void)
} }
#if 0 #if 0
// whats the delay for I wonder, it holds things up :( // whats the delay for, it holds things up :(
SYSTEM_DelayMs(20); SYSTEM_DelayMs(20);
#else #else
// SYSTEM_DelayMs(1); // SYSTEM_DelayMs(1);
@ -115,11 +120,12 @@ void ST7565_BlitStatusLine(void)
SPI_ToggleMasterMode(&SPI0->CR, true); SPI_ToggleMasterMode(&SPI0->CR, true);
} }
void ST7565_FillScreen(uint8_t Value) void ST7565_FillScreen(const uint8_t Value)
{ {
unsigned int i; unsigned int i;
// reset some of the displays settings to try and overcome the radios hardware problem - RF corrupting the display // reset some of the displays settings to try and overcome the
// radios hardware problem - RF corrupting the display
ST7565_Init(false); ST7565_Init(false);
SPI_ToggleMasterMode(&SPI0->CR, false); SPI_ToggleMasterMode(&SPI0->CR, false);
@ -166,9 +172,9 @@ void ST7565_Init(const bool full)
ST7565_WriteByte(0xA4); // all points normal ST7565_WriteByte(0xA4); // all points normal
ST7565_WriteByte(0x24); // ST7565_WriteByte(0x24); //
ST7565_WriteByte(0x81); // volume first ?
ST7565_WriteByte(0x1f); // contrast ? ST7565_WriteByte(0x81); //
ST7565_WriteByte(contrast); // contrast ? 0 ~ 63
if (full) if (full)
{ {
@ -209,7 +215,7 @@ void ST7565_HardwareReset(void)
SYSTEM_DelayMs(120); SYSTEM_DelayMs(120);
} }
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line) void ST7565_SelectColumnAndLine(const uint8_t Column, const uint8_t Line)
{ {
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0); GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {} while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
@ -221,9 +227,19 @@ void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line)
SPI_WaitForUndocumentedTxFifoStatusBit(); SPI_WaitForUndocumentedTxFifoStatusBit();
} }
void ST7565_WriteByte(uint8_t Value) void ST7565_WriteByte(const uint8_t Value)
{ {
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0); GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {} while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
SPI0->WDR = Value; SPI0->WDR = Value;
} }
void ST7565_SetContrast(const uint8_t value)
{
contrast = (value <= 63) ? value : 63;
}
uint8_t ST7565_GetContrast(void)
{
return contrast;
}

View File

@ -26,14 +26,16 @@
extern uint8_t g_status_line[128]; extern uint8_t g_status_line[128];
extern uint8_t g_frame_buffer[7][128]; extern uint8_t g_frame_buffer[7][128];
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap); void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const unsigned int Size, const uint8_t *pBitmap);
void ST7565_BlitFullScreen(void); void ST7565_BlitFullScreen(void);
void ST7565_BlitStatusLine(void); void ST7565_BlitStatusLine(void);
void ST7565_FillScreen(uint8_t Value); void ST7565_FillScreen(const uint8_t Value);
void ST7565_Init(const bool full); void ST7565_Init(const bool full);
void ST7565_HardwareReset(void); void ST7565_HardwareReset(void);
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); void ST7565_SelectColumnAndLine(const uint8_t Column, const uint8_t Line);
void ST7565_WriteByte(uint8_t Value); void ST7565_WriteByte(const uint8_t Value);
void ST7565_SetContrast(const uint8_t value);
uint8_t ST7565_GetContrast(void);
#endif #endif

Binary file not shown.

Binary file not shown.

View File

@ -29,6 +29,7 @@
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/system.h" #include "driver/system.h"
#include "driver/uart.h"
#include "frequencies.h" #include "frequencies.h"
#include "functions.h" #include "functions.h"
#include "helper/battery.h" #include "helper/battery.h"
@ -84,31 +85,36 @@ void FUNCTION_Init(void)
void FUNCTION_Select(function_type_t Function) void FUNCTION_Select(function_type_t Function)
{ {
const function_type_t PreviousFunction = g_current_function; const function_type_t prev_func = g_current_function;
const bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE); const bool was_power_save = (prev_func == FUNCTION_POWER_SAVE);
g_current_function = Function; g_current_function = Function;
if (bWasPowerSave && Function != FUNCTION_POWER_SAVE) if (was_power_save && Function != FUNCTION_POWER_SAVE)
{ { // wake up
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
g_rx_idle_mode = false; g_rx_idle_mode = false;
UI_DisplayStatus(false); UI_DisplayStatus(false);
} }
switch (Function) switch (Function)
{ {
case FUNCTION_FOREGROUND: case FUNCTION_FOREGROUND:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("func forground\r\n");
#endif
if (g_dtmf_reply_state != DTMF_REPLY_NONE) if (g_dtmf_reply_state != DTMF_REPLY_NONE)
RADIO_PrepareCssTX(); RADIO_PrepareCssTX();
if (PreviousFunction == FUNCTION_TRANSMIT) if (prev_func == FUNCTION_TRANSMIT)
{ {
g_vfo_rssi_bar_level[0] = 0; g_vfo_rssi_bar_level[0] = 0;
g_vfo_rssi_bar_level[1] = 0; g_vfo_rssi_bar_level[1] = 0;
} }
else else
if (PreviousFunction != FUNCTION_RECEIVE) if (prev_func != FUNCTION_RECEIVE)
break; break;
#if defined(ENABLE_FMRADIO) #if defined(ENABLE_FMRADIO)
@ -127,16 +133,32 @@ void FUNCTION_Select(function_type_t Function)
return; return;
case FUNCTION_MONITOR: case FUNCTION_MONITOR:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("func monitor\r\n");
#endif
g_monitor_enabled = true; g_monitor_enabled = true;
break; break;
case FUNCTION_INCOMING: case FUNCTION_INCOMING:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("func incoming\r\n");
#endif
break;
case FUNCTION_RECEIVE: case FUNCTION_RECEIVE:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("func receive\r\n");
#endif
break; break;
case FUNCTION_POWER_SAVE: case FUNCTION_POWER_SAVE:
g_power_save_10ms = g_eeprom.battery_save * 10; #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
g_power_save_count_down_expired = false; UART_SendText("func power save\r\n");
#endif
g_power_save_10ms = g_eeprom.battery_save * 10;
g_power_save_expired = false;
g_rx_idle_mode = true; g_rx_idle_mode = true;
@ -155,6 +177,9 @@ void FUNCTION_Select(function_type_t Function)
return; return;
case FUNCTION_TRANSMIT: case FUNCTION_TRANSMIT:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("func transmit\r\n");
#endif
// if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11 // if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11
BK4819_DisableDTMF(); BK4819_DisableDTMF();
@ -247,7 +272,7 @@ void FUNCTION_Select(function_type_t Function)
} }
g_battery_save_count_down_10ms = battery_save_count_10ms; g_battery_save_count_down_10ms = battery_save_count_10ms;
g_schedule_power_save = false; g_schedule_power_save = false;
#if defined(ENABLE_FMRADIO) #if defined(ENABLE_FMRADIO)
g_fm_restore_count_down_10ms = 0; g_fm_restore_count_down_10ms = 0;

3
main.c
View File

@ -29,6 +29,7 @@
#include "driver/backlight.h" #include "driver/backlight.h"
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/st7565.h"
#include "driver/system.h" #include "driver/system.h"
#include "driver/systick.h" #include "driver/systick.h"
#include "driver/uart.h" #include "driver/uart.h"
@ -116,6 +117,8 @@ void Main(void)
// sort the menu list // sort the menu list
UI_SortMenu(!g_f_lock); UI_SortMenu(!g_f_lock);
ST7565_SetContrast(g_setting_contrast);
// wait for user to release all butts before moving on // wait for user to release all butts before moving on
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) ||
KEYBOARD_Poll() != KEY_INVALID || KEYBOARD_Poll() != KEY_INVALID ||

4
misc.c
View File

@ -107,6 +107,8 @@ uint8_t g_setting_backlight_on_tx_rx;
bool g_setting_live_dtmf_decoder; bool g_setting_live_dtmf_decoder;
uint8_t g_setting_battery_text; uint8_t g_setting_battery_text;
uint8_t g_setting_contrast;
uint8_t g_setting_side1_short; uint8_t g_setting_side1_short;
uint8_t g_setting_side1_long; uint8_t g_setting_side1_long;
uint8_t g_setting_side2_short; uint8_t g_setting_side2_short;
@ -133,7 +135,7 @@ uint8_t g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
volatile uint16_t g_battery_save_count_down_10ms = battery_save_count_10ms; volatile uint16_t g_battery_save_count_down_10ms = battery_save_count_10ms;
volatile bool g_power_save_count_down_expired; volatile bool g_power_save_expired;
volatile bool g_schedule_power_save; volatile bool g_schedule_power_save;
volatile bool g_schedule_dual_watch = true; volatile bool g_schedule_dual_watch = true;

4
misc.h
View File

@ -183,6 +183,8 @@ extern uint8_t g_setting_backlight_on_tx_rx;
extern bool g_setting_live_dtmf_decoder; extern bool g_setting_live_dtmf_decoder;
extern uint8_t g_setting_battery_text; extern uint8_t g_setting_battery_text;
extern uint8_t g_setting_contrast;
extern uint8_t g_setting_side1_short; extern uint8_t g_setting_side1_short;
extern uint8_t g_setting_side1_long; extern uint8_t g_setting_side1_long;
extern uint8_t g_setting_side2_short; extern uint8_t g_setting_side2_short;
@ -210,7 +212,7 @@ extern uint8_t g_user_channel_attributes[207];
extern volatile uint16_t g_battery_save_count_down_10ms; extern volatile uint16_t g_battery_save_count_down_10ms;
extern volatile bool g_power_save_count_down_expired; extern volatile bool g_power_save_expired;
extern volatile bool g_schedule_power_save; extern volatile bool g_schedule_power_save;
extern volatile bool g_schedule_dual_watch; extern volatile bool g_schedule_dual_watch;

View File

@ -76,7 +76,7 @@ void SystickHandler(void)
DECREMENT_AND_TRIGGER(g_battery_save_count_down_10ms, g_schedule_power_save); DECREMENT_AND_TRIGGER(g_battery_save_count_down_10ms, g_schedule_power_save);
if (g_current_function == FUNCTION_POWER_SAVE) if (g_current_function == FUNCTION_POWER_SAVE)
DECREMENT_AND_TRIGGER(g_power_save_10ms, g_power_save_count_down_expired); DECREMENT_AND_TRIGGER(g_power_save_10ms, g_power_save_expired);
if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch != DUAL_WATCH_OFF) if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch != DUAL_WATCH_OFF)
if (g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE) if (g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE)

View File

@ -96,7 +96,8 @@ void SETTINGS_SaveSettings(void)
State[7] = g_eeprom.mic_sensitivity; State[7] = g_eeprom.mic_sensitivity;
EEPROM_WriteBuffer(0x0E70, State); EEPROM_WriteBuffer(0x0E70, State);
State[0] = 0xFF; //State[0] = 0xFF;
State[0] = g_setting_contrast;
State[1] = g_eeprom.channel_display_mode; State[1] = g_eeprom.channel_display_mode;
State[2] = g_eeprom.cross_vfo_rx_tx; State[2] = g_eeprom.cross_vfo_rx_tx;
State[3] = g_eeprom.battery_save; State[3] = g_eeprom.battery_save;

View File

@ -37,9 +37,7 @@ extern center_line_t center_line;
#ifdef ENABLE_AUDIO_BAR #ifdef ENABLE_AUDIO_BAR
void UI_DisplayAudioBar(void); void UI_DisplayAudioBar(void);
#endif #endif
#ifdef ENABLE_RSSI_BAR void UI_UpdateRSSI(const int16_t rssi, const int vfo);
void UI_UpdateRSSI(const int16_t rssi, const int vfo);
#endif
void UI_DisplayMain(void); void UI_DisplayMain(void);
#endif #endif

View File

@ -70,6 +70,7 @@ const t_menu_item g_menu_list[] =
#endif #endif
{"Bak LT", VOICE_ID_INVALID, MENU_ABR }, // was "ABR" {"Bak LT", VOICE_ID_INVALID, MENU_ABR }, // was "ABR"
{"BLTTRX", VOICE_ID_INVALID, MENU_ABR_ON_TX_RX }, {"BLTTRX", VOICE_ID_INVALID, MENU_ABR_ON_TX_RX },
{"CTRAST", VOICE_ID_INVALID, MENU_CONTRAST },
{"BEEP", VOICE_ID_BEEP_PROMPT, MENU_BEEP }, {"BEEP", VOICE_ID_BEEP_PROMPT, MENU_BEEP },
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
{"VOICE", VOICE_ID_VOICE_PROMPT, MENU_VOICE }, {"VOICE", VOICE_ID_VOICE_PROMPT, MENU_VOICE },
@ -672,6 +673,13 @@ void UI_DisplayMenu(void)
strcpy(String, g_sub_menu_rx_tx[g_sub_menu_selection]); strcpy(String, g_sub_menu_rx_tx[g_sub_menu_selection]);
break; break;
case MENU_CONTRAST:
sprintf(String, "%d", g_sub_menu_selection);
//g_setting_contrast = g_sub_menu_selection
ST7565_SetContrast(g_sub_menu_selection);
g_update_display = true;
break;
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
case MENU_AM_FIX: case MENU_AM_FIX:
#endif #endif

View File

@ -65,6 +65,7 @@ enum
#endif #endif
MENU_ABR, MENU_ABR,
MENU_ABR_ON_TX_RX, MENU_ABR_ON_TX_RX,
MENU_CONTRAST,
MENU_BEEP, MENU_BEEP,
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
MENU_VOICE, MENU_VOICE,