summaryrefslogtreecommitdiff
path: root/apps/plugins/grayscale.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/grayscale.c')
-rw-r--r--apps/plugins/grayscale.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/apps/plugins/grayscale.c b/apps/plugins/grayscale.c
index 2be9cc9c23..ebfc7f59c0 100644
--- a/apps/plugins/grayscale.c
+++ b/apps/plugins/grayscale.c
@@ -25,6 +25,12 @@
25#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ 25#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
26#include "gray.h" 26#include "gray.h"
27 27
28/* variable button definitions */
29#if CONFIG_KEYPAD == RECORDER_PAD
30#define GRAYSCALE_SHIFT BUTTON_ON
31#elif CONFIG_KEYPAD == ONDIO_PAD
32#define GRAYSCALE_SHIFT BUTTON_MENU
33#endif
28/******************************* Globals ***********************************/ 34/******************************* Globals ***********************************/
29 35
30static struct plugin_api* rb; /* global api struct pointer */ 36static struct plugin_api* rb; /* global api struct pointer */
@@ -34,6 +40,15 @@ static unsigned int gbuf_size = 0;
34 40
35/**************************** main function ********************************/ 41/**************************** main function ********************************/
36 42
43void cleanup(void *parameter)
44{
45 (void)parameter;
46
47 gray_release_buffer(); /* switch off overlay and deinitialize */
48 /* restore normal backlight setting */
49 rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
50}
51
37/* this is only a demo of what the framework can do */ 52/* this is only a demo of what the framework can do */
38int main(void) 53int main(void)
39{ 54{
@@ -193,21 +208,17 @@ int main(void)
193 208
194 button = rb->button_get(true); 209 button = rb->button_get(true);
195 210
196 if (button == SYS_USB_CONNECTED) 211 if (rb->default_event_handler_ex(button, cleanup, NULL)
197 { 212 == SYS_USB_CONNECTED)
198 gray_release_buffer(); /* switch off overlay and deinitialize */
199 /* restore normal backlight setting */
200 rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
201 return PLUGIN_USB_CONNECTED; 213 return PLUGIN_USB_CONNECTED;
202 }
203 214
204 if (button & BUTTON_ON) 215 if (button & GRAYSCALE_SHIFT)
205 black_border = true; 216 black_border = true;
206 217
207 if (button & BUTTON_REPEAT) 218 if (button & BUTTON_REPEAT)
208 scroll_amount = 4; 219 scroll_amount = 4;
209 220
210 switch(button & ~(BUTTON_ON | BUTTON_REPEAT)) 221 switch(button & ~(GRAYSCALE_SHIFT | BUTTON_REPEAT))
211 { 222 {
212 case BUTTON_LEFT: 223 case BUTTON_LEFT:
213 224
@@ -231,9 +242,7 @@ int main(void)
231 242
232 case BUTTON_OFF: 243 case BUTTON_OFF:
233 244
234 gray_release_buffer(); /* switch off overlay and deinitialize */ 245 cleanup(NULL);
235 /* restore normal backlight setting */
236 rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
237 return PLUGIN_OK; 246 return PLUGIN_OK;
238 } 247 }
239 } 248 }
@@ -243,7 +252,6 @@ int main(void)
243 252
244enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 253enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
245{ 254{
246 int ret;
247 /* this macro should be called as the first thing you do in the plugin. 255 /* this macro should be called as the first thing you do in the plugin.
248 it test that the api version and model the plugin was compiled for 256 it test that the api version and model the plugin was compiled for
249 matches the machine it is running on */ 257 matches the machine it is running on */
@@ -255,11 +263,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
255 /* This plugin uses the grayscale framework, so initialize */ 263 /* This plugin uses the grayscale framework, so initialize */
256 gray_init(api); 264 gray_init(api);
257 265
258 ret = main(); 266 return main();
259
260 if (ret == PLUGIN_USB_CONNECTED)
261 rb->usb_screen();
262 return ret;
263} 267}
264 268
265#endif // #ifdef HAVE_LCD_BITMAP 269#endif // #ifdef HAVE_LCD_BITMAP