summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/test_fps.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index cd091e8e04..fd1ee2a89b 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -18,6 +18,7 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19#include "plugin.h" 19#include "plugin.h"
20#include "helper.h" 20#include "helper.h"
21#include "grey.h"
21 22
22#ifdef HAVE_LCD_BITMAP 23#ifdef HAVE_LCD_BITMAP
23 24
@@ -43,6 +44,10 @@ static int max_line;
43static int remote_line; 44static int remote_line;
44static int remote_max_line; 45static int remote_max_line;
45#endif 46#endif
47#if LCD_DEPTH < 4
48static unsigned char *gbuf;
49static size_t gbuf_size;
50#endif
46 51
47static void log_init(void) 52static void log_init(void)
48{ 53{
@@ -251,6 +256,76 @@ static void time_remote_update(void)
251} 256}
252#endif 257#endif
253 258
259#if LCD_DEPTH < 4
260static unsigned char greydata[LCD_HEIGHT][LCD_WIDTH];
261
262static void make_grey_rect(int width, int height)
263{
264 unsigned char vline[LCD_WIDTH];
265 int x, y;
266
267 for (x = 0; x < width; x++)
268 vline[x] = (x << 8) / width;
269 for (y = 0; y < height; y++)
270 rb->memcpy(greydata[y], vline, width);
271}
272
273static void time_greyscale(void)
274{
275 char str[32]; /* text buffer */
276 long time_start; /* start tickcount */
277 long time_end; /* end tickcount */
278 long time_1, time_2;
279 int frames_1, frames_2;
280 int fps, load;
281
282 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
283 if (!grey_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT, NULL))
284 {
285 log_text("greylib: out of memory.");
286 return;
287 }
288 make_grey_rect(LCD_WIDTH, LCD_HEIGHT);
289
290 /* Test 1 - greyscale overlay not yet enabled */
291 frames_1 = 0;
292 rb->sleep(0); /* sync to tick */
293 time_start = *rb->current_tick;
294 while((time_end = *rb->current_tick) - time_start < DURATION)
295 {
296 grey_ub_gray_bitmap(greydata[0], 0, 0, LCD_WIDTH, LCD_HEIGHT);
297 frames_1++;
298 }
299 time_1 = time_end - time_start;
300
301 /* Test 2 - greyscale overlay enabled */
302 grey_show(true);
303 frames_2 = 0;
304 rb->sleep(0); /* sync to tick */
305 time_start = *rb->current_tick;
306 while((time_end = *rb->current_tick) - time_start < DURATION)
307 {
308 grey_ub_gray_bitmap(greydata[0], 0, 0, LCD_WIDTH, LCD_HEIGHT);
309 frames_2++;
310 }
311 time_2 = time_end - time_start;
312
313 grey_release();
314 fps = calc_tenth_fps(frames_2, time_2);
315 load = 100 - (100* frames_2 * time_1) / (frames_1 * time_2);
316 rb->snprintf(str, sizeof(str), "1/1: %d.%d fps", fps / 10, fps % 10);
317 log_text(str);
318
319 if (load > 0 && load < 100)
320 {
321 rb->snprintf(str, sizeof(str), "CPU load: %d%%", load);
322 log_text(str);
323 }
324 else
325 log_text("CPU load err (boost?)");
326}
327#endif
328
254/* plugin entry point */ 329/* plugin entry point */
255enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 330enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
256{ 331{
@@ -275,6 +350,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
275 log_text("Main LCD YUV"); 350 log_text("Main LCD YUV");
276 time_main_yuv(); 351 time_main_yuv();
277#endif 352#endif
353#if LCD_DEPTH < 4
354 log_text("Greyscale library");
355 time_greyscale();
356#endif
278#ifdef HAVE_REMOTE_LCD 357#ifdef HAVE_REMOTE_LCD
279 log_text("Remote LCD Update"); 358 log_text("Remote LCD Update");
280 time_remote_update(); 359 time_remote_update();