Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ / |
| 5 | * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) ( |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2007 Vuong Minh Hiep (vmh) |
| 11 | * Copyright (C) 2008 Thomas Martitz (kugel.) |
| 12 | * Copyright (C) 2008 Alexander Papst |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 13 | * Copyright (C) 2008 Peter D'Hoye |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 14 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 19 | * |
| 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 21 | * KIND, either express or implied. |
| 22 | * |
| 23 | ****************************************************************************/ |
| 24 | |
| 25 | #include "plugin.h" |
| 26 | #include "helper.h" |
| 27 | |
| 28 | PLUGIN_HEADER |
| 29 | |
| 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) |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 34 | # define LAMP_LEFT BUTTON_LEFT |
| 35 | # define LAMP_RIGHT BUTTON_RIGHT |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 36 | |
| 37 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 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 |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 42 | |
| 43 | #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 44 | # define LAMP_LEFT BUTTON_LEFT |
| 45 | # define LAMP_RIGHT BUTTON_RIGHT |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 46 | |
| 47 | #elif (CONFIG_KEYPAD == GIGABEAT_PAD) |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 48 | # define LAMP_LEFT BUTTON_LEFT |
| 49 | # define LAMP_RIGHT BUTTON_RIGHT |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 50 | |
| 51 | #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 52 | # define LAMP_LEFT BUTTON_LEFT |
| 53 | # define LAMP_RIGHT BUTTON_RIGHT |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 54 | |
| 55 | #elif (CONFIG_KEYPAD == SANSA_E200_PAD) |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 56 | # define LAMP_LEFT BUTTON_LEFT |
| 57 | # define LAMP_RIGHT BUTTON_RIGHT |
| 58 | # define LAMP_NEXT BUTTON_SCROLL_FWD |
| 59 | # define LAMP_PREV BUTTON_SCROLL_BACK |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 60 | |
| 61 | #elif (CONFIG_KEYPAD == SANSA_C200_PAD) |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 62 | # define LAMP_LEFT BUTTON_LEFT |
| 63 | # define LAMP_RIGHT BUTTON_RIGHT |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 64 | |
| 65 | #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 66 | # define LAMP_LEFT BUTTON_LEFT |
| 67 | # define LAMP_RIGHT BUTTON_RIGHT |
| 68 | # define LAMP_NEXT BUTTON_SCROLL_UP |
| 69 | # define LAMP_PREV BUTTON_SCROLL_DOWN |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 70 | |
Peter D'Hoye | c9fa717 | 2008-04-23 21:43:18 +0000 | [diff] [blame] | 71 | #elif CONFIG_KEYPAD == MROBE500_PAD |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 72 | # define LAMP_LEFT BUTTON_LEFT |
| 73 | # define LAMP_RIGHT BUTTON_RIGHT |
Peter D'Hoye | c9fa717 | 2008-04-23 21:43:18 +0000 | [diff] [blame] | 74 | |
| 75 | #elif CONFIG_KEYPAD == COWOND2_PAD |
Peter D'Hoye | c9fa717 | 2008-04-23 21:43:18 +0000 | [diff] [blame] | 76 | |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 77 | #else |
| 78 | # error Missing key definitions for this keypad |
| 79 | #endif |
| 80 | #endif |
| 81 | |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 82 | #ifdef HAVE_TOUCHPAD |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 83 | # ifndef LAMP_LEFT |
| 84 | # define LAMP_LEFT BUTTON_MIDLEFT |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 85 | # endif |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 86 | # ifndef LAMP_RIGHT |
| 87 | # define LAMP_RIGHT BUTTON_MIDRIGHT |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 88 | # endif |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 89 | # ifndef LAMP_NEXT |
| 90 | # define LAMP_NEXT BUTTON_TOPMIDDLE |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 91 | # endif |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 92 | # ifndef LAMP_PREV |
| 93 | # define LAMP_PREV BUTTON_BOTTOMMIDDLE |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 94 | # endif |
| 95 | #endif |
| 96 | |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 97 | static const struct plugin_api* rb; /* global api struct pointer */ |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 98 | |
| 99 | #ifdef HAVE_LCD_COLOR |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 100 | /* RGB color sets */ |
| 101 | #define NUM_COLORSETS 2 |
| 102 | static int colorset[NUM_COLORSETS][3] = { { 255, 255, 255 } , /* white */ |
| 103 | { 255, 0, 0 } }; /* red */ |
| 104 | #endif /* HAVE_LCD_COLOR */ |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 105 | |
| 106 | /* this is the plugin entry point */ |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 107 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 108 | { |
| 109 | (void)parameter; |
| 110 | rb = api; |
| 111 | |
| 112 | #ifdef HAVE_LCD_COLOR |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 113 | int cs = 0; |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 114 | bool quit = false; |
| 115 | #endif /* HAVE_LCD_COLOR */ |
| 116 | |
| 117 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
| 118 | short old_brightness = rb->global_settings->brightness; |
| 119 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ |
Peter D'Hoye | 21a3733 | 2008-05-08 21:23:31 +0000 | [diff] [blame] | 120 | #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS |
| 121 | short old_buttonlight_brightness = |
| 122 | rb->global_settings->buttonlight_brightness; |
| 123 | #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 124 | |
| 125 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 126 | unsigned bg_color=rb->lcd_get_background(); |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 127 | rb->lcd_set_backdrop(NULL); |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 128 | rb->lcd_set_background(LCD_WHITE); |
| 129 | #endif |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 130 | |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 131 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
| 132 | rb->backlight_set_brightness(MAX_BRIGHTNESS_SETTING); |
| 133 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ |
Peter D'Hoye | 21a3733 | 2008-05-08 21:23:31 +0000 | [diff] [blame] | 134 | #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS |
| 135 | rb->buttonlight_set_brightness(MAX_BRIGHTNESS_SETTING); |
| 136 | #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 137 | |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 138 | #ifdef HAVE_LCD_INVERT |
Robert Kukla | b4beb05 | 2008-06-28 18:00:04 +0000 | [diff] [blame] | 139 | #ifdef MROBE_100 |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 140 | /* mrobe-100 has inverted display so invert it for max brightness */ |
Peter D'Hoye | 6482c73 | 2008-04-24 00:21:08 +0000 | [diff] [blame] | 141 | rb->lcd_set_invert_display(true); |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 142 | #else |
Peter D'Hoye | 6482c73 | 2008-04-24 00:21:08 +0000 | [diff] [blame] | 143 | rb->lcd_set_invert_display(false); |
Robert Kukla | b4beb05 | 2008-06-28 18:00:04 +0000 | [diff] [blame] | 144 | #endif /* MROBE_100 */ |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 145 | #endif /* HAVE_LCD_INVERT */ |
| 146 | |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 147 | backlight_force_on(rb); |
Peter D'Hoye | 21a3733 | 2008-05-08 21:23:31 +0000 | [diff] [blame] | 148 | #ifdef HAVE_BUTTON_LIGHT |
| 149 | buttonlight_force_on(rb); |
| 150 | #endif /* HAVE_BUTTON_LIGHT */ |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 151 | |
| 152 | #ifdef HAVE_LCD_COLOR |
Peter D'Hoye | 21a3733 | 2008-05-08 21:23:31 +0000 | [diff] [blame] | 153 | do |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 154 | { |
Peter D'Hoye | d402774 | 2008-05-03 14:55:34 +0000 | [diff] [blame] | 155 | if(cs < 0) |
| 156 | cs = NUM_COLORSETS-1; |
| 157 | if(cs >= NUM_COLORSETS) |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 158 | cs = 0; |
| 159 | rb->lcd_set_background( LCD_RGBPACK( colorset[cs][0], |
| 160 | colorset[cs][1], |
| 161 | colorset[cs][2] ) ); |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 162 | rb->lcd_clear_display(); |
| 163 | rb->lcd_update(); |
| 164 | |
| 165 | switch(rb->button_get(true)) |
| 166 | { |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 167 | case LAMP_RIGHT: |
| 168 | #ifdef LAMP_NEXT |
| 169 | case LAMP_NEXT: |
| 170 | #endif /* LAMP_NEXT */ |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 171 | cs++; |
| 172 | break; |
| 173 | |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 174 | case LAMP_LEFT: |
| 175 | #ifdef LAMP_PREV |
| 176 | case LAMP_PREV: |
| 177 | #endif /* LAMP_PREV */ |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 178 | cs--; |
| 179 | break; |
| 180 | |
Peter D'Hoye | ebdb89b | 2008-05-07 21:59:45 +0000 | [diff] [blame] | 181 | case (LAMP_RIGHT|BUTTON_REPEAT): |
| 182 | case (LAMP_RIGHT|BUTTON_REL): |
| 183 | case (LAMP_LEFT|BUTTON_REPEAT): |
| 184 | case (LAMP_LEFT|BUTTON_REL): |
| 185 | #ifdef LAMP_NEXT |
| 186 | case (LAMP_NEXT|BUTTON_REPEAT): |
| 187 | case (LAMP_NEXT|BUTTON_REL): |
| 188 | #endif /* LAMP_NEXT */ |
| 189 | #ifdef LAMP_PREV |
| 190 | case (LAMP_PREV|BUTTON_REPEAT): |
| 191 | case (LAMP_PREV|BUTTON_REL): |
| 192 | #endif /* LAMP_PREV */ |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 193 | /* eat these... */ |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 194 | break; |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 195 | default: |
| 196 | quit = true; |
| 197 | } |
| 198 | } while (!quit); |
| 199 | |
| 200 | #else /* HAVE_LCD_COLOR */ |
| 201 | rb->lcd_clear_display(); |
| 202 | rb->lcd_update(); |
| 203 | /* wait */ |
| 204 | while(rb->button_get(false) == BUTTON_NONE) |
| 205 | { |
| 206 | rb->yield(); |
| 207 | } |
| 208 | |
| 209 | #endif /*HAVE_LCD_COLOR */ |
| 210 | |
| 211 | /* restore */ |
| 212 | backlight_use_settings(rb); |
Peter D'Hoye | 21a3733 | 2008-05-08 21:23:31 +0000 | [diff] [blame] | 213 | #ifdef HAVE_BUTTON_LIGHT |
| 214 | buttonlight_use_settings(rb); |
| 215 | #endif /* HAVE_BUTTON_LIGHT */ |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 216 | |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 217 | #ifdef HAVE_LCD_INVERT |
Peter D'Hoye | 6482c73 | 2008-04-24 00:21:08 +0000 | [diff] [blame] | 218 | rb->lcd_set_invert_display(rb->global_settings->invert); |
Peter D'Hoye | 8efd5d3 | 2008-04-24 00:06:45 +0000 | [diff] [blame] | 219 | #endif /* HAVE_LCD_INVERT */ |
| 220 | |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 221 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
| 222 | rb->backlight_set_brightness(old_brightness); |
| 223 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ |
Peter D'Hoye | 21a3733 | 2008-05-08 21:23:31 +0000 | [diff] [blame] | 224 | #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS |
| 225 | rb->buttonlight_set_brightness(old_buttonlight_brightness); |
| 226 | #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ |
Peter D'Hoye | 39718e3 | 2008-04-23 21:15:07 +0000 | [diff] [blame] | 227 | |
| 228 | #if LCD_DEPTH > 1 |
| 229 | rb->lcd_set_background(bg_color); |
| 230 | #endif |
| 231 | return PLUGIN_OK; |
| 232 | } |
| 233 | #endif |