Brightness adjust from backlight function (#7680)

Adjust brightness from backlight function
This commit is contained in:
DanielGeA
2020-07-31 17:06:11 +02:00
committed by GitHub
parent ac9f510005
commit 035cc6c031
16 changed files with 76 additions and 46 deletions
+10 -3
View File
@@ -340,7 +340,7 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext
#if defined(VARIO)
case FUNC_VARIO:
newActiveFunctions |= (1 << FUNCTION_VARIO);
newActiveFunctions |= (1u << FUNCTION_VARIO);
break;
#endif
@@ -348,15 +348,22 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext
#if defined(SDCARD)
case FUNC_LOGS:
if (CFN_PARAM(cfn)) {
newActiveFunctions |= (1 << FUNCTION_LOGS);
newActiveFunctions |= (1u << FUNCTION_LOGS);
logDelay = CFN_PARAM(cfn);
}
break;
#endif
case FUNC_BACKLIGHT:
newActiveFunctions |= (1 << FUNCTION_BACKLIGHT);
{
getvalue_t raw = getValue(CFN_PARAM(cfn));
#if defined(COLORLCD)
requiredBacklightBright = (1024 - raw) * (BACKLIGHT_LEVEL_MAX - BACKLIGHT_LEVEL_MIN) / 2048;
#else
requiredBacklightBright = (1024 - raw) * 100 / 2048;
#endif
break;
}
case FUNC_SCREENSHOT:
if (!(functionsContext.activeSwitches & switch_mask)) {
+1
View File
@@ -50,6 +50,7 @@ extern uint8_t trimsDisplayMask;
extern uint16_t maxMixerDuration;
extern uint8_t requiredSpeakerVolume;
extern uint8_t requiredBacklightBright;
enum MainRequest {
REQUEST_SCREENSHOT,
@@ -338,6 +338,14 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
}
else if (func == FUNC_BACKLIGHT) {
val_max = MIXSRC_LAST_CH;
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
if (active) {
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
}
#if defined(SDCARD)
else if (func == FUNC_LOGS) {
if (val_displayed) {
@@ -338,14 +338,14 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
lcdDrawMMM(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, attr);
}
}
#if defined(PCBX9E) || defined(PCBX9DP)
else if (func == FUNC_BACKLIGHT) {
drawSlider(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, CFN_PARAM(cfn), 100, attr);
if (active) INCDEC_SET_FLAG(eeFlags | NO_INCDEC_MARKS);
val_min = 0;
val_max = 100;
val_max = MIXSRC_LAST_CH;
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
if (active) {
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
}
#endif
#if defined(GVARS)
else if (func == FUNC_ADJUST_GVAR) {
switch (CFN_GVAR_MODE(cfn)) {
@@ -333,6 +333,14 @@ bool menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
}
else if (func == FUNC_BACKLIGHT) {
val_max = MIXSRC_LAST_CH;
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
if (active) {
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
}
else if (func == FUNC_LOGS) {
if (val_displayed) {
lcdDrawNumber(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT, 0, NULL, "s");
+2
View File
@@ -22,6 +22,8 @@
uint8_t currentSpeakerVolume = 255;
uint8_t requiredSpeakerVolume = 255;
uint8_t currentBacklightBright = 255;
uint8_t requiredBacklightBright = 255;
uint8_t mainRequestFlags = 0;
#if defined(STM32)
+1
View File
@@ -964,6 +964,7 @@ void evalMixes(uint8_t tick10ms)
// must be done before limits because of the applyLimit function: it checks for safety switches which would be not initialized otherwise
if (tick10ms) {
requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
requiredBacklightBright = g_eeGeneral.backlightBright;
if (!g_model.noGlobalFunctions) {
evalFunctions(g_eeGeneral.customFn, globalFunctionsContext);
+1 -1
View File
@@ -57,7 +57,7 @@
#define IS_HAPTIC_FUNC(func) (0)
#endif
#define HAS_ENABLE_PARAM(func) ((func) < FUNC_FIRST_WITHOUT_ENABLE)
#define HAS_ENABLE_PARAM(func) ((func) < FUNC_FIRST_WITHOUT_ENABLE || (func == FUNC_BACKLIGHT))
#define HAS_REPEAT_PARAM(func) (IS_PLAY_FUNC(func) || IS_HAPTIC_FUNC(func))
#define CFN_EMPTY(p) (!(p)->swtch)
+12 -4
View File
@@ -689,12 +689,19 @@ void checkBacklight()
}
}
bool backlightOn = (g_eeGeneral.backlightMode == e_backlight_mode_on || (g_eeGeneral.backlightMode != e_backlight_mode_off && lightOffCounter) || isFunctionActive(FUNCTION_BACKLIGHT));
if (flashCounter) backlightOn = !backlightOn;
if (backlightOn)
bool backlightOn = (g_eeGeneral.backlightMode == e_backlight_mode_on || (g_eeGeneral.backlightMode != e_backlight_mode_off && lightOffCounter));
if (flashCounter) {
backlightOn = !backlightOn;
}
if (backlightOn) {
currentBacklightBright = requiredBacklightBright;
BACKLIGHT_ENABLE();
else
}
else {
BACKLIGHT_DISABLE();
}
}
}
@@ -1951,6 +1958,7 @@ void opentxInit()
#endif
currentSpeakerVolume = requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
currentBacklightBright = requiredBacklightBright = g_eeGeneral.backlightBright;
#if !defined(SOFTWARE_VOLUME)
setScaledVolume(currentSpeakerVolume);
#endif
+1 -1
View File
@@ -487,6 +487,7 @@ void doMixerCalculations();
void scheduleNextMixerCalculation(uint8_t module, uint32_t period_ms);
void checkTrims();
extern uint8_t currentBacklightBright;
void perMain();
void per10ms();
@@ -846,7 +847,6 @@ enum FunctionsActive {
FUNCTION_TRAINER_CHANNELS = FUNCTION_TRAINER_STICK1 + NUM_STICKS,
FUNCTION_INSTANT_TRIM,
FUNCTION_VARIO,
FUNCTION_BACKLIGHT,
#if defined(SDCARD)
FUNCTION_LOGS,
#endif
+1 -1
View File
@@ -552,7 +552,7 @@ void backlightEnable(uint8_t dutyCycle = 0);
#else
#define BACKLIGHT_LEVEL_MIN 46
#endif
#define BACKLIGHT_ENABLE() backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : BACKLIGHT_LEVEL_MAX - g_eeGeneral.backlightBright)
#define BACKLIGHT_ENABLE() backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : BACKLIGHT_LEVEL_MAX - currentBacklightBright)
#define BACKLIGHT_DISABLE() backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && (g_eeGeneral.backlightMode != e_backlight_mode_off)) ? 0 : g_eeGeneral.blOffBright)
#define isBacklightEnabled() true
+1 -1
View File
@@ -269,7 +269,7 @@ extern "C" {
#endif
// Backlight driver
#define backlightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright)
#define backlightEnable() (PWM->PWM_CH_NUM[0].PWM_CDTY = currentBacklightBright)
#define backlightDisable() (PWM->PWM_CH_NUM[0].PWM_CDTY = 100)
#define isBacklightEnabled() (PWM->PWM_CH_NUM[0].PWM_CDTY != 100)
#define BACKLIGHT_ENABLE() backlightEnable()
+2 -2
View File
@@ -665,10 +665,10 @@ uint8_t isBacklightEnabled();
#define backlightEnable(...)
#elif defined(PCBX9E) || defined(PCBX9DP)
void backlightEnable(uint8_t level = 0, uint8_t color = 0);
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
#define BACKLIGHT_ENABLE() backlightEnable(currentBacklightBright, g_eeGeneral.backlightColor)
#else
void backlightEnable(uint8_t level = 0);
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright)
#define BACKLIGHT_ENABLE() backlightEnable(currentBacklightBright)
#endif
#if !defined(SIMU)