1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Backlight control added back in, driver fix (thanks Adela), OFF level configurable

This commit is contained in:
Andre Bernet 2016-03-19 00:16:19 +04:00
parent 29325ad54f
commit 30018b2432
8 changed files with 41 additions and 34 deletions

View file

@ -911,6 +911,7 @@ PACK(struct TrainerData {
uint8_t slidersConfig:2; \
uint32_t switchConfig; \
uint8_t potsConfig; /* two bits per pot */ \
NOBACKUP(uint8_t blOffBright); \
NOBACKUP(char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]); \
NOBACKUP(char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]); \
NOBACKUP(char currModelFilename[LEN_MODEL_FILENAME+1]); \

View file

@ -73,11 +73,12 @@ enum menuGeneralSetupItems {
ITEM_SETUP_INACTIVITY_ALARM,
// ITEM_SETUP_MEMORY_WARNING,
ITEM_SETUP_ALARM_WARNING,
// ITEM_SETUP_BACKLIGHT_LABEL,
// ITEM_SETUP_BACKLIGHT_MODE,
// ITEM_SETUP_BACKLIGHT_DELAY,
// ITEM_SETUP_BRIGHTNESS,
// ITEM_SETUP_FLASH_BEEP,
ITEM_SETUP_BACKLIGHT_LABEL,
ITEM_SETUP_BACKLIGHT_MODE,
ITEM_SETUP_BACKLIGHT_DELAY,
ITEM_SETUP_BRIGHTNESS,
ITEM_SETUP_DIM_LEVEL,
ITEM_SETUP_FLASH_BEEP,
// CASE_SPLASH_PARAM(ITEM_SETUP_DISABLE_SPLASH)
CASE_GPS(ITEM_SETUP_TIMEZONE)
CASE_GPS(ITEM_SETUP_GPSFORMAT)
@ -372,7 +373,6 @@ bool menuGeneralSetup(evt_t event)
if (attr) g_eeGeneral.inactivityTimer = checkIncDec(event, g_eeGeneral.inactivityTimer, 0, 250, EE_GENERAL); //0..250minutes
break;
#if 0
case ITEM_SETUP_BACKLIGHT_LABEL:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BACKLIGHT_LABEL);
break;
@ -394,7 +394,7 @@ bool menuGeneralSetup(evt_t event)
break;
case ITEM_SETUP_BRIGHTNESS:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BRIGHTNESS);
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BLONBRIGHTNESS);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ;
if (attr) {
uint8_t b = 100 - g_eeGeneral.backlightBright;
@ -403,12 +403,11 @@ bool menuGeneralSetup(evt_t event)
}
break;
case ITEM_SETUP_BACKLIGHT_COLOR:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BLCOLOR);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 20, attr);
if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 20, EE_GENERAL | NO_INCDEC_MARKS);
case ITEM_SETUP_DIM_LEVEL:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BLOFFBRIGHTNESS);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.blOffBright, attr|LEFT) ;
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.blOffBright, 0, 100);
break;
#endif
#if 0
case ITEM_SETUP_DISABLE_SPLASH:

View file

@ -258,6 +258,7 @@ void generalDefault()
#elif defined(PCBHORUS)
g_eeGeneral.potsConfig = 0x05; // S1 and S2 = pots with detent
g_eeGeneral.slidersConfig = 0x03; // LS and RS = sliders with detent
g_eeGeneral.blOffBright = 20;
#elif defined(PCBTARANIS)
g_eeGeneral.potsConfig = 0x05; // S1 and S2 = pots with detent
g_eeGeneral.slidersConfig = 0x03; // LS and RS = sliders with detent

View file

@ -272,11 +272,12 @@ void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y,
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
void lcdStoreBackupBuffer(void);
int lcdRestoreBackupBuffer(void);
void LCD_ControlLight(uint16_t dutyCycle);
// Backlight driver
#define setBacklight(xx)
#define backlightEnable()
#define backlightDisable()
#define setBacklight(xx) LCD_ControlLight(xx)
#define backlightEnable() setBacklight(100-g_eeGeneral.backlightBright)
#define backlightDisable() setBacklight(g_eeGeneral.blOffBright)
#define isBacklightEnable() true
// USB driver

View file

@ -320,32 +320,33 @@ void LCD_LayerInit()
void LCD_ControlLight(uint16_t dutyCycle)
{
static uint16_t existingDutyCycle;
if (dutyCycle == existingDutyCycle) {
return;
}
else {
existingDutyCycle = dutyCycle;
}
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
uint16_t freq = LCD_BKLIGHT_PWM_FREQ;
uint32_t temp = 0;
temp = 1000000 / freq - 1;
TIM_TimeBaseStructure.TIM_Prescaler = SystemCoreClock / 1000000 - 1 ;
TIM_TimeBaseStructure.TIM_Prescaler = SystemCoreClock / 10000 - 1 ;//1KhZ
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = temp;
TIM_TimeBaseStructure.TIM_Period = 100;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
unsigned long tempValue;
tempValue = (unsigned long)divRoundClosest((temp+1)*(100-dutyCycle), dutyCycle);
TIM_Cmd(TIM8, DISABLE);
/* Channel 1 Configuration in PWM mode */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
TIM_OCInitStructure.TIM_Pulse = (uint32_t)tempValue;
TIM_OCInitStructure.TIM_Pulse = (100-dutyCycle);
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;

View file

@ -1337,6 +1337,10 @@ uint8_t i2cReadBQ24195(uint8_t) { return 0; }
void i2cWriteBQ24195(uint8_t, uint8_t) { }
#endif
#if defined(PCBHORUS)
void LCD_ControlLight(uint16_t dutyCycle) { }
#endif
void serialPrintf(const char * format, ...) { }
void serialCrlf() { }
void serialPutc(char c) { }

View file

@ -248,7 +248,7 @@ const pm_char STR_PERSISTENT[] PROGMEM = TR_PERSISTENT;
const pm_char STR_BACKLIGHT_LABEL[] PROGMEM = TR_BACKLIGHT_LABEL;
const pm_char STR_BLDELAY[] PROGMEM = TR_BLDELAY;
#if defined(PWM_BACKLIGHT)
#if defined(PWM_BACKLIGHT) || defined(PCBHORUS)
const pm_char STR_BLONBRIGHTNESS[] PROGMEM = TR_BLONBRIGHTNESS;
const pm_char STR_BLOFFBRIGHTNESS[] PROGMEM = TR_BLOFFBRIGHTNESS;
#endif
@ -616,9 +616,9 @@ const pm_char STR_REMOVE_SCREEN[] PROGMEM = TR_REMOVE_SCREEN;
const pm_char STR_MODULE[] PROGMEM = TR_MODULE;
const pm_char STR_ENABLE_POPUP[] PROGMEM = TR_ENABLE_POPUP;
const pm_char STR_DISABLE_POPUP[] PROGMEM = TR_DISABLE_POPUP;
const pm_char STR_POPUP[] PROGMEM = TR_POPUP;
const pm_char STR_MIN[] PROGMEM = TR_MIN;
const pm_char STR_MAX[] PROGMEM = TR_MAX;
const pm_char STR_POPUP[] PROGMEM = TR_POPUP;
const pm_char STR_MIN[] PROGMEM = TR_MIN;
const pm_char STR_MAX[] PROGMEM = TR_MAX;
const pm_char STR_CURVE_PRESET[] PROGMEM = TR_CURVE_PRESET;
const pm_char STR_PRESET[] PROGMEM = TR_PRESET;
const pm_char STR_MIRROR[] PROGMEM = TR_MIRROR;
@ -652,13 +652,13 @@ const pm_char STR_MAX[] PROGMEM = TR_MAX;
const pm_char STR_MENU_HELI[] PROGMEM = TR_MENU_HELI;
const pm_char STR_MENU_TRIMS[] PROGMEM = TR_MENU_TRIMS;
const pm_char STR_MENU_SWITCHES[] PROGMEM = TR_MENU_SWITCHES;
const pm_char STR_MENU_LOGICAL_SWITCHES[] PROGMEM = TR_MENU_LOGICAL_SWITCHES;
const pm_char STR_MENU_LOGICAL_SWITCHES[] PROGMEM = TR_MENU_LOGICAL_SWITCHES;
const pm_char STR_MENU_TRAINER[] PROGMEM = TR_MENU_TRAINER;
const pm_char STR_MENU_CHANNELS[] PROGMEM = TR_MENU_CHANNELS;
const pm_char STR_MENU_GVARS[] PROGMEM = TR_MENU_GVARS;
const pm_char STR_MENU_TELEMETRY[] PROGMEM = TR_MENU_TELEMETRY;
const pm_char STR_MENU_OTHER[] PROGMEM = TR_MENU_OTHER;
const pm_char STR_MENU_INVERT[] PROGMEM = TR_MENU_INVERT;
const pm_char STR_MENU_OTHER[] PROGMEM = TR_MENU_OTHER;
const pm_char STR_MENU_INVERT[] PROGMEM = TR_MENU_INVERT;
#endif
#if MENUS_LOCK == 1

View file

@ -465,7 +465,7 @@ extern const pm_char STR_BEEPCOUNTDOWN[];
extern const pm_char STR_PERSISTENT[];
extern const pm_char STR_BACKLIGHT_LABEL[];
extern const pm_char STR_BLDELAY[];
#if defined(PWM_BACKLIGHT)
#if defined(PWM_BACKLIGHT) || defined(PCBHORUS)
extern const pm_char STR_BLONBRIGHTNESS[];
extern const pm_char STR_BLOFFBRIGHTNESS[];
#endif