1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Thomas Martitz
11 * Copyright (C) 2008 by Martin Ritter
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
24 #include "backlight-target.h"
27 #include "backlight.h"
28 #include "backlight-sw-fading.h"
30 /* To adapt a target do:
31 * - make sure _backlight_on doesn't set the brightness to something other than
32 * the previous value (lowest brightness in most cases)
33 * add proper #defines for software fading
36 /* can be MIN_BRIGHTNESS_SETTING-1 */
37 static int current_brightness
= DEFAULT_BRIGHTNESS_SETTING
;
39 void _backlight_fade_update_state(int brightness
)
41 current_brightness
= brightness
;
44 /* returns true if fade is finished */
45 static bool _backlight_fade_up(void)
47 if (LIKELY(current_brightness
< backlight_brightness
))
49 _backlight_set_brightness(++current_brightness
);
51 return(current_brightness
>= backlight_brightness
);
54 /* returns true if fade is finished */
55 static bool _backlight_fade_down(void)
57 if (LIKELY(current_brightness
> MIN_BRIGHTNESS_SETTING
))
59 _backlight_set_brightness(--current_brightness
);
64 /* decrement once more, since backlight is off */
71 bool _backlight_fade_step(int direction
)
77 done
= _backlight_fade_up();
80 done
= _backlight_fade_down();