kopia lustrzana https://github.com/OpenRTX/OpenRTX
Modified range for display backlight level from 0 - 255 to 0 - 100, set minimum allowed level to 5.
rodzic
9297c08b05
commit
a5209d6f52
|
@ -142,7 +142,7 @@ void platform_beepStop();
|
|||
|
||||
/**
|
||||
* This function sets the screen backlight to the specified level.
|
||||
* @param level: backlight level, from 0 (backlight off) to 255 (backlight at
|
||||
* @param level: backlight level, from 0 (backlight off) to 100 (backlight at
|
||||
* full brightness).
|
||||
*/
|
||||
void platform_setBacklightLevel(uint8_t level);
|
||||
|
|
|
@ -61,7 +61,7 @@ __attribute__((packed)) settings_t;
|
|||
|
||||
static const settings_t default_settings =
|
||||
{
|
||||
255, // Brightness
|
||||
100, // Brightness
|
||||
#ifdef SCREEN_CONTRAST
|
||||
DEFAULT_CONTRAST, // Contrast
|
||||
#else
|
||||
|
|
|
@ -133,7 +133,6 @@ void state_init();
|
|||
/**
|
||||
* Write default values to OpenRTX settings and VFO Channel configuration
|
||||
* Writes out to flash and calls state_init again to reload it immediately
|
||||
*
|
||||
*/
|
||||
void defaultSettingsAndVfo();
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ state_t state;
|
|||
|
||||
void defaultSettingsAndVfo()
|
||||
{
|
||||
|
||||
|
||||
//don't need to lock state mutex because this is called from a section
|
||||
//that already does that - ui_updatefsm runs in a critical section in
|
||||
//the ui thread
|
||||
|
@ -77,6 +77,9 @@ void state_init()
|
|||
state.zone_enabled = false;
|
||||
state.rtxStatus = RTX_OFF;
|
||||
state.emergency = false;
|
||||
|
||||
// Force brightness field to be in range 0 - 100
|
||||
if(state.settings.brightness > 100) state.settings.brightness = 100;
|
||||
}
|
||||
|
||||
void state_terminate()
|
||||
|
@ -86,7 +89,7 @@ void state_terminate()
|
|||
*/
|
||||
if(state.settings.brightness == 0)
|
||||
{
|
||||
state.settings.brightness = 25;
|
||||
state.settings.brightness = 5;
|
||||
}
|
||||
|
||||
nvm_writeSettingsAndVfo(&state.settings, &state.channel);
|
||||
|
|
|
@ -553,7 +553,8 @@ int _ui_fsm_loadChannel(uint16_t zone_index, bool *sync_rtx) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void _ui_fsm_confirmVFOInput(bool *sync_rtx) {
|
||||
void _ui_fsm_confirmVFOInput(bool *sync_rtx)
|
||||
{
|
||||
// Switch to TX input
|
||||
if(ui_state.input_set == SET_RX)
|
||||
{
|
||||
|
@ -581,7 +582,8 @@ void _ui_fsm_confirmVFOInput(bool *sync_rtx) {
|
|||
}
|
||||
}
|
||||
|
||||
void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx) {
|
||||
void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx)
|
||||
{
|
||||
// Advance input position
|
||||
ui_state.input_position += 1;
|
||||
// Save pressed number to calculate frequency and show in GUI
|
||||
|
@ -627,12 +629,13 @@ void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx) {
|
|||
|
||||
void _ui_changeBrightness(int variation)
|
||||
{
|
||||
if(variation >= 0)
|
||||
state.settings.brightness =
|
||||
(255 - state.settings.brightness < variation) ? 255 : state.settings.brightness + variation;
|
||||
else
|
||||
state.settings.brightness =
|
||||
(state.settings.brightness < -variation) ? 0 : state.settings.brightness + variation;
|
||||
state.settings.brightness += variation;
|
||||
|
||||
// Max value for brightness is 100, min value is set to 5 to avoid complete
|
||||
// display shutdown.
|
||||
if(state.settings.brightness > 100) state.settings.brightness = 100;
|
||||
if(state.settings.brightness < 5) state.settings.brightness = 5;
|
||||
|
||||
platform_setBacklightLevel(state.settings.brightness);
|
||||
}
|
||||
|
||||
|
@ -718,7 +721,8 @@ bool _ui_exitStandby(long long now)
|
|||
return true;
|
||||
}
|
||||
|
||||
void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) {
|
||||
void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
|
||||
{
|
||||
ui_state.input_number = input_getPressedNumber(msg);
|
||||
// CTCSS Encode/Decode Selection
|
||||
bool tone_tx_enable = state.channel.fm.txToneEn;
|
||||
|
@ -773,10 +777,10 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) {
|
|||
*sync_rtx = true;
|
||||
break;
|
||||
case 7:
|
||||
_ui_changeBrightness(+25);
|
||||
_ui_changeBrightness(+5);
|
||||
break;
|
||||
case 8:
|
||||
_ui_changeBrightness(-25);
|
||||
_ui_changeBrightness(-5);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -867,7 +871,7 @@ void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg, bool callsig
|
|||
num_symbols = strlen(symbols_ITU_T_E161_callsign[num_key]);
|
||||
else
|
||||
num_symbols = strlen(symbols_ITU_T_E161[num_key]);
|
||||
|
||||
|
||||
// Skip keypad logic for first keypress
|
||||
if(ui_state.last_keypress != 0)
|
||||
{
|
||||
|
@ -1459,7 +1463,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
|||
switch(ui_state.menu_selected)
|
||||
{
|
||||
case D_BRIGHTNESS:
|
||||
_ui_changeBrightness(-25);
|
||||
_ui_changeBrightness(-5);
|
||||
break;
|
||||
#ifdef SCREEN_CONTRAST
|
||||
case D_CONTRAST:
|
||||
|
@ -1479,7 +1483,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
|||
switch(ui_state.menu_selected)
|
||||
{
|
||||
case D_BRIGHTNESS:
|
||||
_ui_changeBrightness(+25);
|
||||
_ui_changeBrightness(+5);
|
||||
break;
|
||||
#ifdef SCREEN_CONTRAST
|
||||
case D_CONTRAST:
|
||||
|
@ -1564,7 +1568,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
|||
else if(msg.keys & KEY_ESC)
|
||||
// Discard selected callsign and disable input mode
|
||||
ui_state.edit_mode = false;
|
||||
else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN ||
|
||||
else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN ||
|
||||
msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT)
|
||||
_ui_textInputDel(ui_state.new_callsign);
|
||||
else if(input_isNumberPressed(msg))
|
||||
|
|
|
@ -541,7 +541,7 @@ void _ui_drawSettingsM17(ui_state_t* ui_state)
|
|||
{
|
||||
gfx_clearScreen();
|
||||
// Print "M17 Settings" on top bar
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "M17 Settings");
|
||||
gfx_printLine(1, 4, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
|
||||
layout.horizontal_pad, layout.menu_font,
|
||||
|
@ -550,7 +550,7 @@ void _ui_drawSettingsM17(ui_state_t* ui_state)
|
|||
{
|
||||
uint16_t rect_width = SCREEN_WIDTH - (layout.horizontal_pad * 2);
|
||||
uint16_t rect_height = (SCREEN_HEIGHT - (layout.top_h + layout.bottom_h))/2;
|
||||
point_t rect_origin = {(SCREEN_WIDTH - rect_width) / 2,
|
||||
point_t rect_origin = {(SCREEN_WIDTH - rect_width) / 2,
|
||||
(SCREEN_HEIGHT - rect_height) / 2};
|
||||
gfx_drawRect(rect_origin, rect_width, rect_height, color_white, false);
|
||||
// Print M17 callsign being typed
|
||||
|
@ -558,7 +558,7 @@ void _ui_drawSettingsM17(ui_state_t* ui_state)
|
|||
layout.horizontal_pad, layout.input_font,
|
||||
TEXT_ALIGN_CENTER, color_white, ui_state->new_callsign);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// Print M17 current callsign
|
||||
gfx_printLine(1, 1, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
|
||||
|
@ -566,11 +566,14 @@ void _ui_drawSettingsM17(ui_state_t* ui_state)
|
|||
TEXT_ALIGN_CENTER, color_white, last_state.settings.callsign);
|
||||
}
|
||||
}
|
||||
|
||||
void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state)
|
||||
{
|
||||
(void) ui_state;
|
||||
|
||||
static int drawcnt = 0;
|
||||
gfx_clearScreen();
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "Reset to Defaults");
|
||||
|
||||
//text will flash yellow and white based on update rate of screen
|
||||
|
@ -580,11 +583,12 @@ void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state)
|
|||
TEXT_ALIGN_CENTER, textcolor, "To reset:");
|
||||
gfx_printLine(2, 4, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
|
||||
layout.horizontal_pad, layout.top_font,
|
||||
TEXT_ALIGN_CENTER, textcolor, "Press Enter 2x");
|
||||
TEXT_ALIGN_CENTER, textcolor, "Press Enter twice");
|
||||
drawcnt++;
|
||||
}
|
||||
|
||||
bool _ui_drawMacroMenu() {
|
||||
bool _ui_drawMacroMenu()
|
||||
{
|
||||
// Header
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "Macro Menu");
|
||||
|
@ -694,7 +698,7 @@ bool _ui_drawMacroMenu() {
|
|||
yellow_fab413, "9 ");
|
||||
gfx_print(layout.line3_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||
color_white, "Sav");
|
||||
|
||||
|
||||
// Draw S-meter bar
|
||||
_ui_drawMainBottom();
|
||||
return true;
|
||||
|
|
|
@ -53,5 +53,8 @@ void backlight_terminate()
|
|||
*/
|
||||
void platform_setBacklightLevel(uint8_t level)
|
||||
{
|
||||
FTM0->CONTROLS[3].CnV = level;
|
||||
if(level > 100) level = 100;
|
||||
|
||||
// Convert value to 0 - 255
|
||||
FTM0->CONTROLS[3].CnV = (2 * level) + (level * 55)/100;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,10 @@ void backlight_terminate()
|
|||
*/
|
||||
void platform_setBacklightLevel(uint8_t level)
|
||||
{
|
||||
TIM8->CCR1 = level;
|
||||
if(level > 100) level = 100;
|
||||
|
||||
// Convert value to 0 - 255
|
||||
TIM8->CCR1 = (2 * level) + (level * 55)/100;
|
||||
}
|
||||
|
||||
#elif defined(ENABLE_BKLIGHT_DIMMING) /* MD-UV3x0 AND dimming enabled */
|
||||
|
@ -155,7 +158,9 @@ void platform_setBacklightLevel(uint8_t level)
|
|||
*/
|
||||
if(level > 1)
|
||||
{
|
||||
TIM11->CCR1 = level;
|
||||
if(level > 100) level = 100;
|
||||
|
||||
TIM11->CCR1 = (2 * level) + (level * 55)/100;
|
||||
TIM11->CR1 |= TIM_CR1_CEN;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -57,12 +57,16 @@ void platform_terminate()
|
|||
|
||||
void platform_setBacklightLevel(uint8_t level)
|
||||
{
|
||||
// Saturate level to 100 and convert value to 0 - 255
|
||||
if(level > 100) level = 100;
|
||||
uint16_t value = (2 * level) + (level * 55)/100;
|
||||
|
||||
SDL_Event e;
|
||||
SDL_zero(e);
|
||||
e.type = SDL_Backlight_Event;
|
||||
e.user.data1 = malloc(sizeof(uint8_t));
|
||||
uint8_t *data = (uint8_t *)e.user.data1;
|
||||
*data = level;
|
||||
*data = ((uint8_t) value);
|
||||
|
||||
SDL_PushEvent(&e);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue