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