summaryrefslogtreecommitdiff
path: root/apps/plugins/fractals/fractal.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/fractals/fractal.c')
-rw-r--r--apps/plugins/fractals/fractal.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/plugins/fractals/fractal.c b/apps/plugins/fractals/fractal.c
index 179bc3e562..971ae506ca 100644
--- a/apps/plugins/fractals/fractal.c
+++ b/apps/plugins/fractals/fractal.c
@@ -29,7 +29,6 @@
29#include "fractal_rect.h" 29#include "fractal_rect.h"
30#include "fractal_sets.h" 30#include "fractal_sets.h"
31#include "mandelbrot_set.h" 31#include "mandelbrot_set.h"
32#include "lib/pluginlib_exit.h"
33 32
34#ifdef USEGSLIB 33#ifdef USEGSLIB
35GREY_INFO_STRUCT 34GREY_INFO_STRUCT
@@ -42,7 +41,7 @@ static size_t gbuf_size = 0;
42#define REDRAW_FULL 2 41#define REDRAW_FULL 2
43#define REDRAW_FULL_OVERLAY 3 42#define REDRAW_FULL_OVERLAY 3
44 43
45 44PLUGIN_HEADER
46 45
47/* returns 1 if a button has been pressed, 0 otherwise */ 46/* returns 1 if a button has been pressed, 0 otherwise */
48static int button_yield(void *ctx) 47static int button_yield(void *ctx)
@@ -86,8 +85,9 @@ static int button_yield(void *ctx)
86 } 85 }
87} 86}
88 87
89static void cleanup(void) 88static void cleanup(void *parameter)
90{ 89{
90 (void)parameter;
91#ifdef USEGSLIB 91#ifdef USEGSLIB
92 grey_release(); 92 grey_release();
93#endif 93#endif
@@ -109,13 +109,11 @@ enum plugin_status plugin_start(const void* parameter)
109 if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL)) 109 if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL))
110 { 110 {
111 rb->splash(HZ, "Couldn't init greyscale display"); 111 rb->splash(HZ, "Couldn't init greyscale display");
112 return PLUGIN_ERROR; 112 return 0;
113 } 113 }
114 grey_show(true); /* switch on greyscale overlay */ 114 grey_show(true); /* switch on greyscale overlay */
115#endif 115#endif
116 116
117 /* release greylib on exit */
118 atexit(cleanup);
119#if LCD_DEPTH > 1 117#if LCD_DEPTH > 1
120 rb->lcd_set_backdrop(NULL); 118 rb->lcd_set_backdrop(NULL);
121#endif 119#endif
@@ -163,6 +161,9 @@ enum plugin_status plugin_start(const void* parameter)
163 case FRACTAL_RC_QUIT: 161 case FRACTAL_RC_QUIT:
164#endif 162#endif
165 case FRACTAL_QUIT: 163 case FRACTAL_QUIT:
164#ifdef USEGSLIB
165 grey_release();
166#endif
166 return PLUGIN_OK; 167 return PLUGIN_OK;
167 168
168 case FRACTAL_ZOOM_OUT: 169 case FRACTAL_ZOOM_OUT:
@@ -245,13 +246,18 @@ enum plugin_status plugin_start(const void* parameter)
245 break; 246 break;
246 247
247 default: 248 default:
248 exit_on_usb(button); 249 if (rb->default_event_handler_ex(button, cleanup, NULL)
250 == SYS_USB_CONNECTED)
251 return PLUGIN_USB_CONNECTED;
249 break; 252 break;
250 } 253 }
251 254
252 if (button != BUTTON_NONE) 255 if (button != BUTTON_NONE)
253 lastbutton = button; 256 lastbutton = button;
254 } 257 }
258#ifdef USEGSLIB
259 grey_release();
260#endif
255 return PLUGIN_OK; 261 return PLUGIN_OK;
256} 262}
257 263