Made Brightness setting optional based on HW capabilities

pull/166/merge
k5jae 2023-08-07 13:36:22 -05:00 zatwierdzone przez Silvano Seva
rodzic 4a6d0b4c2b
commit c1a9db22b7
13 zmienionych plików z 45 dodań i 18 usunięć

Wyświetl plik

@ -169,7 +169,6 @@ mdx_src = ['openrtx/src/core/xmodem.c',
'platform/drivers/audio/inputStream_MDx.cpp',
'platform/drivers/audio/outputStream_MDx.cpp',
'platform/drivers/baseband/HR_Cx000.cpp',
'platform/drivers/backlight/backlight_MDx.c',
'platform/drivers/tones/toneGenerator_MDx.cpp']
mdx_src = mdx_src + openrtx_ui_default
@ -321,6 +320,7 @@ md3x0_src = src + mdx_src + stm32f405_src + ['platform/drivers/NVM/nvmem_MD3x0.c
'platform/drivers/baseband/HR_C5000_MDx.cpp',
'platform/drivers/keyboard/keyboard_MD3x.c',
'platform/drivers/display/HX8353_MD3x.cpp',
'platform/drivers/backlight/backlight_MDx.c',
'platform/targets/MD-3x0/platform.c']
md3x0_inc = inc + stm32f405_inc + ['platform/targets/MD-3x0']
@ -335,6 +335,7 @@ mduv3x0_src = src + mdx_src + stm32f405_src + ['platform/drivers/NVM/nvmem_MDUV3
'platform/targets/MD-UV3x0/platform.c',
'platform/drivers/keyboard/keyboard_MD3x.c',
'platform/drivers/display/HX8353_MD3x.cpp',
'platform/drivers/backlight/backlight_MDx.c',
'platform/drivers/chSelector/chSelector_UV3x0.c',
'platform/drivers/baseband/radio_UV3x0.cpp',
'platform/drivers/baseband/AT1846S_UV3x0.cpp',

Wyświetl plik

@ -109,7 +109,9 @@ enum backupRestoreItems
enum displayItems
{
#ifdef SCREEN_BRIGHTNESS
D_BRIGHTNESS = 0,
#endif
#ifdef SCREEN_CONTRAST
D_CONTRAST,
#endif

Wyświetl plik

@ -73,14 +73,15 @@ void state_init()
state.emergency = false;
// Force brightness field to be in range 0 - 100
if(state.settings.brightness > 100) state.settings.brightness = 100;
if(state.settings.brightness > 100)
{
state.settings.brightness = 100;
}
}
void state_terminate()
{
/*
* Never store a brightness of 0 to avoid booting with a black screen
*/
// Never store a brightness of 0 to avoid booting with a black screen
if(state.settings.brightness == 0)
{
state.settings.brightness = 5;

Wyświetl plik

@ -147,7 +147,9 @@ const char *settings_items[] =
const char *display_items[] =
{
#ifdef SCREEN_BRIGHTNESS
"Brightness",
#endif
#ifdef SCREEN_CONTRAST
"Contrast",
#endif
@ -715,6 +717,7 @@ static void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx)
vp_play();
}
#ifdef SCREEN_BRIGHTNESS
static void _ui_changeBrightness(int variation)
{
state.settings.brightness += variation;
@ -726,6 +729,7 @@ static void _ui_changeBrightness(int variation)
display_setBacklightLevel(state.settings.brightness);
}
#endif
#ifdef SCREEN_CONTRAST
static void _ui_changeContrast(int variation)
@ -848,6 +852,7 @@ static bool _ui_exitStandby(long long now)
standby = false;
redraw_needed = true;
display_setBacklightLevel(state.settings.brightness);
return true;
}
@ -948,7 +953,7 @@ static void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
float power = dBmToWatt(state.channel.power);
vp_anouncePower(power, queueFlags);
break;
break;
#ifdef SCREEN_BRIGHTNESS
case 7:
_ui_changeBrightness(-5);
vp_announceSettingsInt(&currentLanguage->brightness, queueFlags,
@ -959,6 +964,7 @@ static void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
vp_announceSettingsInt(&currentLanguage->brightness, queueFlags,
state.settings.brightness);
break;
#endif
}
#ifdef HAS_ABSOLUTE_KNOB // If the radio has an absolute position knob
@ -1837,11 +1843,13 @@ void ui_updateFSM(bool *sync_rtx)
{
switch(ui_state.menu_selected)
{
#ifdef SCREEN_BRIGHTNESS
case D_BRIGHTNESS:
_ui_changeBrightness(-5);
vp_announceSettingsInt(&currentLanguage->brightness, queueFlags,
state.settings.brightness);
break;
#endif
#ifdef SCREEN_CONTRAST
case D_CONTRAST:
_ui_changeContrast(-4);
@ -1862,11 +1870,13 @@ void ui_updateFSM(bool *sync_rtx)
{
switch(ui_state.menu_selected)
{
#ifdef SCREEN_BRIGHTNESS
case D_BRIGHTNESS:
_ui_changeBrightness(+5);
vp_announceSettingsInt(&currentLanguage->brightness, queueFlags,
state.settings.brightness);
break;
#endif
#ifdef SCREEN_CONTRAST
case D_CONTRAST:
_ui_changeContrast(+4);

Wyświetl plik

@ -265,9 +265,11 @@ int _ui_getDisplayValueName(char *buf, uint8_t max_len, uint8_t index)
uint8_t value = 0;
switch(index)
{
#ifdef SCREEN_BRIGHTNESS
case D_BRIGHTNESS:
value = last_state.settings.brightness;
break;
#endif
#ifdef SCREEN_CONTRAST
case D_CONTRAST:
value = last_state.settings.contrast;
@ -977,15 +979,19 @@ bool _ui_drawMacroMenu()
// Third row
gfx_print(layout.line3_pos, layout.top_font, TEXT_ALIGN_LEFT,
yellow_fab413, "7");
#ifdef SCREEN_BRIGHTNESS
gfx_print(layout.line3_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, " B-");
gfx_print(layout.line3_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, " %5d",
state.settings.brightness);
#endif
gfx_print(layout.line3_pos, layout.top_font, TEXT_ALIGN_CENTER,
yellow_fab413, "8");
#ifdef SCREEN_BRIGHTNESS
gfx_print(layout.line3_pos, layout.top_font, TEXT_ALIGN_CENTER,
color_white, " B+");
#endif
gfx_print(layout.line3_pos, layout.top_font, TEXT_ALIGN_RIGHT,
yellow_fab413, "9 ");
gfx_print(layout.line3_pos, layout.top_font, TEXT_ALIGN_RIGHT,

Wyświetl plik

@ -23,7 +23,7 @@
#include <hwconfig.h>
#include "backlight.h"
#if defined(PLATFORM_MDUV3x0) && defined(ENABLE_BKLIGHT_DIMMING)
#if defined(PLATFORM_MDUV3x0) && defined(SCREEN_BRIGHTNESS)
/*
* Interrupt-based software PWM for backlight dimming on MD-UV3x0.
@ -83,7 +83,7 @@ void backlight_init()
gpio_setMode(LCD_BKLIGHT, OUTPUT);
gpio_clearPin(LCD_BKLIGHT);
#ifdef ENABLE_BKLIGHT_DIMMING
#ifdef SCREEN_BRIGHTNESS
/*
* Configure TIM11 for backlight PWM: Fpwm = 256Hz, 8 bit of resolution.
* APB2 freq. is 84MHz but timer runs at twice this frequency, then:
@ -146,7 +146,7 @@ void display_setBacklightLevel(uint8_t level)
*/
if(pwmLevel > 1)
{
#ifdef ENABLE_BKLIGHT_DIMMING
#ifdef SCREEN_BRIGHTNESS
TIM11->CCR1 = pwmLevel;
TIM11->CR1 |= TIM_CR1_CEN;
#else

Wyświetl plik

@ -38,6 +38,9 @@ extern "C" {
#define SCREEN_CONTRAST
#define DEFAULT_CONTRAST 71
/* Screen has adjustable brightness */
#define SCREEN_BRIGHTNESS
/* Battery type */
#define BAT_LIPO_2S

Wyświetl plik

@ -38,6 +38,9 @@ extern "C" {
#define SCREEN_CONTRAST
#define DEFAULT_CONTRAST 71
/* Screen has adjustable brightness */
#define SCREEN_BRIGHTNESS
/* Battery type */
#define BAT_LIPO_2S

Wyświetl plik

@ -42,6 +42,9 @@ extern "C" {
/* Screen pixel format */
#define PIX_FMT_RGB565
/* Screen has adjustable brightness */
#define SCREEN_BRIGHTNESS
/* Battery type */
#define BAT_LIPO_2S

Wyświetl plik

@ -24,7 +24,6 @@
#include <interfaces/delays.h>
#include <hwconfig.h>
#include <string.h>
#include <backlight.h>
#include <ADC1_MDx.h>
#include <calibInfo_MDx.h>
#include <toneGenerator_MDx.h>
@ -34,7 +33,7 @@
#include <chSelector.h>
/* TODO: Hardcoded hwInfo until we implement reading from flash */
static const hwInfo_t hwInfo
static const hwInfo_t hwInfo =
{
.vhf_maxFreq = 174,
.vhf_minFreq = 136,
@ -44,7 +43,7 @@ static const hwInfo_t hwInfo
.uhf_band = 1,
.hw_version = 0,
.name = "MD-9600"
}
};
void platform_init()
{
@ -76,16 +75,12 @@ void platform_init()
nvm_init(); /* Initialise non volatile memory manager */
toneGen_init(); /* Initialise tone generator */
rtc_init(); /* Initialise RTC */
backlight_init(); /* Initialise backlight driver */
chSelector_init(); /* Initialise channel selector handler */
audio_init(); /* Initialise audio management module */
}
void platform_terminate()
{
/* Shut down backlight */
backlight_terminate();
/* Shut down all the modules */
adc1_terminate();
toneGen_terminate();

Wyświetl plik

@ -151,7 +151,7 @@ extern "C" {
* pin and its frequency has to be low (~250Hz) to not put too much overehad on
* the processor due to timer ISR triggering at an high rate.
*
* #define ENABLE_BKLIGHT_DIMMING
* #define SCREEN_BRIGHTNESS
*/
#ifdef __cplusplus

Wyświetl plik

@ -29,7 +29,7 @@
#include <interfaces/audio.h>
#include <chSelector.h>
#ifdef ENABLE_BKLIGHT_DIMMING
#ifdef SCREEN_BRIGHTNESS
#include <backlight.h>
#endif

Wyświetl plik

@ -28,6 +28,9 @@ extern "C" {
/* Device supports an optional GPS chip */
#define GPS_PRESENT
/* Screen has adjustable brightness */
#define SCREEN_BRIGHTNESS
/* Battery type */
#define BAT_LIPO_2S