diff --git a/Makefile b/Makefile index 84690bb..0cb8200 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ ENABLE_OVERLAY := 0 ENABLE_LTO := 1 ENABLE_UART := 1 ENABLE_UART_DEBUG := 1 -ENABLE_AIRCOPY := 1 +ENABLE_AIRCOPY := 0 ENABLE_FMRADIO := 1 ENABLE_NOAA := 1 ENABLE_VOICE := 0 diff --git a/app/action.c b/app/action.c index 688897f..a5c3717 100644 --- a/app/action.c +++ b/app/action.c @@ -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 { diff --git a/app/app.c b/app/app.c index 7f7dae3..ca745fc 100644 --- a/app/app.c +++ b/app/app.c @@ -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(); diff --git a/app/menu.c b/app/menu.c index 217881e..954e644 100644 --- a/app/menu.c +++ b/app/menu.c @@ -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; diff --git a/app/uart.c b/app/uart.c index c5d19f9..e46e0a6 100644 --- a/app/uart.c +++ b/app/uart.c @@ -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; diff --git a/board.c b/board.c index edb380a..2fc60a8 100644 --- a/board.c +++ b/board.c @@ -540,6 +540,7 @@ void BOARD_EEPROM_Init(void) // 0E78..0E7F 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.cross_vfo_rx_tx = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; g_eeprom.battery_save = (Data[3] < 5) ? Data[3] : 4; diff --git a/driver/st7565.c b/driver/st7565.c index ca93c1a..96faf7a 100644 --- a/driver/st7565.c +++ b/driver/st7565.c @@ -27,6 +27,7 @@ uint8_t g_status_line[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) { @@ -64,6 +65,10 @@ void ST7565_BlitFullScreen(void) { 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); ST7565_WriteByte(0x40); @@ -82,7 +87,7 @@ void ST7565_BlitFullScreen(void) } #if 0 - // whats the delay for I wonder, it holds things up :( + // whats the delay for, it holds things up :( SYSTEM_DelayMs(20); #else // SYSTEM_DelayMs(1); @@ -115,13 +120,14 @@ void ST7565_BlitStatusLine(void) SPI_ToggleMasterMode(&SPI0->CR, true); } -void ST7565_FillScreen(uint8_t Value) +void ST7565_FillScreen(const uint8_t Value) { 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); - + SPI_ToggleMasterMode(&SPI0->CR, false); for (i = 0; i < 8; i++) @@ -145,52 +151,52 @@ void ST7565_Init(const bool full) if (full) { SPI0_Init(); - + ST7565_HardwareReset(); - + SPI_ToggleMasterMode(&SPI0->CR, false); - + ST7565_WriteByte(0xE2); // internal reset - + SYSTEM_DelayMs(120); } else SPI_ToggleMasterMode(&SPI0->CR, false); - + ST7565_WriteByte(0xA2); // bias 9 ST7565_WriteByte(0xC0); // com normal ST7565_WriteByte(0xA1); // reverse ? - + ST7565_WriteByte(0xA6); // normal screen ? // ST7565_WriteByte(0xA7); // inverse screen ? ST7565_WriteByte(0xA4); // all points normal ST7565_WriteByte(0x24); // - ST7565_WriteByte(0x81); // volume first ? - ST7565_WriteByte(0x1f); // contrast ? + ST7565_WriteByte(0x81); // + ST7565_WriteByte(contrast); // contrast ? 0 ~ 63 if (full) { ST7565_WriteByte(0x2B); // power control ? - + SYSTEM_DelayMs(1); - + ST7565_WriteByte(0x2E); // power control ? - + SYSTEM_DelayMs(1); - + ST7565_WriteByte(0x2F); // ST7565_WriteByte(0x2F); // ST7565_WriteByte(0x2F); // ST7565_WriteByte(0x2F); // - + SYSTEM_DelayMs(40); } - + ST7565_WriteByte(0x40); // start line ? ST7565_WriteByte(0xAF); // display on ? - + SPI_WaitForUndocumentedTxFifoStatusBit(); SPI_ToggleMasterMode(&SPI0->CR, true); @@ -209,7 +215,7 @@ void ST7565_HardwareReset(void) 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); 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(); } -void ST7565_WriteByte(uint8_t Value) +void ST7565_WriteByte(const uint8_t Value) { GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0); while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {} SPI0->WDR = Value; } + +void ST7565_SetContrast(const uint8_t value) +{ + contrast = (value <= 63) ? value : 63; +} + +uint8_t ST7565_GetContrast(void) +{ + return contrast; +} diff --git a/driver/st7565.h b/driver/st7565.h index eddb134..54dd150 100644 --- a/driver/st7565.h +++ b/driver/st7565.h @@ -26,14 +26,16 @@ extern uint8_t g_status_line[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_BlitFullScreen(void); -void ST7565_BlitStatusLine(void); -void ST7565_FillScreen(uint8_t Value); -void ST7565_Init(const bool full); -void ST7565_HardwareReset(void); -void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line); -void ST7565_WriteByte(uint8_t Value); +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_BlitStatusLine(void); +void ST7565_FillScreen(const uint8_t Value); +void ST7565_Init(const bool full); +void ST7565_HardwareReset(void); +void ST7565_SelectColumnAndLine(const uint8_t Column, const uint8_t Line); +void ST7565_WriteByte(const uint8_t Value); +void ST7565_SetContrast(const uint8_t value); +uint8_t ST7565_GetContrast(void); #endif diff --git a/firmware.bin b/firmware.bin index cb0a07f..498f3bc 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index d7558a8..ae73167 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 7f5e71f..45bc802 100644 --- a/functions.c +++ b/functions.c @@ -29,6 +29,7 @@ #include "driver/bk4819.h" #include "driver/gpio.h" #include "driver/system.h" +#include "driver/uart.h" #include "frequencies.h" #include "functions.h" #include "helper/battery.h" @@ -84,31 +85,36 @@ void FUNCTION_Init(void) void FUNCTION_Select(function_type_t Function) { - const function_type_t PreviousFunction = g_current_function; - const bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE); + const function_type_t prev_func = g_current_function; + const bool was_power_save = (prev_func == FUNCTION_POWER_SAVE); 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(); g_rx_idle_mode = false; + UI_DisplayStatus(false); } switch (Function) { 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) RADIO_PrepareCssTX(); - if (PreviousFunction == FUNCTION_TRANSMIT) + if (prev_func == FUNCTION_TRANSMIT) { g_vfo_rssi_bar_level[0] = 0; g_vfo_rssi_bar_level[1] = 0; } else - if (PreviousFunction != FUNCTION_RECEIVE) + if (prev_func != FUNCTION_RECEIVE) break; #if defined(ENABLE_FMRADIO) @@ -127,16 +133,32 @@ void FUNCTION_Select(function_type_t Function) return; case FUNCTION_MONITOR: + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_SendText("func monitor\r\n"); + #endif + g_monitor_enabled = true; break; case FUNCTION_INCOMING: + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_SendText("func incoming\r\n"); + #endif + break; + case FUNCTION_RECEIVE: + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_SendText("func receive\r\n"); + #endif break; case FUNCTION_POWER_SAVE: - g_power_save_10ms = g_eeprom.battery_save * 10; - g_power_save_count_down_expired = false; + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + 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; @@ -155,6 +177,9 @@ void FUNCTION_Select(function_type_t Function) return; 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 BK4819_DisableDTMF(); @@ -247,7 +272,7 @@ void FUNCTION_Select(function_type_t Function) } g_battery_save_count_down_10ms = battery_save_count_10ms; - g_schedule_power_save = false; + g_schedule_power_save = false; #if defined(ENABLE_FMRADIO) g_fm_restore_count_down_10ms = 0; diff --git a/main.c b/main.c index ac72919..ddaf7ab 100644 --- a/main.c +++ b/main.c @@ -29,6 +29,7 @@ #include "driver/backlight.h" #include "driver/bk4819.h" #include "driver/gpio.h" +#include "driver/st7565.h" #include "driver/system.h" #include "driver/systick.h" #include "driver/uart.h" @@ -116,6 +117,8 @@ void Main(void) // sort the menu list UI_SortMenu(!g_f_lock); + ST7565_SetContrast(g_setting_contrast); + // wait for user to release all butts before moving on if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || KEYBOARD_Poll() != KEY_INVALID || diff --git a/misc.c b/misc.c index 3b8fa8b..f270e05 100644 --- a/misc.c +++ b/misc.c @@ -107,6 +107,8 @@ uint8_t g_setting_backlight_on_tx_rx; bool g_setting_live_dtmf_decoder; uint8_t g_setting_battery_text; +uint8_t g_setting_contrast; + uint8_t g_setting_side1_short; uint8_t g_setting_side1_long; 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 bool g_power_save_count_down_expired; +volatile bool g_power_save_expired; volatile bool g_schedule_power_save; volatile bool g_schedule_dual_watch = true; diff --git a/misc.h b/misc.h index 0be14b4..09881ed 100644 --- a/misc.h +++ b/misc.h @@ -183,6 +183,8 @@ extern uint8_t g_setting_backlight_on_tx_rx; extern bool g_setting_live_dtmf_decoder; 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_long; 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 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_dual_watch; diff --git a/scheduler.c b/scheduler.c index 2ff29e8..1080777 100644 --- a/scheduler.c +++ b/scheduler.c @@ -76,7 +76,7 @@ void SystickHandler(void) DECREMENT_AND_TRIGGER(g_battery_save_count_down_10ms, g_schedule_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_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE) diff --git a/settings.c b/settings.c index b0d8ecb..079334c 100644 --- a/settings.c +++ b/settings.c @@ -96,7 +96,8 @@ void SETTINGS_SaveSettings(void) State[7] = g_eeprom.mic_sensitivity; EEPROM_WriteBuffer(0x0E70, State); - State[0] = 0xFF; + //State[0] = 0xFF; + State[0] = g_setting_contrast; State[1] = g_eeprom.channel_display_mode; State[2] = g_eeprom.cross_vfo_rx_tx; State[3] = g_eeprom.battery_save; diff --git a/ui/main.h b/ui/main.h index b3e756f..494aef4 100644 --- a/ui/main.h +++ b/ui/main.h @@ -37,9 +37,7 @@ extern center_line_t center_line; #ifdef ENABLE_AUDIO_BAR void UI_DisplayAudioBar(void); #endif -#ifdef ENABLE_RSSI_BAR - void UI_UpdateRSSI(const int16_t rssi, const int vfo); -#endif +void UI_UpdateRSSI(const int16_t rssi, const int vfo); void UI_DisplayMain(void); #endif diff --git a/ui/menu.c b/ui/menu.c index 9ca3b03..c6a77b1 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -70,6 +70,7 @@ const t_menu_item g_menu_list[] = #endif {"Bak LT", VOICE_ID_INVALID, MENU_ABR }, // was "ABR" {"BLTTRX", VOICE_ID_INVALID, MENU_ABR_ON_TX_RX }, + {"CTRAST", VOICE_ID_INVALID, MENU_CONTRAST }, {"BEEP", VOICE_ID_BEEP_PROMPT, MENU_BEEP }, #ifdef ENABLE_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]); 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 case MENU_AM_FIX: #endif diff --git a/ui/menu.h b/ui/menu.h index 16151dd..f76355c 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -65,6 +65,7 @@ enum #endif MENU_ABR, MENU_ABR_ON_TX_RX, + MENU_CONTRAST, MENU_BEEP, #ifdef ENABLE_VOICE MENU_VOICE,