revert r19656 for lamp which is no longer needed. should fix FS#9877
[kugel-rb.git] / apps / plugins / lamp.c
blob335bea55ebfa22d45c43f1549a1fc066f93de6e8
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
25 #include "plugin.h"
26 #include "lib/helper.h"
28 PLUGIN_HEADER
30 #if defined(HAVE_BACKLIGHT)
31 /* variable button definitions - only targets with a colour display */
32 #if defined(HAVE_LCD_COLOR)
33 #if (CONFIG_KEYPAD == IRIVER_H300_PAD)
34 # define LAMP_LEFT BUTTON_LEFT
35 # define LAMP_RIGHT BUTTON_RIGHT
37 #elif (CONFIG_KEYPAD == IPOD_4G_PAD)
38 # define LAMP_LEFT BUTTON_LEFT
39 # define LAMP_RIGHT BUTTON_RIGHT
40 # define LAMP_NEXT BUTTON_SCROLL_FWD
41 # define LAMP_PREV BUTTON_SCROLL_BACK
43 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
44 # define LAMP_LEFT BUTTON_LEFT
45 # define LAMP_RIGHT BUTTON_RIGHT
47 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
48 # define LAMP_LEFT BUTTON_LEFT
49 # define LAMP_RIGHT BUTTON_RIGHT
51 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
52 # define LAMP_LEFT BUTTON_LEFT
53 # define LAMP_RIGHT BUTTON_RIGHT
55 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
56 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
57 # define LAMP_LEFT BUTTON_LEFT
58 # define LAMP_RIGHT BUTTON_RIGHT
59 # define LAMP_NEXT BUTTON_SCROLL_FWD
60 # define LAMP_PREV BUTTON_SCROLL_BACK
62 #elif (CONFIG_KEYPAD == SANSA_C200_PAD)
63 # define LAMP_LEFT BUTTON_LEFT
64 # define LAMP_RIGHT BUTTON_RIGHT
66 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
67 # define LAMP_LEFT BUTTON_LEFT
68 # define LAMP_RIGHT BUTTON_RIGHT
69 # define LAMP_NEXT BUTTON_SCROLL_UP
70 # define LAMP_PREV BUTTON_SCROLL_DOWN
72 #elif CONFIG_KEYPAD == MROBE500_PAD
73 # define LAMP_LEFT BUTTON_LEFT
74 # define LAMP_RIGHT BUTTON_RIGHT
76 #elif CONFIG_KEYPAD == COWOND2_PAD
78 #elif CONFIG_KEYPAD == IAUDIO67_PAD
79 # define LAMP_LEFT BUTTON_LEFT
80 # define LAMP_RIGHT BUTTON_RIGHT
82 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
83 # define LAMP_LEFT BUTTON_LEFT
84 # define LAMP_RIGHT BUTTON_RIGHT
86 #else
87 # error Missing key definitions for this keypad
88 #endif
89 #endif
91 #ifdef HAVE_TOUCHSCREEN
92 # ifndef LAMP_LEFT
93 # define LAMP_LEFT BUTTON_MIDLEFT
94 # endif
95 # ifndef LAMP_RIGHT
96 # define LAMP_RIGHT BUTTON_MIDRIGHT
97 # endif
98 # ifndef LAMP_NEXT
99 # define LAMP_NEXT BUTTON_TOPMIDDLE
100 # endif
101 # ifndef LAMP_PREV
102 # define LAMP_PREV BUTTON_BOTTOMMIDDLE
103 # endif
104 #endif
106 #ifdef HAVE_LCD_COLOR
107 /* RGB color sets */
108 #define NUM_COLORSETS 2
109 static int colorset[NUM_COLORSETS][3] = { { 255, 255, 255 } , /* white */
110 { 255, 0, 0 } }; /* red */
111 #endif /* HAVE_LCD_COLOR */
113 /* this is the plugin entry point */
114 enum plugin_status plugin_start(const void* parameter)
116 long button;
117 (void)parameter;
119 #ifdef HAVE_LCD_COLOR
120 int cs = 0;
121 bool quit = false;
122 #endif /* HAVE_LCD_COLOR */
124 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
125 short old_brightness = rb->global_settings->brightness;
126 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
127 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
128 short old_buttonlight_brightness =
129 rb->global_settings->buttonlight_brightness;
130 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
132 #if LCD_DEPTH > 1
133 unsigned bg_color=rb->lcd_get_background();
134 rb->lcd_set_backdrop(NULL);
135 rb->lcd_set_background(LCD_WHITE);
136 #endif
138 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
139 rb->backlight_set_brightness(MAX_BRIGHTNESS_SETTING);
140 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
141 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
142 rb->buttonlight_set_brightness(MAX_BRIGHTNESS_SETTING);
143 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
145 #ifdef HAVE_LCD_INVERT
146 #if defined(MROBE_100) || defined(SANSA_CLIP)
147 /* mrobe-100 has inverted display so invert it for max brightness */
148 /* sansa clip has no real backlight so we need to enable all pixels */
149 rb->lcd_set_invert_display(true);
150 #else
151 rb->lcd_set_invert_display(false);
152 #endif /* MROBE_100 */
153 #endif /* HAVE_LCD_INVERT */
155 backlight_force_on();
156 #ifdef HAVE_BUTTON_LIGHT
157 buttonlight_force_on();
158 #endif /* HAVE_BUTTON_LIGHT */
160 #ifdef HAVE_LCD_COLOR
163 if(cs < 0)
164 cs = NUM_COLORSETS-1;
165 if(cs >= NUM_COLORSETS)
166 cs = 0;
167 rb->lcd_set_background( LCD_RGBPACK( colorset[cs][0],
168 colorset[cs][1],
169 colorset[cs][2] ) );
170 rb->lcd_clear_display();
171 rb->lcd_update();
173 switch((button = rb->button_get(true)))
175 case LAMP_RIGHT:
176 #ifdef LAMP_NEXT
177 case LAMP_NEXT:
178 #endif /* LAMP_NEXT */
179 cs++;
180 break;
182 case LAMP_LEFT:
183 #ifdef LAMP_PREV
184 case LAMP_PREV:
185 #endif /* LAMP_PREV */
186 cs--;
187 break;
189 case (LAMP_RIGHT|BUTTON_REPEAT):
190 case (LAMP_RIGHT|BUTTON_REL):
191 case (LAMP_LEFT|BUTTON_REPEAT):
192 case (LAMP_LEFT|BUTTON_REL):
193 #ifdef LAMP_NEXT
194 case (LAMP_NEXT|BUTTON_REPEAT):
195 case (LAMP_NEXT|BUTTON_REL):
196 #endif /* LAMP_NEXT */
197 #ifdef LAMP_PREV
198 case (LAMP_PREV|BUTTON_REPEAT):
199 case (LAMP_PREV|BUTTON_REL):
200 #endif /* LAMP_PREV */
201 /* eat these... */
202 break;
203 default:
204 quit = true;
206 } while (!quit);
208 #else /* HAVE_LCD_COLOR */
209 rb->lcd_clear_display();
210 rb->lcd_update();
211 /* wait */
214 button = rb->button_get(false);
215 if (button && !IS_SYSEVENT(button))
216 break;
217 rb->yield();
218 } while (1);
220 #endif /*HAVE_LCD_COLOR */
222 /* restore */
223 backlight_use_settings();
224 #ifdef HAVE_BUTTON_LIGHT
225 buttonlight_use_settings();
226 #endif /* HAVE_BUTTON_LIGHT */
228 #ifdef HAVE_LCD_INVERT
229 rb->lcd_set_invert_display(rb->global_settings->invert);
230 #endif /* HAVE_LCD_INVERT */
232 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
233 rb->backlight_set_brightness(old_brightness);
234 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
235 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
236 rb->buttonlight_set_brightness(old_buttonlight_brightness);
237 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
239 #if LCD_DEPTH > 1
240 rb->lcd_set_background(bg_color);
241 #endif
242 return PLUGIN_OK;
244 #endif