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"
27 #include "lib/pluginlib_actions.h"
29 /* this set the context to use with PLA */
30 static const struct button_mapping
*plugin_contexts
[] = { pla_main_ctx
};
32 /* variable button definitions.
33 - only targets with a colour display
34 LAMP_LEFT / LAMP_RIGHT: change the color
35 LAMP_NEXT / LAMP_PREV: (optional) change the color
36 - only targets which can set brightness
37 LAMP_UP / LAMP_DOWN: change the brightness
41 #ifdef HAVE_SCROLLWHEEL
42 # define LAMP_LEFT PLA_LEFT
43 # define LAMP_RIGHT PLA_RIGHT
44 # define LAMP_UP PLA_SCROLL_FWD
45 # define LAMP_DOWN PLA_SCROLL_BACK
46 # define LAMP_UP_REPEAT PLA_SCROLL_FWD_REPEAT
47 # define LAMP_DOWN_REPEAT PLA_SCROLL_BACK_REPEAT
49 # define LAMP_LEFT PLA_LEFT
50 # define LAMP_RIGHT PLA_RIGHT
51 # define LAMP_UP PLA_UP
52 # define LAMP_DOWN PLA_DOWN
53 # define LAMP_UP_REPEAT PLA_UP_REPEAT
54 # define LAMP_DOWN_REPEAT PLA_DOWN_REPEAT
55 #endif/* HAVE_SCROLLWHEEL */
58 #define LAMP_EXIT PLA_EXIT
59 #define LAMP_EXIT2 PLA_CANCEL
64 #define NUM_COLORSETS 9
65 static unsigned colorset
[NUM_COLORSETS
] = {
66 LCD_RGBPACK(255, 255, 255), /* white */
67 LCD_RGBPACK(255, 0, 0), /* red */
68 LCD_RGBPACK(255, 165, 0), /* orange */
69 LCD_RGBPACK(255, 255, 0), /* yellow */
70 LCD_RGBPACK( 0, 255, 0), /* green */
71 LCD_RGBPACK( 0, 0, 255), /* blue */
72 LCD_RGBPACK( 75, 0, 130), /* indigo */
73 LCD_RGBPACK(238, 130, 238), /* violet */
74 LCD_RGBPACK( 0, 0, 0), /* black */
76 #endif /* HAVE_LCD_COLOR */
78 /* this is the plugin entry point */
79 enum plugin_status
plugin_start(const void* parameter
)
81 enum plugin_status status
= PLUGIN_OK
;
89 #endif /* HAVE_LCD_COLOR */
92 unsigned bg_color
= rb
->lcd_get_background();
93 rb
->lcd_set_backdrop(NULL
);
94 rb
->lcd_set_background(LCD_WHITE
);
97 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
98 int current_brightness
= MAX_BRIGHTNESS_SETTING
;
99 backlight_brightness_set(MAX_BRIGHTNESS_SETTING
);
100 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
101 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
102 buttonlight_brightness_set(MAX_BRIGHTNESS_SETTING
);
103 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
105 #ifdef HAVE_LCD_INVERT
106 #ifdef HAVE_NEGATIVE_LCD
107 rb
->lcd_set_invert_display(true);
109 rb
->lcd_set_invert_display(false);
110 #endif /* HAVE_NEGATIVE_LCD */
111 #endif /* HAVE_LCD_INVERT */
113 backlight_force_on();
114 #ifdef HAVE_BUTTON_LIGHT
115 buttonlight_force_on();
116 #endif /* HAVE_BUTTON_LIGHT */
118 rb
->lcd_clear_display();
123 #ifdef HAVE_LCD_COLOR
127 cs
= NUM_COLORSETS
-1;
128 if(cs
>= NUM_COLORSETS
)
130 rb
->lcd_set_background(colorset
[cs
]);
131 rb
->lcd_clear_display();
135 #endif /* HAVE_LCD_COLOR */
136 button
= pluginlib_getaction(HZ
*30, plugin_contexts
,
137 ARRAYLEN(plugin_contexts
));
141 #ifdef HAVE_LCD_COLOR
145 #endif /* LAMP_NEXT */
153 #endif /* LAMP_PREV */
157 #endif /* HAVE_LCD_COLOR */
159 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
161 case (LAMP_UP_REPEAT
):
162 if (current_brightness
< MAX_BRIGHTNESS_SETTING
)
163 backlight_brightness_set(++current_brightness
);
167 case (LAMP_DOWN_REPEAT
):
168 if (current_brightness
> MIN_BRIGHTNESS_SETTING
)
169 backlight_brightness_set(--current_brightness
);
171 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
180 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
182 status
= PLUGIN_USB_CONNECTED
;
186 rb
->reset_poweroff_timer();
190 backlight_use_settings();
191 #ifdef HAVE_BUTTON_LIGHT
192 buttonlight_use_settings();
193 #endif /* HAVE_BUTTON_LIGHT */
195 #ifdef HAVE_LCD_INVERT
196 rb
->lcd_set_invert_display(rb
->global_settings
->invert
);
197 #endif /* HAVE_LCD_INVERT */
199 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
200 backlight_brightness_use_setting();
201 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
202 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
203 buttonlight_brightness_use_setting();
204 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
207 rb
->lcd_set_background(bg_color
);