0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-27 22:01:26 +03:00
This commit is contained in:
OneOfEleven 2023-11-10 16:45:07 +00:00
parent 2b98faeedf
commit e2e571b4fb
9 changed files with 40 additions and 36 deletions

View File

@ -324,7 +324,7 @@ static void APP_process_rx(void)
if (g_squelch_open || g_monitor_enabled)
{
if (g_eeprom.config.setting.backlight_on_tx_rx >= 2)
BACKLIGHT_turn_on(backlight_tx_rx_time_10ms); // keep the backlight on while we're receiving
BACKLIGHT_turn_on(backlight_tx_rx_time_secs); // keep the backlight on while we're receiving
if (!g_end_of_rx_detected_maybe && IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
{
@ -467,7 +467,7 @@ bool APP_start_listening(void)
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
if (g_eeprom.config.setting.backlight_on_tx_rx >= 2)
BACKLIGHT_turn_on(backlight_tx_rx_time_10ms);
BACKLIGHT_turn_on(backlight_tx_rx_time_secs);
#ifdef ENABLE_MDC1200
// MDC1200_reset_rx();
@ -1282,11 +1282,11 @@ void APP_check_keys(void)
{
if (--g_ptt_debounce <= 0)
{ // stop TX'ing
g_ptt_is_pressed = false;
g_ptt_was_released = true;
g_ptt_debounce = 0;
APP_process_key(KEY_PTT, false, false);
}
}
@ -1780,7 +1780,7 @@ void APP_process_functions(void)
case FUNCTION_TRANSMIT:
if (g_eeprom.config.setting.backlight_on_tx_rx == 1 || g_eeprom.config.setting.backlight_on_tx_rx == 3)
BACKLIGHT_turn_on(backlight_tx_rx_time_10ms);
BACKLIGHT_turn_on(backlight_tx_rx_time_secs);
break;
case FUNCTION_NEW_RECEIVE:
@ -2497,11 +2497,10 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
// reset the state so as to remove it from the screen
if (Key != KEY_INVALID && Key != KEY_PTT)
RADIO_set_vfo_state(VFO_STATE_NORMAL);
#if 0
// remember the current backlight state (on / off)
const bool backlight_was_on = g_backlight_on;
if (Key == KEY_EXIT && !backlight_was_on && g_eeprom.config.setting.backlight_time > 0)
#if 1
// remember the current backlight state (on / off)
if (Key == KEY_EXIT && !BACKLIGHT_is_on() && g_eeprom.config.setting.backlight_time > 0)
{ // just turn the back light on for now so the user can see what's what
if (!key_pressed && !key_held)
{ // key has been released

View File

@ -22,13 +22,12 @@
#include "settings.h"
uint16_t g_backlight_tick_10ms;
bool g_backlight_on;
void BACKLIGHT_init(void)
{
// 48MHz / 94 / 1024 ~ 500Hz
const uint32_t PWM_FREQUENCY_HZ = 1000;
PWM_PLUS0_CLKSRC |= ((CPU_CLOCK_HZ / 1024 / PWM_FREQUENCY_HZ) << 16);
PWM_PLUS0_CLKSRC |= (CPU_CLOCK_HZ / 1024 / PWM_FREQUENCY_HZ) << 16;
PWM_PLUS0_PERIOD = 1023;
PORTCON_PORTB_SEL0 &= ~(PORTCON_PORTB_SEL0_B6_MASK);
@ -44,29 +43,36 @@ uint16_t BACKLIGHT_ticks(void)
uint16_t ticks = 0;
switch (g_eeprom.config.setting.backlight_time)
{
case 1: ticks = 5; break; // 5 sec
case 2: ticks = 10; break; // 10 sec
case 3: ticks = 20; break; // 20 sec
case 4: ticks = 60; break; // 1 min
case 5: ticks = 60 * 2; break; // 2 min
case 6: ticks = 60 * 4; break; // 4 min
case 1: ticks = 5; break; // 5 sec
case 2: ticks = 10; break; // 10 sec
case 3: ticks = 20; break; // 20 sec
case 4: ticks = 60; break; // 1 min
case 5: ticks = 120; break; // 2 min
case 6: ticks = 240; break; // 4 min
}
return ticks * 100;
}
void BACKLIGHT_set_brightness(unsigned int brightness)
bool BACKLIGHT_is_on(void)
{
brightness = (brightness > BACKLIGHT_MAX_BRIGHTNESS) ? BACKLIGHT_MAX_BRIGHTNESS : brightness;
// non-linear
PWM_PLUS0_CH0_COMP = (1023ul * brightness * brightness) / (BACKLIGHT_MAX_BRIGHTNESS * BACKLIGHT_MAX_BRIGHTNESS);
//PWM_PLUS0_SWLOAD = 1;
g_backlight_on = (brightness > 0) ? true : false;
return (PWM_PLUS0_CH0_COMP > 0) ? true : false;
}
void BACKLIGHT_turn_on(const uint16_t min_ticks)
void BACKLIGHT_set_brightness(unsigned int brightness)
{
if (brightness > BACKLIGHT_MAX_BRIGHTNESS)
brightness = BACKLIGHT_MAX_BRIGHTNESS;
// non-linear 0 ~ 1023
PWM_PLUS0_CH0_COMP = (1023ul * brightness * brightness * brightness) / (BACKLIGHT_MAX_BRIGHTNESS * BACKLIGHT_MAX_BRIGHTNESS * BACKLIGHT_MAX_BRIGHTNESS);
//PWM_PLUS0_SWLOAD = 1;
// g_backlight_on = (brightness > 0) ? true : false;
}
void BACKLIGHT_turn_on(const unsigned int min_secs)
{
const uint16_t min_ticks = min_secs * 100;
if (min_ticks > 0)
{
if (g_backlight_tick_10ms < min_ticks)

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef DRIVER_BACKLIGHT_H
#define DRIVER_BACKLIGHT_H
#ifndef BACKLIGHT_H
#define BACKLIGHT_H
#include <stdint.h>
#include <stdbool.h>
@ -23,13 +23,12 @@
#define BACKLIGHT_MAX_BRIGHTNESS 100
extern uint16_t g_backlight_tick_10ms;
extern bool g_backlight_on;
void BACKLIGHT_init(void);
uint16_t BACKLIGHT_ticks(void);
bool BACKLIGHT_is_on(void);
void BACKLIGHT_set_brightness(unsigned int brightness);
void BACKLIGHT_turn_on(const uint16_t min_ticks);
void BACKLIGHT_turn_on(const unsigned int min_secs);
void BACKLIGHT_turn_off(void);
#endif

Binary file not shown.

Binary file not shown.

View File

@ -196,7 +196,7 @@ void FUNCTION_Select(function_type_t Function)
}
if (g_eeprom.config.setting.backlight_on_tx_rx == 1 || g_eeprom.config.setting.backlight_on_tx_rx == 3)
BACKLIGHT_turn_on(backlight_tx_rx_time_10ms);
BACKLIGHT_turn_on(backlight_tx_rx_time_secs);
if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
{ // dual-RX is enabled

2
misc.c
View File

@ -31,7 +31,7 @@ const uint16_t fm_play_noscan_10ms = 1200 / 10; // 1.2 s
const uint8_t menu_timeout_500ms = 30000 / 500; // 30 seconds
const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes
const uint16_t backlight_tx_rx_time_10ms = 10000 / 10; // 10 seconds
const uint16_t backlight_tx_rx_time_secs = 10; // 10 seconds
const uint8_t dtmf_rx_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen
const uint8_t dtmf_rx_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver

2
misc.h
View File

@ -126,7 +126,7 @@ extern const uint16_t fm_play_noscan_10ms;
extern const uint8_t menu_timeout_500ms;
extern const uint16_t menu_timeout_long_500ms;
extern const uint16_t backlight_tx_rx_time_10ms;
extern const uint16_t backlight_tx_rx_time_secs;
extern const uint8_t dtmf_rx_live_timeout_500ms;
extern const uint8_t dtmf_rx_timeout_500ms;

View File

@ -419,7 +419,7 @@ void UI_DisplayMain(void)
if (g_serial_config_tick_500ms > 0)
{
BACKLIGHT_turn_on(100 * 5); // 5 seconds
BACKLIGHT_turn_on(5); // 5 seconds
UI_PrintString("UART", 0, LCD_WIDTH, 1, 8);
UI_PrintString("CONFIG COMMS", 0, LCD_WIDTH, 3, 8);
ST7565_BlitFullScreen();
@ -430,7 +430,7 @@ void UI_DisplayMain(void)
#ifdef ENABLE_KEYLOCK
if (g_eeprom.config.setting.key_lock && g_keypad_locked > 0)
{ // tell user how to unlock the keyboard
BACKLIGHT_turn_on(100 * 5); // 5 seconds
BACKLIGHT_turn_on(5); // 5 seconds
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8);
ST7565_BlitFullScreen();