Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

lamp plugin: -handles sys_events. -disable idle poweroff (part of FS#11578 by Hayden Pearce.) -correct button table in the manual.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28429 a1c6a512-1295-4272-9138-f99709370657

+78 -59
+51 -46
apps/plugins/lamp.c
··· 123 123 #ifdef HAVE_LCD_COLOR 124 124 /* RGB color sets */ 125 125 #define NUM_COLORSETS 2 126 - static int colorset[NUM_COLORSETS][3] = { { 255, 255, 255 } , /* white */ 127 - { 255, 0, 0 } }; /* red */ 126 + static unsigned colorset[NUM_COLORSETS] = { 127 + LCD_RGBPACK(255, 255, 255), /* white */ 128 + LCD_RGBPACK(255, 0, 0), /* red */ 129 + }; 128 130 #endif /* HAVE_LCD_COLOR */ 129 131 130 132 /* this is the plugin entry point */ 131 133 enum plugin_status plugin_start(const void* parameter) 132 134 { 135 + enum plugin_status status = PLUGIN_OK; 133 136 long button; 134 137 (void)parameter; 135 138 136 139 #ifdef HAVE_LCD_COLOR 137 140 int cs = 0; 138 141 bool quit = false; 142 + bool update = true; 139 143 #endif /* HAVE_LCD_COLOR */ 140 144 141 - #ifdef HAVE_BACKLIGHT_BRIGHTNESS 142 - short old_brightness = rb->global_settings->brightness; 143 - #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ 144 - #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 145 - short old_buttonlight_brightness = 146 - rb->global_settings->buttonlight_brightness; 147 - #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ 148 - 149 145 #if LCD_DEPTH > 1 150 - unsigned bg_color=rb->lcd_get_background(); 146 + unsigned bg_color = rb->lcd_get_background(); 151 147 rb->lcd_set_backdrop(NULL); 152 148 rb->lcd_set_background(LCD_WHITE); 153 149 #endif 154 150 155 151 #ifdef HAVE_BACKLIGHT_BRIGHTNESS 156 - rb->backlight_set_brightness(MAX_BRIGHTNESS_SETTING); 152 + backlight_brightness_set(MAX_BRIGHTNESS_SETTING); 157 153 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ 158 154 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 159 - rb->buttonlight_set_brightness(MAX_BRIGHTNESS_SETTING); 155 + buttonlight_brightness_set(MAX_BRIGHTNESS_SETTING); 160 156 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ 161 157 162 158 #ifdef HAVE_LCD_INVERT ··· 175 171 #ifdef HAVE_LCD_COLOR 176 172 do 177 173 { 178 - if(cs < 0) 179 - cs = NUM_COLORSETS-1; 180 - if(cs >= NUM_COLORSETS) 181 - cs = 0; 182 - rb->lcd_set_background( LCD_RGBPACK( colorset[cs][0], 183 - colorset[cs][1], 184 - colorset[cs][2] ) ); 185 - rb->lcd_clear_display(); 186 - rb->lcd_update(); 174 + if(update) 175 + { 176 + if(cs < 0) 177 + cs = NUM_COLORSETS-1; 178 + if(cs >= NUM_COLORSETS) 179 + cs = 0; 180 + rb->lcd_set_background(colorset[cs]); 181 + rb->lcd_clear_display(); 182 + rb->lcd_update(); 183 + update = false; 184 + } 187 185 188 - switch((button = rb->button_get(true))) 186 + switch((button = rb->button_get_w_tmo(HZ*30))) 189 187 { 190 188 case LAMP_RIGHT: 191 189 #ifdef LAMP_NEXT 192 190 case LAMP_NEXT: 193 191 #endif /* LAMP_NEXT */ 194 192 cs++; 193 + update = true; 195 194 break; 196 195 197 196 case LAMP_LEFT: ··· 199 198 case LAMP_PREV: 200 199 #endif /* LAMP_PREV */ 201 200 cs--; 201 + update = true; 202 202 break; 203 203 204 - case (LAMP_RIGHT|BUTTON_REPEAT): 205 - case (LAMP_RIGHT|BUTTON_REL): 206 - case (LAMP_LEFT|BUTTON_REPEAT): 207 - case (LAMP_LEFT|BUTTON_REL): 208 - #ifdef LAMP_NEXT 209 - case (LAMP_NEXT|BUTTON_REPEAT): 210 - case (LAMP_NEXT|BUTTON_REL): 211 - #endif /* LAMP_NEXT */ 212 - #ifdef LAMP_PREV 213 - case (LAMP_PREV|BUTTON_REPEAT): 214 - case (LAMP_PREV|BUTTON_REL): 215 - #endif /* LAMP_PREV */ 216 - /* eat these... */ 217 - break; 218 204 default: 219 - quit = true; 205 + if(button) 206 + { 207 + if(rb->default_event_handler(button) == SYS_USB_CONNECTED) 208 + { 209 + status = PLUGIN_USB_CONNECTED; 210 + quit = true; 211 + } 212 + if(!(button & (BUTTON_REL|BUTTON_REPEAT)) 213 + && !IS_SYSEVENT(button)) 214 + quit = true; 215 + } 216 + break; 220 217 } 218 + rb->reset_poweroff_timer(); 221 219 } while (!quit); 222 220 223 221 #else /* HAVE_LCD_COLOR */ ··· 226 224 /* wait */ 227 225 do 228 226 { 229 - button = rb->button_get(false); 230 - if (button && !IS_SYSEVENT(button)) 231 - break; 232 - rb->yield(); 227 + button = rb->button_get_w_tmo(HZ*30); 228 + if(button) 229 + { 230 + if(rb->default_event_handler(button) == SYS_USB_CONNECTED) 231 + { 232 + status = PLUGIN_USB_CONNECTED; 233 + break; 234 + } 235 + if(!IS_SYSEVENT(button)) 236 + break; 237 + } 238 + rb->reset_poweroff_timer(); 233 239 } while (1); 234 240 235 241 #endif /*HAVE_LCD_COLOR */ ··· 245 251 #endif /* HAVE_LCD_INVERT */ 246 252 247 253 #ifdef HAVE_BACKLIGHT_BRIGHTNESS 248 - rb->backlight_set_brightness(old_brightness); 254 + backlight_brightness_use_setting(); 249 255 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ 250 256 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 251 - rb->buttonlight_set_brightness(old_buttonlight_brightness); 257 + buttonlight_brightness_use_setting(); 252 258 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ 253 259 254 260 #if LCD_DEPTH > 1 255 261 rb->lcd_set_background(bg_color); 256 262 #endif 257 - return PLUGIN_OK; 263 + return status; 258 264 } 259 -
+12
apps/plugins/lib/helper.c
··· 107 107 rb->backlight_set_brightness(rb->global_settings->brightness); 108 108 } 109 109 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ 110 + 111 + #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 112 + void buttonlight_brightness_set(int brightness) 113 + { 114 + rb->buttonlight_set_brightness(brightness); 115 + } 116 + 117 + void buttonlight_brightness_use_setting(void) 118 + { 119 + rb->buttonlight_set_brightness(rb->global_settings->buttonlight_brightness); 120 + } 121 + #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
+5
apps/plugins/lib/helper.h
··· 32 32 void remote_backlight_force_on(void); 33 33 void remote_backlight_use_settings(void); 34 34 #endif 35 + 35 36 #ifdef HAVE_BUTTON_LIGHT 36 37 void buttonlight_force_on(void); 37 38 void buttonlight_use_settings(void); ··· 45 46 void backlight_brightness_use_setting(void); 46 47 #endif 47 48 49 + #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 50 + void buttonlight_brightness_set(int brightness); 51 + void buttonlight_brightness_use_setting(void); 52 + #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ 48 53 49 54 #endif /* _LIB_HELPER_H_ */
+10 -13
manual/plugins/lamp.tex
··· 3 3 Lamp is a simple plugin to use your player as a lamp (flashlight, torch). 4 4 You get an empty screen with maximum brightness. 5 5 \begin{btnmap} 6 - \opt{lcd_color}{ 6 + \opt{lcd_color}{ 7 7 \opt{PLAYER_PAD,RECORDER_PAD,ONDIO_PAD,IRIVER_H100_PAD,IRIVER_H300_PAD% 8 8 ,IPOD_4G_PAD,IPOD_3G_PAD,IRIVER_H10_PAD,IAUDIO_X5_PAD,SANSA_E200_PAD% 9 9 ,SANSA_C200_PAD,GIGABEAT_PAD,MROBE100_PAD,SANSA_FUZE_PAD,PBELL_VIBE500_PAD} 10 10 {\ButtonLeft/\ButtonRight} 11 11 \opt{COWON_D2_PAD}{\TouchMidLeft{} / \TouchMidRight} 12 - \opt{HAVEREMOTEKEYMAP}{& } 12 + \opt{HAVEREMOTEKEYMAP}{& } 13 13 & Toggle between colours\\ 14 - } 15 - \opt{PLAYER_PAD}{\ButtonMenu} 16 - \opt{RECORDER_PAD,ONDIO_PAD,IRIVER_H100_PAD,IRIVER_H300_PAD}{\ButtonOff} 17 - \opt{IPOD_4G_PAD,IPOD_3G_PAD}{Long \ButtonPlay} 18 - \opt{IRIVER_H10_PAD,IAUDIO_X5_PAD,SANSA_E200_PAD,SANSA_C200_PAD,GIGABEAT_PAD,MROBE100_PAD}{\ButtonPower} 19 - \opt{SANSA_FUZE_PAD}{\ButtonHome} 20 - \opt{COWON_D2_PAD}{\ButtonPower} 21 - \opt{PBELL_VIBE500_PAD}{\ButtonRec} 22 - \opt{HAVEREMOTEKEYMAP}{& 23 - \opt{IRIVER_RC_H100_PAD}{\ButtonRCStop} 24 - } 14 + Any ohter key 15 + \opt{HAVEREMOTEKEYMAP}{& } 16 + & Quit\\ 17 + } 18 + \nopt{lcd_color}{ 19 + Any key 20 + \opt{HAVEREMOTEKEYMAP}{& } 25 21 & Quit\\ 22 + } 26 23 \end{btnmap}