1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Barry Wardell
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "backlight-target.h"
25 #include "backlight.h"
26 #include "ascodec-target.h"
29 int buttonlight_is_on
= 0;
30 int backlight_is_on
= 0;
31 static int backlight_level
= 0;
33 /* logarithmic lookup table for brightness s*/
34 static const int brightness_table
[MAX_BRIGHTNESS_SETTING
+1] = {
35 0, 21, 47, 78, 118, 165, 224, 296, 386, 495, 630, 796, 1000
38 static void _ll_backlight_on(void)
43 static void _ll_backlight_off(void)
48 void _backlight_pwm(int on
)
57 bool _backlight_init(void)
63 void _backlight_set_brightness(int brightness
)
65 backlight_level
= brightness_table
[brightness
];
73 void _backlight_on(void)
75 #ifdef HAVE_LCD_ENABLE
76 lcd_enable(true); /* power on lcd + visible display */
80 _set_timer2_pwm_ratio(backlight_level
);
84 void _backlight_off(void)
87 _set_timer2_pwm_ratio(0);
89 #ifdef HAVE_LCD_ENABLE
90 lcd_enable(false); /* power off visible display */
94 void _buttonlight_on(void)
96 /* Needed for buttonlight and MicroSD to work at the same time */
97 /* Turn ROD control on, as the OF does */
99 SD_MCI_POWER
|= (1<<7);
100 GPIOD_PIN(7) = (1<<7);
101 buttonlight_is_on
= 1;
104 void _buttonlight_off(void)
106 /* Needed for buttonlight and MicroSD to work at the same time */
107 /* Turn ROD control off, as the OF does */
108 SD_MCI_POWER
&= ~(1<<7);
110 GPIOD_DIR
&= ~(1<<7);
111 buttonlight_is_on
= 0;