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 2
65 static unsigned colorset
[NUM_COLORSETS
] = {
66 LCD_RGBPACK(255, 255, 255), /* white */
67 LCD_RGBPACK(255, 0, 0), /* red */
69 #endif /* HAVE_LCD_COLOR */
71 /* this is the plugin entry point */
72 enum plugin_status
plugin_start(const void* parameter
)
74 enum plugin_status status
= PLUGIN_OK
;
82 #endif /* HAVE_LCD_COLOR */
85 unsigned bg_color
= rb
->lcd_get_background();
86 rb
->lcd_set_backdrop(NULL
);
87 rb
->lcd_set_background(LCD_WHITE
);
90 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
91 int current_brightness
= MAX_BRIGHTNESS_SETTING
;
92 backlight_brightness_set(MAX_BRIGHTNESS_SETTING
);
93 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
94 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
95 buttonlight_brightness_set(MAX_BRIGHTNESS_SETTING
);
96 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
98 #ifdef HAVE_LCD_INVERT
99 #ifdef HAVE_NEGATIVE_LCD
100 rb
->lcd_set_invert_display(true);
102 rb
->lcd_set_invert_display(false);
103 #endif /* HAVE_NEGATIVE_LCD */
104 #endif /* HAVE_LCD_INVERT */
106 backlight_force_on();
107 #ifdef HAVE_BUTTON_LIGHT
108 buttonlight_force_on();
109 #endif /* HAVE_BUTTON_LIGHT */
111 rb
->lcd_clear_display();
116 #ifdef HAVE_LCD_COLOR
120 cs
= NUM_COLORSETS
-1;
121 if(cs
>= NUM_COLORSETS
)
123 rb
->lcd_set_background(colorset
[cs
]);
124 rb
->lcd_clear_display();
128 #endif /* HAVE_LCD_COLOR */
129 button
= pluginlib_getaction(HZ
*30, plugin_contexts
,
130 ARRAYLEN(plugin_contexts
));
134 #ifdef HAVE_LCD_COLOR
138 #endif /* LAMP_NEXT */
146 #endif /* LAMP_PREV */
150 #endif /* HAVE_LCD_COLOR */
152 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
154 case (LAMP_UP_REPEAT
):
155 if (current_brightness
< MAX_BRIGHTNESS_SETTING
)
156 backlight_brightness_set(++current_brightness
);
160 case (LAMP_DOWN_REPEAT
):
161 if (current_brightness
> MIN_BRIGHTNESS_SETTING
)
162 backlight_brightness_set(--current_brightness
);
164 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
173 if(rb
->default_event_handler(button
) == SYS_USB_CONNECTED
)
175 status
= PLUGIN_USB_CONNECTED
;
179 rb
->reset_poweroff_timer();
183 backlight_use_settings();
184 #ifdef HAVE_BUTTON_LIGHT
185 buttonlight_use_settings();
186 #endif /* HAVE_BUTTON_LIGHT */
188 #ifdef HAVE_LCD_INVERT
189 rb
->lcd_set_invert_display(rb
->global_settings
->invert
);
190 #endif /* HAVE_LCD_INVERT */
192 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
193 backlight_brightness_use_setting();
194 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
195 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
196 buttonlight_brightness_use_setting();
197 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
200 rb
->lcd_set_background(bg_color
);