1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Vuong Minh Hiep (vmh)
11 * Copyright (C) 2008 Thomas Martitz (kugel.)
12 * Copyright (C) 2008 Alexander Papst
13 * Copyright (C) 2008 Peter D'Hoye
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
26 #include "lib/helper.h"
28 /* variable button definitions.
29 - only targets with a colour display
30 LAMP_LEFT / LAMP_RIGHT: change the color
31 LAMP_NEXT / LAMP_PREV: (optional) change the color
32 - only targets which can set brightness
33 LAMP_UP / LAMP_DOWN: change the brightness
35 #if defined(HAVE_LCD_COLOR) || defined(HAVE_BACKLIGHT_BRIGHTNESS)
36 #if (CONFIG_KEYPAD == IRIVER_H300_PAD)
37 # define LAMP_LEFT BUTTON_LEFT
38 # define LAMP_RIGHT BUTTON_RIGHT
39 # define LAMP_UP BUTTON_UP
40 # define LAMP_DOWN BUTTON_DOWN
42 #elif (CONFIG_KEYPAD == IPOD_4G_PAD)
43 # define LAMP_LEFT BUTTON_LEFT
44 # define LAMP_RIGHT BUTTON_RIGHT
45 # define LAMP_UP BUTTON_SCROLL_FWD
46 # define LAMP_DOWN BUTTON_SCROLL_BACK
48 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
49 # define LAMP_LEFT BUTTON_LEFT
50 # define LAMP_RIGHT BUTTON_RIGHT
51 # define LAMP_UP BUTTON_UP
52 # define LAMP_DOWN BUTTON_DOWN
54 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
55 # define LAMP_LEFT BUTTON_LEFT
56 # define LAMP_RIGHT BUTTON_RIGHT
57 # define LAMP_UP BUTTON_UP
58 # define LAMP_DOWN BUTTON_DOWN
60 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
61 # define LAMP_LEFT BUTTON_LEFT
62 # define LAMP_RIGHT BUTTON_RIGHT
63 # define LAMP_UP BUTTON_UP
64 # define LAMP_DOWN BUTTON_DOWN
66 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
67 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
68 # define LAMP_LEFT BUTTON_LEFT
69 # define LAMP_RIGHT BUTTON_RIGHT
70 # define LAMP_UP BUTTON_SCROLL_FWD
71 # define LAMP_DOWN BUTTON_SCROLL_BACK
73 #elif (CONFIG_KEYPAD == SANSA_C200_PAD)
74 # define LAMP_LEFT BUTTON_LEFT
75 # define LAMP_RIGHT BUTTON_RIGHT
76 # define LAMP_UP BUTTON_UP
77 # define LAMP_DOWN BUTTON_DOWN
79 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
80 # define LAMP_LEFT BUTTON_LEFT
81 # define LAMP_RIGHT BUTTON_RIGHT
82 # define LAMP_NEXT BUTTON_SCROLL_UP
83 # define LAMP_PREV BUTTON_SCROLL_DOWN
85 #elif CONFIG_KEYPAD == MROBE500_PAD
86 # define LAMP_LEFT BUTTON_LEFT
87 # define LAMP_RIGHT BUTTON_RIGHT
89 #elif CONFIG_KEYPAD == COWON_D2_PAD
91 #elif CONFIG_KEYPAD == IAUDIO67_PAD
92 # define LAMP_LEFT BUTTON_LEFT
93 # define LAMP_RIGHT BUTTON_RIGHT
95 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
96 # define LAMP_LEFT BUTTON_LEFT
97 # define LAMP_RIGHT BUTTON_RIGHT
98 # define LAMP_UP BUTTON_UP
99 # define LAMP_DOWN BUTTON_DOWN
101 #elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
102 # define LAMP_LEFT BUTTON_LEFT
103 # define LAMP_RIGHT BUTTON_RIGHT
104 # define LAMP_UP BUTTON_UP
105 # define LAMP_DOWN BUTTON_DOWN
107 #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
108 # define LAMP_LEFT BUTTON_PREV
109 # define LAMP_RIGHT BUTTON_NEXT
110 # define LAMP_UP BUTTON_UP
111 # define LAMP_DOWN BUTTON_DOWN
113 #elif CONFIG_KEYPAD == ONDAVX747_PAD
114 # define LAMP_LEFT BUTTON_VOL_DOWN
115 # define LAMP_RIGHT BUTTON_VOL_UP
117 #elif CONFIG_KEYPAD == ONDAVX777_PAD
119 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
120 # define LAMP_LEFT BUTTON_LEFT
121 # define LAMP_RIGHT BUTTON_RIGHT
123 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
124 # define LAMP_LEFT BUTTON_PREV
125 # define LAMP_RIGHT BUTTON_NEXT
126 # define LAMP_UP BUTTON_UP
127 # define LAMP_DOWN BUTTON_DOWN
129 #elif CONFIG_KEYPAD == MPIO_HD200_PAD
130 # define LAMP_UP BUTTON_REW
131 # define LAMP_DOWN BUTTON_FF
133 #elif CONFIG_KEYPAD == MPIO_HD300_PAD
134 # define LAMP_UP BUTTON_UP
135 # define LAMP_DOWN BUTTON_DOWN
138 # error Missing key definitions for this keypad
140 #endif /* HAVE_LCD_COLOR || HAVE_BACKLIGHT_BRIGHTNESS */
142 #ifdef HAVE_TOUCHSCREEN
144 # define LAMP_LEFT BUTTON_MIDLEFT
147 # define LAMP_RIGHT BUTTON_MIDRIGHT
150 # define LAMP_UP BUTTON_TOPMIDDLE
153 # define LAMP_DOWN BUTTON_BOTTOMMIDDLE
157 #ifdef HAVE_LCD_COLOR
159 #define NUM_COLORSETS 2
160 static unsigned colorset
[NUM_COLORSETS
] = {
161 LCD_RGBPACK(255, 255, 255), /* white */
162 LCD_RGBPACK(255, 0, 0), /* red */
164 #endif /* HAVE_LCD_COLOR */
166 /* this is the plugin entry point */
167 enum plugin_status
plugin_start(const void* parameter
)
169 enum plugin_status status
= PLUGIN_OK
;
174 #ifdef HAVE_LCD_COLOR
177 #endif /* HAVE_LCD_COLOR */
180 unsigned bg_color
= rb
->lcd_get_background();
181 rb
->lcd_set_backdrop(NULL
);
182 rb
->lcd_set_background(LCD_WHITE
);
185 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
186 int current_brightness
= MAX_BRIGHTNESS_SETTING
;
187 backlight_brightness_set(MAX_BRIGHTNESS_SETTING
);
188 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
189 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
190 buttonlight_brightness_set(MAX_BRIGHTNESS_SETTING
);
191 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
193 #ifdef HAVE_LCD_INVERT
194 #ifdef HAVE_NEGATIVE_LCD
195 rb
->lcd_set_invert_display(true);
197 rb
->lcd_set_invert_display(false);
198 #endif /* HAVE_NEGATIVE_LCD */
199 #endif /* HAVE_LCD_INVERT */
201 backlight_force_on();
202 #ifdef HAVE_BUTTON_LIGHT
203 buttonlight_force_on();
204 #endif /* HAVE_BUTTON_LIGHT */
206 rb
->lcd_clear_display();
211 #ifdef HAVE_LCD_COLOR
215 cs
= NUM_COLORSETS
-1;
216 if(cs
>= NUM_COLORSETS
)
218 rb
->lcd_set_background(colorset
[cs
]);
219 rb
->lcd_clear_display();
223 #endif /* HAVE_LCD_COLOR */
225 switch((button
= rb
->button_get_w_tmo(HZ
*30)))
227 #ifdef HAVE_LCD_COLOR
231 #endif /* LAMP_NEXT */
239 #endif /* LAMP_PREV */
243 #endif /* HAVE_LCD_COLOR */
245 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
247 case (LAMP_UP
|BUTTON_REPEAT
):
248 if (current_brightness
< MAX_BRIGHTNESS_SETTING
)
249 backlight_brightness_set(++current_brightness
);
253 case (LAMP_DOWN
|BUTTON_REPEAT
):
254 if (current_brightness
> MIN_BRIGHTNESS_SETTING
)
255 backlight_brightness_set(--current_brightness
);
257 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
263 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
265 status
= PLUGIN_USB_CONNECTED
;
268 if(!(button
& (BUTTON_REL
|BUTTON_REPEAT
))
269 && !IS_SYSEVENT(button
))
273 rb
->reset_poweroff_timer();
277 backlight_use_settings();
278 #ifdef HAVE_BUTTON_LIGHT
279 buttonlight_use_settings();
280 #endif /* HAVE_BUTTON_LIGHT */
282 #ifdef HAVE_LCD_INVERT
283 rb
->lcd_set_invert_display(rb
->global_settings
->invert
);
284 #endif /* HAVE_LCD_INVERT */
286 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
287 backlight_brightness_use_setting();
288 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
289 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
290 buttonlight_brightness_use_setting();
291 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
294 rb
->lcd_set_background(bg_color
);