Backlight control added back in, driver fix (thanks Adela), OFF level configurable
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) { }
|
||||
|
||||
Reference in New Issue
Block a user