Skip to content

Commit

Permalink
Backlight should be off when init to prevent flashing.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclli committed Jun 28, 2024
1 parent 7b7fd64 commit c952b8b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions radio/src/targets/pl18/backlight_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ void backlightInit()
// PIN init
gpio_init_af(BACKLIGHT_GPIO, BACKLIGHT_GPIO_AF, GPIO_PIN_SPEED_LOW);

// TODO review this when the timer will be chosen
stm32_timer_enable_clock(BACKLIGHT_TIMER);
BACKLIGHT_TIMER->ARR = 100;
BACKLIGHT_TIMER->PSC = BACKLIGHT_TIMER_FREQ / 1000000 - 1; // 10kHz (same as FrOS)
BACKLIGHT_TIMER->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1PE; // PWM mode 1
BACKLIGHT_TIMER->CCER = TIM_CCER_CC1E | TIM_CCER_CC1NE;
BACKLIGHT_TIMER->CCR1 = 100; // 100% on init
BACKLIGHT_TIMER->CCR1 = 0;
BACKLIGHT_TIMER->EGR = TIM_EGR_UG;
BACKLIGHT_TIMER->CR1 |= TIM_CR1_CEN; // Counter enable
BACKLIGHT_TIMER->BDTR |= TIM_BDTR_MOE;
Expand All @@ -68,6 +67,11 @@ void backlightEnable(uint8_t dutyCycle)
lastDutyCycle = dutyCycle;
}

void backlightFullOn()
{
backlightEnable(BACKLIGHT_LEVEL_MAX);
}

void lcdOff() {
backlightEnable(0);
}
Expand Down

0 comments on commit c952b8b

Please sign in to comment.