static void time_greyscale(void) { char str[32]; /* text buffer */ long time_start; /* start tickcount */ long time_end; /* end tickcount */ long time_1, time_2; int frames_1, frames_2; int fps, load; gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL)) { log_text("greylib: out of memory."); return; } make_grey_rect(LCD_WIDTH, LCD_HEIGHT); /* Test 1 - greyscale overlay not yet enabled */ frames_1 = 0; rb->sleep(0); /* sync to tick */ time_start = *rb->current_tick; while((time_end = *rb->current_tick) - time_start < DURATION) { grey_ub_gray_bitmap(greydata[0], 0, 0, LCD_WIDTH, LCD_HEIGHT); frames_1++; } time_1 = time_end - time_start; /* Test 2 - greyscale overlay enabled */ grey_show(true); frames_2 = 0; rb->sleep(0); /* sync to tick */ time_start = *rb->current_tick; while((time_end = *rb->current_tick) - time_start < DURATION) { grey_ub_gray_bitmap(greydata[0], 0, 0, LCD_WIDTH, LCD_HEIGHT); frames_2++; } time_2 = time_end - time_start; grey_release(); fps = calc_tenth_fps(frames_2, time_2); load = 100 - (100 * frames_2 * time_1) / (frames_1 * time_2); rb->snprintf(str, sizeof(str), "1/1: %d.%d fps", fps / 10, fps % 10); log_text(str); if (load > 0 && load < 100) { rb->snprintf(str, sizeof(str), "CPU load: %d%%", load); log_text(str); } else log_text("CPU load err (boost?)"); }
static void time_greyscale(void) { char str[32]; /* text buffer */ long time_start; /* start tickcount */ long time_end; /* end tickcount */ long time_1, time_2; int frames_1, frames_2; int fps, load; size_t gbuf_size; unsigned char *gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); #if NUM_CORES > 1 int i; for (i = 0; i < NUM_CORES; i++) { rb->snprintf(str, sizeof(str), "Greyscale (%s)", (i > 0) ? "COP" : "CPU"); log_text(str); #else const int i = 0; log_text("Greyscale library"); { #endif if (!grey_init(gbuf, gbuf_size, (i > 0) ? GREY_ON_COP : 0, LCD_WIDTH, LCD_HEIGHT, NULL)) { log_text("greylib: out of memory."); return; } make_grey_rect(LCD_WIDTH, LCD_HEIGHT); /* Test 1 - greyscale overlay not yet enabled */ frames_1 = 0; rb->sleep(0); /* sync to tick */ time_start = *rb->current_tick; while((time_end = *rb->current_tick) - time_start < DURATION) { grey_ub_gray_bitmap(greydata[0], 0, 0, LCD_WIDTH, LCD_HEIGHT); frames_1++; } time_1 = time_end - time_start; /* Test 2 - greyscale overlay enabled */ grey_show(true); frames_2 = 0; rb->sleep(0); /* sync to tick */ time_start = *rb->current_tick; while((time_end = *rb->current_tick) - time_start < DURATION) { grey_ub_gray_bitmap(greydata[0], 0, 0, LCD_WIDTH, LCD_HEIGHT); frames_2++; } time_2 = time_end - time_start; grey_release(); fps = calc_tenth_fps(frames_2, time_2); load = 100 - (100 * frames_2 * time_1) / (frames_1 * time_2); rb->snprintf(str, sizeof(str), "1/1: %d.%d fps", fps / 10, fps % 10); log_text(str); if (load > 0 && load < 100) { rb->snprintf(str, sizeof(str), "CPU load: %d%%", load); log_text(str); } else log_text("CPU load err (boost?)"); } } #endif void plugin_quit(void) { #ifdef HAVE_TOUCHSCREEN static struct touchbutton button[] = {{ .action = ACTION_STD_OK, .title = "OK", /* .vp runtime initialized, rest false/NULL */ }}; struct viewport *vp = &button[0].vp; struct screen *lcd = rb->screens[SCREEN_MAIN]; rb->viewport_set_defaults(vp, SCREEN_MAIN); const int border = 10; const int height = 50; lcd->set_viewport(vp); /* button matches the bottom center in the grid */ vp->x = lcd->lcdwidth/3; vp->width = lcd->lcdwidth/3; vp->height = height; vp->y = lcd->lcdheight - height - border; touchbutton_draw(button, ARRAYLEN(button)); lcd->update_viewport(); if (rb->touchscreen_get_mode() == TOUCHSCREEN_POINT) { while(touchbutton_get(button, ARRAYLEN(button)) != ACTION_STD_OK); } else #endif while (1) { int btn = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, ARRAYLEN(plugin_contexts)); exit_on_usb(btn); if ((btn == FPS_QUIT) || (btn == FPS_QUIT2)) break; } }