make backlight code cleaner

This commit is contained in:
Pavol Rusnak 2016-06-06 17:42:50 +02:00
parent bbfd633f35
commit daa1df9f0f
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 4 additions and 4 deletions

View File

@ -203,9 +203,9 @@ void display_update(void) {
int display_backlight(int val)
{
if (val >= 0 && val <= 255) {
if (BACKLIGHT != val && val >= 0 && val <= 255) {
BACKLIGHT = val;
__HAL_TIM_SetCompare(&TIM1_Handle, TIM_CHANNEL_1, LED_PWM_TIM_PERIOD * BACKLIGHT / 255);
}
__HAL_TIM_SetCompare(&TIM1_Handle, TIM_CHANNEL_1, LED_PWM_TIM_PERIOD * BACKLIGHT / 255);
return BACKLIGHT;
}

View File

@ -128,9 +128,9 @@ int display_orientation(int degrees)
int display_backlight(int val)
{
if (val >= 0 && val <= 255) {
if (BACKLIGHT != val && val >= 0 && val <= 255) {
BACKLIGHT = val;
SDL_SetRenderDrawColor(RENDERER, BACKLIGHT, BACKLIGHT, BACKLIGHT, 255);
}
SDL_SetRenderDrawColor(RENDERER, BACKLIGHT, BACKLIGHT, BACKLIGHT, 255);
return BACKLIGHT;
}