unsigned int second_timer(unsigned int ctx) { static int counter = 0; bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20, "seconds: %d", counter++); return 0; }
static MENU_UPDATE_FUNC(script_print) { if (!script_preview_flag || !entry->selected) { MENU_SET_NAME("Show script"); MENU_SET_VALUE(""); script_preview_flag = 0; return; } static int prev_script = -1; if (prev_script != script_selected) { int size; char* p = get_script_path(script_selected); char* f = (char*)read_entire_file(p, &size); if (f) { script_copy_window(script_preview, sizeof(script_preview), f, 0, 0, 20, 60); free_dma_memory(f); } else { snprintf(script_preview, sizeof(script_preview), "Could not read '%s'", p); } } prev_script = script_selected; bmp_fill(40, 0, 0, 720, 430); int fnt = FONT(FONT_MED, COLOR_WHITE, 40); big_bmp_printf(fnt, 10, 10, "%s", script_preview); info->custom_drawing = CUSTOM_DRAW_THIS_MENU; }
/** * Create new button on parent and specified with caption, position and style * * @param __name - name of widget * @param __parent - parent of button. Should be CONTAINER * @param __caption - caption on button * @param __x, __y - coordinates of button * @param __style of button. May be one or combination of: * WBS_DEFAULT - default button on window * @return a pointer to button object */ w_button_t* widget_create_button (const wchar_t *__name, w_container_t *__parent, const wchar_t *__caption, int __x, int __y, unsigned int __style) { w_button_t *res; /* There is no parent or caption is null, so we can't create button */ if (!__parent || !__caption) { return 0; } /* Create context for buttons widgets */ button_context = hotkey_create_context (L"button-class-context", 0); unsigned int w; w = (__caption ? widget_shortcut_length (__caption) : 0) + 4 + (__style & WBS_DEFAULT ? 2 : 0); WIDGET_INIT (res, w_button_t, WT_BUTTON, __name, __parent, WF_NOLAYOUT, button_context, button_destructor, button_drawer, __x, __y, 1, w, 1); /* Set callbacks */ WIDGET_CALLBACK (res, keydown) = (widget_keydown_proc)button_keydown; WIDGET_CALLBACK (res, shortcut) = (widget_action)button_shortcut; WIDGET_SHORTCUT (res)=widget_shortcut_key (__caption); res->caption=wcsdup (__caption); res->style=__style; res->font = FONT (CID_BLACK, CID_GREY); res->focused_font = FONT (CID_BLACK, CID_CYAN); res->hot_font = FONT (CID_BLUE, CID_GREY); res->hot_focused_font = FONT (CID_BLUE, CID_CYAN); WIDGET_POST_INIT (res); return res; }
static font_t base_font(enum map_base base, int x, int y) { font_t font; switch (base) { case BASE_OCEAN: font = FONT(B, b); break; case BASE_COAST: { font = FONT(w, b); float dx = (x / (float)MAP_WIDTH) - 0.5; float dy = (y / (float)MAP_HEIGHT) - 0.5; dx *= 1.3; float dist = sqrt(dx * dx + dy * dy) * 100; float offset = fmod(device_uepoch() / 500000.0, PI * 2); font.fore_bright = sinf(dist + offset) < 0 ? true : false; } break; case BASE_GRASSLAND: font = FONT(G, g); break; case BASE_FOREST: font = FONT(G, g); break; case BASE_HILL: font = FONT(K, g); break; case BASE_MOUNTAIN: font = FONT(w, g); break; case BASE_SAND: font = FONT(Y, Y); break; } return font; }
static Object P_Create_Glyph_Cursor (Object srcf, Object srcc, Object maskf, Object maskc, Object f, Object b) { Font sf = Get_Font (srcf), mf; Display *d = FONT(srcf)->dpy; mf = EQ(maskf, Sym_None) ? None : Get_Font (maskf); return Make_Cursor (d, XCreateGlyphCursor (d, sf, mf, Get_Integer (srcc), mf == None ? 0 : Get_Integer (maskc), Get_Color (f), Get_Color (b))); }
/** * Create new window with specified caption and position * * @param __name - name of widget * @param __caption - caption of window * @param __x, __y - coordinates of window * @param __w, __h - width and height of window * @return a pointer to window object */ w_window_t* widget_create_window (const wchar_t *__name, const wchar_t *__caption, int __x, int __y, int __w, int __h, unsigned int __style) { w_window_t *res; window_context = hotkey_create_context (L"window-class-context", HKCF_OPAQUE); if (__style & WMS_CENTERED) { __x = CENTRE_X (__w); __y = CENTRE_Y (__h); } WIDGET_INIT (res, w_window_t, WT_WINDOW, __name, 0, 0, window_context, window_destructor, window_drawer, __x, __y, 0, __w, __h); if (__caption) { res->caption.text = wcsdup (__caption); } res->panel = panel_new (res->layout); res->style = __style; /* Layout parameters */ res->font = FONT (CID_BLACK, CID_GREY); res->caption.font = FONT (CID_BLUE, CID_GREY); WIDGET_CALLBACK (res, keydown) = (widget_keydown_proc) window_keydown; WIDGET_CALLBACK (res, onresize) = (widget_action) window_onresize; return res; }
void display_overlay(uint8_t *vram_address) { char buffer[LP_MAX_WORD]; if (FLAG_GUI_MODE == GUIMODE_OLC && AE_IS_CREATIVE(DPData.ae)) { if (FLAG_DISPLAY_ON) { int current_cmode = get_current_cmode(); if (status.msm_active) bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_BLACK, COLOR_GRAY), 35, 96, "[***]"); else if (status.cmode_active && current_cmode != CMODE_NONE) bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_BLACK, COLOR_GRAY), 16, 96, "%s", cmodes_config.names[current_cmode]); if (status.fexp && DPData.tv_val != TV_VAL_BULB) bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_BLACK, COLOR_GRAY), 138, 32, "#"); if (settings.autoiso_enable && (DPData.ae != AE_MODE_M || DPData.tv_val != TV_VAL_BULB)) bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_BLACK, COLOR_GRAY), 237, 14, "%s", AUTOISO_AUTO); if (DPData.wb == WB_MODE_COLORTEMP) bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_BLACK, COLOR_GRAY), 50, 138, "%d", DPData.color_temp); if (DPData.ae_bkt) { ec_print(buffer, DPData.ae_bkt); bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_BLACK, COLOR_GRAY), 224, 96, "%s", buffer); } #ifdef RELEASE bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_BLACK, COLOR_BLUE), 148, 0, LP_WORD(L_P_400PLUS)); #else bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_BLACK, COLOR_RED ), 20, 0, LP_WORD(L_A_WARNING)); #endif if (*display_message) { if(timestamp() < message_timeout) bmp_printf(vram_address, FONT(FONT_SMALL, COLOR_WHITE, COLOR_BLACK), 16, 228, display_message); else *display_message = '\0'; } } } }
void display_shooting_info() // called from debug task { if (lv) return; #ifdef FEATURE_FLEXINFO // from flexinfo.c info_print_screen(); #endif // the following is stuff not yet ported to flexinfo #ifdef FEATURE_LCD_SENSOR_REMOTE display_lcd_remote_icon(555, 460); #endif // hack for Rebel cameras to display intermediate ISOs iso_refresh_display(); display_trap_focus_info(); #ifdef STROBO_READY_AND_WE_CAN_USE_IT int col_field = bmp_getpixel(20,10); if (flash_info.mode==STROBO_FLASH_MODE_MANUAL) { uint32_t fntl = FONT(FONT_LARGE, COLOR_YELLOW, col_field); fnt = FONT(FONT_SMALL, COLOR_CYAN, col_field); bmp_printf(fnt, 488, 188, "A"); bmp_printf(fntl, 498, 185, "%3d", 1 << flash_info.group_a_output); bmp_printf(fnt, 556, 188, "B"); bmp_printf(fntl, 564, 185, "%3d", 1 << flash_info.group_b_output ); bmp_printf(fnt, 624, 188, "C"); bmp_printf(fntl, 632, 185, "%3d", 1 << flash_info.group_c_output); bmp_fill(col_bg,486,212,212,6); } #endif }
void qemu_hello() { bmp_printf(FONT_LARGE, 50, 50, "Hello from QEMU!"); for (int i = 1; i < 14; i++) { bfnt_draw_char(-i, i * 50, 100, COLOR_BLUE, COLOR_WHITE); bmp_printf(FONT(FONT_MED, COLOR_BLUE, COLOR_WHITE), i * 50, 140, "%d", i); } qprintf("\nHello at QEMU console!\n\n"); call("dispcheck"); call("shutdown"); while(1); // that's all, folks! }
static void vram_print( void * priv, int x, int y, int selected ) { unsigned menu_font = selected ? FONT(FONT_LARGE, COLOR_WHITE, COLOR_BLACK) : MENU_FONT; bmp_printf( menu_font, x, y, "%s = %d", vram_param_names[(int)priv], MEM(vram_params[(int)priv]) ); menu_draw_icon(x,y,MNI_NONE,0); }
void map_draw_buildings(map_t *map, panel_t *p) { for (size_t y = 0; y < MAP_HEIGHT; y++) { for (size_t x = 0; x < MAP_WIDTH; x++) { enum building building = map->high[x][y].building; if (building != C_NONE) { uint16_t c = building; font_t font = FONT(Y, k); if (map->high[x][y].building_age < 0) { font.fore = COLOR_CYAN; c = tolower(c); } panel_putc(p, x, y, font, c); } } } }
/**************************************************************************** Return the size of the given text in the given font. This size should include the ascent and descent of the text. Either of width or height may be NULL in which case those values simply shouldn't be filled out. ****************************************************************************/ void get_text_size(int *width, int *height, enum client_font font, const char *text) { PangoRectangle rect; if (!layout) { layout = pango_layout_new(gdk_pango_context_get_for_screen(gdk_screen_get_default())); } pango_layout_set_font_description(layout, FONT(font)); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_extents(layout, NULL, &rect); if (width) { *width = rect.width; } if (height) { *height = rect.height; } }
int load(SceSize args, void *argp){ int stat,modid; if(sceKernelStartModule(modid=sceKernelLoadModule("flash0:/vsh/module/libfont_hv.prx",0,NULL),0,NULL,&stat,NULL)<0)return -__LINE__; int errorCode; InitParam initParams = {NULL,4,NULL,myMalloc,myFree,NULL,NULL,NULL,NULL,NULL,NULL}; void* libID = sceFontNewLib(&initParams, &errorCode);if(errorCode)return -__LINE__; void* fontID = sceFontOpen(libID, FONT(BOLD), FILE, &errorCode);if(errorCode)return -__LINE__; memset((void*)0x44000000,0,4*512*16); //print build date printchar(fontID, __DATE__" "__TIME__);//on vram sceIoWrite(2,__DATE__" "__TIME__,11+1+8);//on cout if(sceFontClose(fontID)) return -__LINE__; if(sceFontDoneLib(libID)) return -__LINE__; sceKernelStopModule(modid,0,NULL,&stat,NULL); sceKernelUnloadModule(modid); sceKernelSelfStopUnloadModule(1,0,NULL); return 0; }
/**************************************************************************** Draw the text onto the canvas in the given color and font. The canvas position does not account for the ascent of the text; this function must take care of this manually. The text will not be NULL but may be empty. ****************************************************************************/ void canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y, enum client_font font, struct color *pcolor, const char *text) { cairo_t *cr; if (!layout) { layout = pango_layout_new(gdk_pango_context_get_for_screen(gdk_screen_get_default())); } if (!pcanvas->drawable) { cr = cairo_create(pcanvas->surface); } else { cr = pcanvas->drawable; } if (pcanvas->drawable) { cairo_save(cr); } pango_layout_set_font_description(layout, FONT(font)); pango_layout_set_text(layout, text, -1); if (fonts[font].shadowed) { cairo_set_source_rgb(cr, 0, 0, 0); cairo_move_to(cr, canvas_x * pcanvas->zoom + 1, canvas_y * pcanvas->zoom + 1); pango_cairo_show_layout (cr, layout); } cairo_move_to(cr, canvas_x * pcanvas->zoom, canvas_y * pcanvas->zoom); gdk_cairo_set_source_rgba(cr, &pcolor->color); pango_cairo_show_layout(cr, layout); if (!pcanvas->drawable) { cairo_destroy(cr); } else { cairo_restore(cr); } }
static void dbg_memspy_update() { //int printed_elapsed=0; static int init_done = 0; if (!init_done) dbg_memspy_init(); init_done = 1; if (!dbg_memmirror) return; if (!dbg_memchanges) return; //if (!dbg_memlogged) return; int elapsed_time = _toc(); bmp_printf(FONT_MED, 50, 200, "[%d] ", elapsed_time); int i; int k=0; for (i = 0; i < mem_spy_len; i++) { int fnt = FONT_SMALL; unsigned int addr = dbg_memspy_get_addr(i); int oldval = dbg_memmirror[i]; int newval = MEMX(addr); if (oldval != newval) { dbg_memmirror[i] = newval; if (dbg_memchanges[i] < 1000000) dbg_memchanges[i]++; //dbg_memlogged[i]=0; fnt = FONT(FONT_SMALL,5, COLOR_BG); if (elapsed_time < mem_spy_start_time) dbg_memchanges[i] = 1000000; // so it will be ignored } if (mem_spy_bool && newval != 0 && newval != 1 && newval != -1) continue; if (mem_spy_value_lo && newval < mem_spy_value_lo) continue; if (mem_spy_value_hi && newval > mem_spy_value_hi) continue; if (mem_spy_count_lo && dbg_memchanges[i] < mem_spy_count_lo) continue; if (mem_spy_count_hi && dbg_memchanges[i] > mem_spy_count_hi) continue; int freq = dbg_memchanges[i] / elapsed_time; if (mem_spy_freq_lo && freq < mem_spy_freq_lo) continue; if (mem_spy_freq_hi && freq > mem_spy_freq_hi) continue; //if (dbg_memlogged[i]) return; //if (!printed_elapsed) { // debug_log("memspy: elapsed: %d sec ", elapsed_time); // printed_elapsed = 1; //} //debug_log("%8x:%2d:%8x", addr, dbg_memchanges[i], newval); //dbg_memlogged[i] = 1; //SleepTask(10); int x = 10 + 8 * 22 * (k % 2); int y = 10 + 12 * (k / 2); bmp_printf(fnt, x, y, "[%8x:%2d:%8x]", addr, dbg_memchanges[i], newval); k = (k + 1) % 120; } //printed_elapsed=0; //SleepTask(10); //for (i = 0; i < 10; i++) { // int x = 10 + 8 * 13 * (k % 3); // int y = 10 + 12 * (k / 3); // bmp_printf(FONT_SMALL, x, y, " "); // k = (k + 1) % 120; //} }
static void console_draw(int tiny) { int cbpos0 = mod((console_buffer_index / CONSOLE_W) * CONSOLE_W + CONSOLE_W, BUFSIZE); /* display last two lines that actually contain something (don't display the cursor-only line) */ if (tiny && console_buffer_index % CONSOLE_W == 0) cbpos0 -= CONSOLE_W; int skipped_lines = 0; int chopped_columns = 0; /* skip empty lines at the top */ for (int i = 0; i < CONSOLE_H; i++) { int cbpos = cbpos0 + i * CONSOLE_W; int empty = 1; for (int j = 0; j < CONSOLE_W; j++) if (CONSOLE_BUFFER(cbpos + j) != ' ') { empty = 0; break; } if (empty) skipped_lines++; else break; } if (skipped_lines == CONSOLE_H) // nothing to show return; if (tiny) skipped_lines = CONSOLE_H - 3; /* chop empty columns from the right */ for (int j = CONSOLE_W-1; j > 0; j--) { int empty = 1; for (int i = skipped_lines; i < CONSOLE_H; i++) if (CONSOLE_BUFFER(cbpos0 + i*CONSOLE_W + j) != ' ') { empty = 0; break; } if (empty) chopped_columns++; else break; } chopped_columns = MIN(chopped_columns, CONSOLE_W - (console_buffer_index % CONSOLE_W)); if (skipped_lines < 5) skipped_lines = 0; if (chopped_columns < 5) chopped_columns = 0; /* can we use large fonts? */ int can_use_large_font = (skipped_lines > 7 && chopped_columns > 25 && !tiny); /* top-left corner of "full" console (without lines/columns skipped) */ unsigned x0 = 720/2 - fontspec_font(CONSOLE_FONT)->width * CONSOLE_W/2; unsigned y0 = 480/2 - fontspec_font(CONSOLE_FONT)->height * CONSOLE_H/2; /* correct y to account for skipped lines */ int yc = y0; if (tiny) { yc = gui_menu_shown() || MENU_MODE ? 415 : y0; } else { yc = y0 + fontspec_font(CONSOLE_FONT)->height * skipped_lines; } if (can_use_large_font) yc -= (fontspec_font(FONT_LARGE)->height - fontspec_font(CONSOLE_FONT)->height) * (CONSOLE_H - skipped_lines); int fnt = FONT(can_use_large_font ? FONT_LARGE : CONSOLE_FONT,COLOR_WHITE, (lv || PLAY_OR_QR_MODE) ? COLOR_BG_DARK : COLOR_ALMOST_BLACK); int xa = (x0 & ~3) - 1; int ya = (yc-1); int w = fontspec_font(fnt)->width * (CONSOLE_W - chopped_columns) + 2; int h = fontspec_font(fnt)->height * (CONSOLE_H - skipped_lines) + 2; /* did the console shrink? if so, redraw Canon GUI around it */ static int prev_w = 0; static int prev_h = 0; if (w < prev_w || h < prev_h) { canon_gui_enable_front_buffer(1); // force a redraw prev_w = w; prev_h = h; //return; // better luck next time :) } else if (!tiny) /* fixme: prevent Canon code from drawing over the console (ugly) */ canon_gui_disable_front_buffer(); prev_w = w; prev_h = h; bmp_draw_rect(60, xa, ya, w, h); bmp_draw_rect(COLOR_BLACK, xa-1, ya-1, w+2, h+2); /* display each line */ int found_cursor = 0; for (int i = skipped_lines; i < CONSOLE_H; i++) { char buf[CONSOLE_W+1]; int cbpos = cbpos0 + i * CONSOLE_W; for (int j = 0; j < CONSOLE_W; j++) { // last character should be on last line => this ensures proper scrolling if (mod(cbpos+j, BUFSIZE) == mod(console_buffer_index, BUFSIZE)) // end of data { if (!found_cursor) { buf[j] = '_'; found_cursor = 1; continue; } } buf[j] = found_cursor ? ' ' : CONSOLE_BUFFER(cbpos+j); } buf[CONSOLE_W - chopped_columns] = 0; int y = yc + fontspec_font(fnt)->height * (i - skipped_lines); bmp_printf(fnt, x0, y, buf); } }
void console_show_status() { int fnt = FONT(CONSOLE_FONT,60, COLOR_BLACK); bmp_printf(fnt, 0, 480 - font_med.height, console_status_text); if (console_visible) bmp_printf(fnt, 720 - font_med.width * strlen(console_help_text), 480 - font_med.height, console_help_text); }
/** @copydoc list_struct::post_column_func */ static void list_post_column(list_struct *list, uint32_t row, uint32_t col) { size_t skill_id; SDL_Rect box; skill_id = row * list->cols + col; if (skill_id >= skill_list_num) { return; } if (!FaceList[skill_list[skill_id]->skill->face].sprite) { return; } box.x = list->x + list->frame_offset + INVENTORY_ICON_SIZE * col; box.y = LIST_ROWS_START(list) + (LIST_ROW_OFFSET(row, list) * LIST_ROW_HEIGHT(list)); box.w = INVENTORY_ICON_SIZE; box.h = INVENTORY_ICON_SIZE; surface_show(list->surface, box.x, box.y, NULL, FaceList[skill_list[skill_id]->skill->face].sprite->bitmap); if (selected_skill != skill_id) { return; } border_create_color(list->surface, &box, 1, "ff0000"); char buf[MAX_BUF]; snprintf(VS(buf), "%s", skill_list[skill_id]->skill->s_name); string_title(buf); box.w = 160; text_show(list->surface, FONT_SERIF12, buf, 150, 18, COLOR_HGOLD, TEXT_ALIGN_CENTER | TEXT_OUTLINE, &box); box.h = 100; text_show(list->surface, FONT_ARIAL11, skill_list[skill_id]->msg, 150, 38, COLOR_WHITE, TEXT_WORD_WRAP, &box); if (skill_list[skill_id]->level == 0) { return; } widgetdata *widget = widget_find(NULL, -1, NULL, list->surface); SOFT_ASSERT(widget != NULL, "Could not find widget"); text_show(list->surface, FONT("arial", 10), "[b]Experience[/b]", 167, widget->h - 47, COLOR_WHITE, TEXT_MARKUP, NULL); player_draw_exp_progress(list->surface, 160, widget->h - 32, skill_list[skill_id]->exp, skill_list[skill_id]->level); box.h = 30; box.w = 35; text_show(list->surface, FONT("arial", 10), "[b]Level[/b]", widget->w - 45, widget->h - 47, COLOR_WHITE, TEXT_MARKUP | TEXT_ALIGN_CENTER, &box); text_show_format(list->surface, FONT_SERIF18, widget->w - 45, widget->h - 30, COLOR_HGOLD, TEXT_MARKUP | TEXT_OUTLINE | TEXT_ALIGN_CENTER, &box, "%" PRIu8, skill_list[skill_id]->level); }
static MENU_UPDATE_FUNC(mrc_dump_update_all) { if (!info->can_custom_draw) return; info->custom_drawing = CUSTOM_DRAW_THIS_MENU; bmp_fill(COLOR_BLACK, 0, 0, 720, 480); int skip = (mrc_dump_page - 1) * (450 / font_large.height); int k = 0; int y = 0; int printed = 0; for(int pos = 0; pos < COUNT(cp_regs); pos++) { char *str = cp_regs[pos].desc; if(!str) { break; } k++; if (k <= skip) { continue; } mrc_cp = cp_regs[pos].cp; mrc_crn = cp_regs[pos].crn; mrc_op1 = cp_regs[pos].op1; mrc_crm = cp_regs[pos].crm; mrc_op2 = cp_regs[pos].op2; mrc_dump_process(); printed = 1; if(k%2) { bmp_fill(COLOR_GRAY(10), 0, y, 720, font_large.height); } int yasm = y + font_small.height; bmp_printf( SHADOW_FONT(FONT_SMALL), 10, y, "%s", str ); bmp_printf( SHADOW_FONT(FONT_MED), 10, yasm, "MRC p%d, %d, Rd, c%d, c%d, %d", mrc_cp, mrc_op1, mrc_crn, mrc_crm, mrc_op2 ); bmp_printf( SHADOW_FONT(FONT(FONT_LARGE, COLOR_YELLOW, COLOR_BLACK)), 720 - 8*font_large.width, y, "%8x", mrc_value ); y += font_large.height; if (y > 440) { bmp_printf(FONT(FONT_MED, COLOR_CYAN, COLOR_BLACK), 710 - 7*font_med.width, y, "more..."); break; } } if (!printed) { mrc_dump_page = 1; } }
void green_screen_step() { /**************************************************** * .. if Canon menu is ACTIVE - return immediately * ****************************************************/ if (!lv) { last_green_screen_state = 0; return; } /******************************** * Masses of auto variables. * ********************************/ // unsigned int Xs,Xe; // X_POSITION of Cropmark_start/_end //~ Xs = g_cropmark_x_start; // First Pix drawn on (and a multiple of 4) //~ Xe = g_cropmark_x_end; // First Pix not drawn on (multiple of 4) // unsigned int Vram_pixels = Xe - Xs; unsigned int vpix, lum1, lum2; // results from previous loop, used for display static int total_luma = 0; static int highest_luma = 0; static int lowest_luma = 256; static int total_pixels = 0; // results for current loop, being updated (will be used at next loop) unsigned int total_luma_tmp = 0; unsigned int highest_luma_tmp = 0; unsigned int lowest_luma_tmp = 256; unsigned int total_pixels_tmp = 0; /**************************************************************** * Set address pointers up to first line in Vram * ****************************************************************/ uint32_t* lv = (uint32_t *) get_yuv422_vram()->vram; if (!lv) return; uint8_t* bm = bmp_vram(); // uint16_t* bm16 = (uint16_t *) bmp_vram(); uint8_t* bm_mirror = (uint8_t *) get_bvram_mirror(); unsigned int average_luma = total_luma / total_pixels; unsigned int high_delta = highest_luma - average_luma; // used to work out colour scale unsigned int low_delta = average_luma - lowest_luma; // colour scale for darker pixels /****************************************************************** * Go through Crop area. Note highest and lowest luma, average * ******************************************************************/ int high_delta_factor = 1024 / high_delta; // replace division with multiplication int low_delta_factor = 1024 / low_delta; for(int y = os.y0 + os.off_169; y < os.y_max - os.off_169; y += 2 ) { uint32_t * const v_row = (uint32_t*)( lv + BM2LV_R(y) ); // 2 pixels uint16_t * const b_row = (uint16_t*)( bm + BM_R(y) ); // 2 pixels uint16_t * const m_row = (uint16_t*)( bm_mirror + BM_R(y) ); // 2 pixels uint8_t* lvp; // that's a moving pointer through lv vram uint16_t* bp; // through bmp vram uint16_t* mp; // through mirror for (int x = os.x0; x < os.x_max; x += 2) { lvp = (uint8_t *) (v_row + BM2LV_X(x)/2); lvp++; bp = b_row + x/2; mp = m_row + x/2; /******************************************** * Get 4 bytes of vram (ie two vram Pixels) * ********************************************/ // vpix = [LSB=pix on left] u y1 v y2 [MSB=pix on right] vpix = lv[BM2LV(x,y)/4]; total_pixels_tmp += 2; lum1 = ( vpix & 0x0000FF00 ) >> 8; // y1 lum2 = ( vpix & 0xFF000000 ) >> 24; // y2 /************************* * Update total luma * *************************/ total_luma_tmp += lum1 + lum2; /************************* * new Maximum ? * *************************/ if (lum1 > highest_luma_tmp) highest_luma_tmp = lum1; if (lum2 > highest_luma_tmp) highest_luma_tmp = lum2; /************************* * new Miniumum ? * *************************/ if (lum1 < lowest_luma_tmp) lowest_luma_tmp = lum1; if (lum2 < lowest_luma_tmp) lowest_luma_tmp = lum2; /********************************************************* * Initialise writeback colour of overlay to 0 for LUM1 * *********************************************************/ unsigned int lum = (lum1 + lum2) / 2; unsigned int col = 0; /************************************** * LUM1 Higher than average luma * **************************************/ if (lum > average_luma) { col = ((lum-average_luma)*12) * high_delta_factor / 1024; if (col > 12) col=12; col = 128 + (col+2) * 8; } else if (lum < average_luma) { /************************************** * LUM1 Lower than average luma * **************************************/ col = ((average_luma-lum)*12) * low_delta_factor / 1024; if (col > 12) col=12; col = 128 - (col+2) * 8; } if (col) col = ((col * 41) >> 8) + 38; unsigned int c = col | (col << 8); #define BP (*bp) #define MP (*mp) #define BN (*(bp + BMPPITCH/2)) #define MN (*(mp + BMPPITCH/2)) if (BP != 0 && BP != MP) { continue; } if (BN != 0 && BN != MN) { continue; } if ((MP & 0x80808080) || (MN & 0x80808080)) continue; MP = BP = c; MN = BN = c; #undef BP #undef MP #undef BN #undef MN } } // end of (y loop) /********************************** * commit statistics for next loop * **********************************/ total_luma = total_luma_tmp; highest_luma = highest_luma_tmp; lowest_luma = lowest_luma_tmp; total_pixels = total_pixels_tmp; /********************************** * Display average, min and max * **********************************/ bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), os.x0 + os.x_ex/2 - font_med.width*7, os.y_max - os.off_169 - 47, "Average = %03d",average_luma); bmp_printf( FONT(FONT_MED,COLOR_CYAN, COLOR_BLACK), os.x0, os.y_max - os.off_169 - 47, "MIN = %03d",lowest_luma); bmp_printf( FONT(FONT_MED,COLOR_YELLOW, COLOR_BLACK), os.x_max - font_med.width*9, os.y_max - os.off_169 - 47, "%03d = MAX",highest_luma); bmp_printf( FONT(FONT_MED,COLOR_WHITE, COLOR_BLACK), os.x0 + os.x_ex/2 - font_med.width*7, os.y_max - os.off_169 - 27, "Accuracy=%03d%%",((255-(highest_luma-lowest_luma))*99 )/255 ); bmp_printf( FONT(FONT_MED,COLOR_CYAN, COLOR_BLACK), os.x0, os.y_max - os.off_169 - 27, "delta %03d", COERCE(average_luma - lowest_luma, 0, 255)); bmp_printf( FONT(FONT_MED, COLOR_YELLOW, COLOR_BLACK), os.x_max - font_med.width*9, os.y_max - os.off_169 - 27, "%03d delta", COERCE(highest_luma - average_luma, 0, 255)); msleep(10); // don't kill the battery :) } /* end of green_screen_step() */
static bool expose_event (RobWidget* rw, cairo_t* cr, cairo_rectangle_t *ev) { BITui* ui = (BITui*)GET_HANDLE(rw); cairo_rectangle (cr, ev->x, ev->y, ev->width, ev->height); cairo_clip (cr); const int ww = rw->area.width; const int hh = rw->area.height; CairoSetSouerceRGBA(c_g30); cairo_rectangle (cr, 0, 0, ww, hh); cairo_fill (cr); if (!ui->m0_faceplate) { gen_faceplate (ui, ww, hh); } const int spc = (int) floorf ((ww - 28) / 28.) & ~1; const int rad = ceilf (spc * .75); const int x0r = rint (ww * .5 + 12 * spc); const int xpr = rint (ww * .5 - 13 * spc); const int spc_s = (int) floorf (ww / 45.) & ~1; const int rad_s = ceilf (spc_s * .75); const int x0r_s = ww * .5 + 20 * spc_s; const int y0 = hh - 60 - rad_s - spc; const int y0_s = hh - 20 - rad_s; const int y0_g = 10; const int y1_g = y0 - 4; const int yh_g = y1_g - y0_g; // draw distribution if ((int)ui->integration_spl == ui->f_zero) { // all blank draw_bit_dist (cr, xpr, y0_g, rad, yh_g, -1); for (int k = 0; k < 23; ++k) { const float xp = x0r - rintf (spc * (.5 * (k / 8) + k)); draw_bit_dist (cr, xp, y0_g, rad, yh_g, -1); } } else { const float scnt = ui->integration_spl; draw_bit_dist (cr, xpr, y0_g, rad, yh_g, ui->f_pos / scnt); for (int k = 0; k < 23; ++k) { const float xp = x0r - rintf (spc * (.5 * (k / 8) + k)); const float v = ui->flt[k + BIM_DSET] / scnt; draw_bit_dist (cr, xp, y0_g, rad, yh_g, v); } } cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_set_source_surface(cr, ui->m0_faceplate, 0, 0); cairo_paint (cr); /* quick glance boxes */ // sign - bit draw_bit_box (ui, cr, xpr, y0, rad, -1, ui->f_pos); // "+" sign const float mid = .5 + rintf (spc * .75 * .5); const float span = ceilf (spc * .75 * .2); CairoSetSouerceRGBA(c_wht); cairo_set_line_width (cr, 1); cairo_move_to (cr, xpr + mid, y0 + mid - span); cairo_line_to (cr, xpr + mid, y0 + mid + span); cairo_stroke (cr); cairo_move_to (cr, xpr + mid - span, y0 + mid); cairo_line_to (cr, xpr + mid + span, y0 + mid); cairo_stroke (cr); // mantissa for (int k = 0; k < 23; ++k) { const float xp = x0r - rintf (spc * (.5 * (k / 8) + k)); draw_bit_box (ui, cr, xp, y0, rad, -1, ui->flt[k + BIM_DSET]); } // magnitude for (int k = 0; k < 40; ++k) { const int o = k + 118; const float xp = .5 * (k / 8) + k; draw_bit_box (ui, cr, x0r_s - rintf (xp * spc_s), y0_s, rad_s, ui->flt[o + BIM_DHIT], ui->flt[o + BIM_DONE]); } if (ui->integration_spl == 0) { cairo_set_source_rgba (cr, 0, 0, 0, .6); cairo_rectangle (cr, 0, 0, ww, hh); cairo_fill (cr); write_text_full (cr, "<markup><b>No data available.</b></markup>", FONT(FONT_S), rintf(ww * .5f), rintf(hh * .5f), 0, 2, c_wht); } else if (ui->integration_spl >= 2147483647) { cairo_set_source_rgba (cr, .9, .9, .9, .5); cairo_rectangle (cr, 0, 0, ww, hh); cairo_fill (cr); write_text_full (cr, "<markup>Reached <b>2<sup><small>31</small></sup> sample limit.\nData acquisition suspended.</b></markup>", FONT(FONT_S), rintf(ww * .5f), rintf(hh * .5f), 0, 2, c_blk); } else if ((int)ui->integration_spl == ui->f_zero) { // all blank write_text_full (cr, "<markup><b>All samples are zero.</b></markup>", FONT(FONT_S), rintf(ww * .5f), rintf(y0_g + yh_g * .5f), 0, 2, c_wht); } return TRUE; }
static void gen_faceplate (BITui* ui, const int ww, const int hh) { assert(!ui->m0_faceplate); ui->m0_faceplate = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ww, hh); cairo_t* cr = cairo_create (ui->m0_faceplate); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); const int spc = (int) floorf ((ww - 28) / 28.) & ~1; const int rad = ceilf (spc * .75); const int mid = rint (spc * .75 * .5); const int x0r = rint (ww * .5 + 12 * spc); const int xpr = rint (ww * .5 - 13 * spc); const int spc_s = (int) floorf (ww / 45.) & ~1; const int rad_s = ceilf (spc_s * .75); const int x0r_s = ww * .5 + 20 * spc_s; const int y0 = hh - 60 - rad_s - spc; const int y0_s = hh - 20 - rad_s; const int y0_g = 10; const int y1_g = y0 - 4; const int yh_g = y1_g - y0_g; // grid & annotations -- TODO statically allocate surface const float x0_g = xpr - 2; const float x1_b = x0r + rad + 2; const float x1_g = x1_b + mid + 2; const float yc_g = rintf (y0_g + .5 * yh_g); const float y6_g = rintf (y0_g + yh_g * 2. / 3.); const float y3_g = rintf (y0_g + yh_g / 3.); cairo_rectangle (cr, x1_b, y0_g, mid, y3_g); cairo_set_source_rgba (cr, .8, .5, .1, 1.0); cairo_fill (cr); cairo_rectangle (cr, x1_b, y3_g, mid, y6_g - y3_g); cairo_set_source_rgba (cr, .1, .9, .1, 1.0); cairo_fill (cr); cairo_rectangle (cr, x1_b, y6_g, mid, y1_g - y6_g); cairo_set_source_rgba (cr, .1, .6, .9, 1.0); cairo_fill (cr); cairo_set_line_width (cr, 2); cairo_move_to (cr, x1_b, y0_g); cairo_line_to (cr, x1_b + mid, y0_g); cairo_set_source_rgba (cr, .9, .0, .0, 1.0); cairo_stroke (cr); cairo_move_to (cr, x1_b, y0_g + yh_g); cairo_line_to (cr, x1_b + mid, y0_g + yh_g); cairo_set_source_rgba (cr, .0, .0, .9, 1.0); cairo_stroke (cr); CairoSetSouerceRGBA(c_g80); cairo_set_line_width (cr, 1); cairo_save (cr); double dash = 1; cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT); cairo_set_dash (cr, &dash, 1, 0); cairo_move_to (cr, x0_g, y0_g - .5); cairo_line_to (cr, x1_b, y0_g - .5); cairo_stroke (cr); cairo_move_to (cr, x0_g, .5 + yc_g); cairo_line_to (cr, x0_g + spc + 4, .5 + yc_g); cairo_stroke (cr); cairo_move_to (cr, x0_g, .5 + y6_g); cairo_line_to (cr, x1_b, .5 + y6_g); cairo_stroke (cr); cairo_move_to (cr, x0_g, .5 + y3_g); cairo_line_to (cr, x1_b, .5 + y3_g); cairo_stroke (cr); cairo_move_to (cr, x0_g, y1_g + .5); cairo_line_to (cr, x1_b, y1_g + .5); cairo_stroke (cr); cairo_restore (cr); cairo_move_to (cr, 1.5 + rintf (x0r_s - 33 * spc_s), y0_s - 1.5); cairo_line_to (cr, 1.5 + rintf (x0r_s - 33 * spc_s), y0_s + rad_s + 3.5); cairo_line_to (cr, .5 + rintf (x0r_s - 35.5 * spc_s), y0_s + rad_s + 3.5); cairo_stroke (cr); write_text_full (cr, ">1.0", FONT(FONT_M), x0r_s - 33.0 * spc_s, hh - 2, 0, 4, c_wht); write_text_full (cr, "<markup>2<small><sup>-32</sup></small></markup>", FONT(FONT_M), x0r_s + 0.5 * spc_s, hh - 2, 0, 5, c_wht); write_text_full (cr, "<markup>2<small><sup>-24</sup></small></markup>", FONT(FONT_M), x0r_s - 8.0 * spc_s, hh - 2, 0, 5, c_wht); write_text_full (cr, "<markup>2<small><sup>-16</sup></small></markup>", FONT(FONT_M), x0r_s - 16.5 * spc_s, hh - 2, 0, 5, c_wht); write_text_full (cr, "<markup>2<small><sup>-8</sup></small></markup>", FONT(FONT_M), x0r_s - 25.0 * spc_s, hh - 2, 0, 5, c_wht); write_text_full (cr, "<markup>2<small><sup>7</sup></small></markup>", FONT(FONT_M), x0r_s - 40.5 * spc_s, hh - 2, 0, 5, c_wht); write_text_full (cr, "% time bit is set", FONT(FONT_M), x1_g, yc_g, -.5 * M_PI, 8, c_wht); write_text_full (cr, "100%", FONT(FONT_M), x0_g - 2, y0_g, 0, 1, c_wht); write_text_full (cr, "50%", FONT(FONT_M), x0_g - 2, yc_g, 0, 1, c_wht); write_text_full (cr, "0%", FONT(FONT_M), x0_g - 2, y1_g, 0, 1, c_wht); // sep int ysep = .5 * (y0 + rad + y0_s); CairoSetSouerceRGBA(c_g60); cairo_move_to (cr, 15, ysep + .5); cairo_line_to (cr, ww - 30 , ysep + .5); cairo_stroke (cr); write_text_full (cr, "Sign & Mantissa (23bit significand)", FONT(FONT_S), ww * .5, ysep - 2, 0, 5, c_wht); write_text_full (cr, "Full Scale", FONT(FONT_S), ww * .5, ysep + 3, 0, 8, c_wht); write_text_full (cr, ui->nfo, FONT(FONT_M), 2, hh -2, 1.5 * M_PI, 9, c_gry); cairo_destroy (cr); }
int main(int argc, char** argv) { /* Check command arguments */ if(argc != 3) { printf("usage: %s RB_DRIVER FONT\n", argv[0]); return -1; } const char* driver_name = argv[1]; const char* font_name = argv[2]; FILE* file = fopen(driver_name, "r"); if(!file) { fprintf(stderr, "Invalid driver %s\n", driver_name); return -1; } fclose(file); file = fopen(font_name, "r"); if(!file) { fprintf(stderr, "Invalid font name %s\n", font_name); return -1; } fclose(file); /* Spawn a drawable windows */ struct wm_device* device = NULL; struct wm_window* window = NULL; const struct wm_window_desc win_desc = { .width = 640, .height = 480, .fullscreen = false }; WM(create_device(NULL, &device)); WM(create_window(device, &win_desc, &window)); /* Create a render backend */ struct rbi rbi; struct rb_context* rb_ctxt = NULL; CHECK(rbi_init(driver_name, &rbi), 0); RBI(&rbi, create_context(NULL, &rb_ctxt)); /* Load font resource */ struct font_system* font_sys = NULL; struct font_rsrc* font_rsrc = NULL; bool is_font_scalable = false; int line_space = 0; FONT(system_create(NULL, &font_sys)); FONT(rsrc_create(font_sys, font_name, &font_rsrc)); FONT(rsrc_get_line_space(font_rsrc, &line_space)); FONT(rsrc_is_scalable(font_rsrc, &is_font_scalable)); if(is_font_scalable) { FONT(rsrc_set_size(font_rsrc, 24, 24)); } /* Build x charset description */ int glyph_min_width = INT_MAX; const wchar_t* charset = L"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" L" &~\"#'{([-|`_\\^@)]=}+$%*,?;.:/!<>"; const size_t charset_len = wcslen(charset); size_t i = 0; struct lp_font_glyph_desc lp_font_glyph_desc_list[512]; unsigned char* glyph_bitmap_list[512]; ASSERT(charset_len <= 512); for(i = 0; i < charset_len; ++i) { struct font_glyph_desc font_glyph_desc; struct font_glyph* font_glyph = NULL; int width = 0; int height = 0; int Bpp = 0; FONT(rsrc_get_glyph(font_rsrc, charset[i], &font_glyph)); FONT(glyph_get_desc(font_glyph, &font_glyph_desc)); glyph_min_width = MIN(font_glyph_desc.width, glyph_min_width); lp_font_glyph_desc_list[i].width = font_glyph_desc.width; lp_font_glyph_desc_list[i].character = font_glyph_desc.character; lp_font_glyph_desc_list[i].bitmap_left = font_glyph_desc.bbox.x_min; lp_font_glyph_desc_list[i].bitmap_top = font_glyph_desc.bbox.y_min; FONT(glyph_get_bitmap(font_glyph, true, &width, &height, &Bpp, NULL)); if(width && height ) { glyph_bitmap_list[i] = MEM_CALLOC (&mem_default_allocator, (size_t)(width*height), (size_t)Bpp); NCHECK(glyph_bitmap_list[i], NULL); FONT(glyph_get_bitmap (font_glyph, true, &width, &height, &Bpp, glyph_bitmap_list[i])); } lp_font_glyph_desc_list[i].bitmap.width = width; lp_font_glyph_desc_list[i].bitmap.height = height; lp_font_glyph_desc_list[i].bitmap.bytes_per_pixel = Bpp; lp_font_glyph_desc_list[i].bitmap.buffer = glyph_bitmap_list[i]; FONT(glyph_ref_put(font_glyph)); } /* Create the lp system and font */ struct lp* lp = NULL; struct lp_font* lp_font = NULL; LP(create(&rbi, rb_ctxt, NULL, &lp)); LP(font_create(lp, &lp_font)); LP(font_set_data (lp_font, line_space, (int)charset_len, lp_font_glyph_desc_list)); /* Create the printer */ struct lp_printer* lp_printer = NULL; LP(printer_create(lp, &lp_printer)); LP(printer_set_font(lp_printer, lp_font)); LP(printer_set_viewport(lp_printer, 0, 0, win_desc.width, win_desc.height)); enum wm_state esc = WM_STATE_UNKNOWN; do { int cur[2] = { 0, 0 }; RBI(&rbi, clear (rb_ctxt, RB_CLEAR_COLOR_BIT, (float[]){0.05f, 0.05f, 0.05f}, 0.f, 0)); LP(printer_print_wstring (lp_printer, 50, 70, L">$ ", (float[]){0.f, 1.f, 0.f}, cur+0, cur+1)); LP(printer_print_wstring (lp_printer, cur[0], cur[1], L"Hello", (float[]){1.f, 1.f, 1.f}, cur+0, cur+1));
void lv_rec_start() { int yPos = 3; lv_rec_data_t data; lv_rec_save_data_t save_data; /* set all values to zero */ memset(&data, 0x00, sizeof(lv_rec_data_t)); memset(&save_data, 0x00, sizeof(lv_rec_save_data_t)); /* menu options */ data.options.frameSkip = lv_rec_frame_skip; data.options.rawMode = lv_rec_raw_mode; data.options.singleFile = lv_rec_single_file; data.options.linesToSkip = lv_rec_line_skip; /* this causes the function to hang!? */ if(data.options.rawMode) { //~ bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "Make sure you ran call('lv_save_raw')"); call("lv_save_raw", 1); msleep(200); raw_update_params(); } /* get maximum available memory */ bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "Allocating memory"); data.chunkData.memSuite = shoot_malloc_suite(0); if(!data.chunkData.memSuite) { bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "Failed to allocate memory"); return; } unsigned int allocatedMemory = lv_rec_get_memsize(data.chunkData.memSuite); bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "Allocated %d MiB", allocatedMemory/1024/1024); save_data.options = data.options; save_data.chunkData = data.chunkData; /* ensure the selected profile is applied, dont rely on menu painting to do this for us */ lv_rec_update_preset(&save_data); /* file sequence number */ int start_number = 0; /* set file pre/suffixes */ if(data.options.singleFile) { strcpy(save_data.filePrefix, "M"); } else { strcpy(save_data.filePrefix, "I"); } if(data.options.rawMode) { strcpy(save_data.fileSuffix, "RAW"); } else { strcpy(save_data.fileSuffix, "YUV"); } /* get first available file name */ for (start_number = 0 ; start_number < 1000; start_number++) { snprintf(save_data.fileName, sizeof(save_data.fileName), "%s%s%07d.%s", MODULE_CARD_DRIVE, save_data.filePrefix, start_number, save_data.fileSuffix); uint32_t size; if( FIO_GetFileSize( save_data.fileName, &size ) != 0 ) break; if (size == 0) break; } if(data.options.rawMode) { /* copy 8 bytes per transfer */ data.dmaFlags = 0x20001000; /* set block size for EDMAC and update cropping */ save_data.frameSize = (save_data.frameSizeReal + 4095) & (~4095); /* the data at bottom are trash remains caused by EDMAC block size, drop it */ save_data.bottomDrop = save_data.frameSize - save_data.frameSizeReal; /* mem copy connection */ data.dmaCopyChannel = 0x19; data.dmaCopyConn = 0x06; data.dmaSourceConn = 0x06; data.dmaFlags = 0; /* create a memory suite that consists of lv_save_raw raw buffer */ data.memCopySuite = CreateMemorySuite((void*)shamem_read(RAW_LV_EDMAC), save_data.frameSize, 0); PackMem_RegisterEDmacCompleteCBRForMemorySuite(data.dmaCopyChannel, &complete_cbr, 0); PackMem_RegisterEDmacPopCBRForMemorySuite(data.dmaCopyChannel, &pop_cbr, 0); } else { /* copy 2 byte per transfer */ data.dmaFlags = 0x20000000; /* read from YUV connection */ data.dmaSourceConn = 0x1B; /* no special treatment, save the exact size */ save_data.frameSize = save_data.frameSizeReal; save_data.bottomDrop = 0; } /* who wants to save more? */ data.maxFrames = 200000; data.dmaChannel = 0x11; data.maxFramesBufferable = allocatedMemory / save_data.frameSize; data.frameSize = save_data.frameSize; /* EDMAC callbacks */ PackMem_RegisterEDmacCompleteCBRForMemorySuite(data.dmaChannel, &complete_cbr, 1); PackMem_RegisterEDmacPopCBRForMemorySuite(data.dmaChannel, &pop_cbr, 1); /* this enables recording */ lv_rec_state = &data; bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "Ready, waiting for first frame"); int wait_loops = 0; int t0 = get_ms_clock_value(); while(!data.finished || (lv_rec_ring_mode && (data.capturedFrames > data.savedFrames))) { if(lv_rec_ring_mode) { if(data.capturedFrames > data.savedFrames) { if(data.options.singleFile) { if(!save_data.handle) { snprintf(save_data.fileName, sizeof(save_data.fileName), "%s%s%07d.%s", MODULE_CARD_DRIVE, save_data.filePrefix, start_number, save_data.fileSuffix); bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * (yPos+1), "Saving to '%s'", save_data.fileName); save_data.handle = FIO_CreateFileEx(save_data.fileName); save_data.handleWritten = 0; } if(save_data.handle) { /* save or skip, depending on skip counter */ save_data.handleWritten += lv_rec_save_frame(save_data.handle, &save_data, (data.savedFrames % data.options.frameSkip) != 0); } else { yPos++; bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "Failed to save file"); break; } /* when reaching 2GiB, create another file */ if(save_data.handleWritten > ((2UL * 1024UL) - 10UL) * 1024UL * 1024UL) { yPos++; bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "Creating next file"); FIO_CloseFile(save_data.handle); save_data.handle = NULL; lv_rec_update_suffix(&save_data); save_data.fileSeqNum++; } data.savedFrames++; } else { if((data.savedFrames % data.options.frameSkip) == 0) { snprintf(save_data.fileName, sizeof(save_data.fileName), "%s%s%07d.%s", MODULE_CARD_DRIVE, save_data.filePrefix, start_number + (data.savedFrames / data.options.frameSkip), save_data.fileSuffix); bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * (yPos+1), "Saving '%s'", save_data.fileName); save_data.handle = FIO_CreateFileEx(save_data.fileName); save_data.handleWritten = 0; if(save_data.handle) { save_data.handleWritten += lv_rec_save_frame(save_data.handle, &save_data, 0); save_data.frameCount = 1; lv_rec_save_footer(save_data.handle, &save_data); FIO_CloseFile(save_data.handle); save_data.handle = NULL; } else { yPos++; bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "Failed to save file"); break; } } else { /* do not save data, just skip buffers */ lv_rec_save_frame(save_data.handle, &save_data, 1); } data.savedFrames++; } /* reset timeout counter */ wait_loops = 0; } else { msleep(10); if(wait_loops++ > 25) { yPos++; bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos++, "No more data, aborting."); lv_rec_state = NULL; PackMem_PopEDmacForMemorySuite(data.dmaChannel); data.finished = 1; } } } else { msleep(200); } int t1 = get_ms_clock_value(); int speed = (save_data.handleWritten / 1024) * 10 / (t1 - t0) * 1000 / 1024; // MB/s x10 bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * yPos, "%s, %d buffered, %d saved, %d.%d MB/s ", (data.finished?"Finished":(data.running?"Recording":"Wait.....")), data.capturedFrames - data.savedFrames, data.savedFrames / data.options.frameSkip, speed/10, speed%10 ); } yPos++; if(lv_rec_ring_mode) { if(data.options.singleFile) { save_data.frameCount = data.capturedFrames; lv_rec_save_footer(save_data.handle, &save_data); FIO_CloseFile(save_data.handle); } } else { bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * ++yPos, "Saving"); if(data.options.singleFile) { /* save one single file */ bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * ++yPos, "Saved: 0x%08X", exmem_save_buffer(data.chunkData.memSuite, "DATA.BIN")); } } bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 30, 20 * ++yPos, "Recording finished"); shoot_free_suite(data.chunkData.memSuite); /* the dummy suite that points to lv_save_raw buffer */ if(data.memCopySuite) { DeleteMemorySuite(data.memCopySuite); } }
void display_lens_hyperfocal() { unsigned menu_font = MENU_FONT; unsigned font = FONT(FONT_MED, FONT_FG(menu_font), FONT_BG(menu_font)); unsigned height = fontspec_height( font ); int x = 10; int y = 315; y += 10; y += height; if (!lens_info.name[0]) { y += height; bmp_printf( font, x, y, "Lens: manual (without chip)." ); return; } bmp_printf( font, x, y, "Lens: %s, %dmm f/%d.%d", lens_info.name, lens_info.focal_len, lens_info.aperture / 10, lens_info.aperture % 10 ); if (!lv || !lens_info.focus_dist) { y += height; bmp_printf( font, x, y, "Hyperfocal: %s", lens_info.hyperfocal ? lens_format_dist( lens_info.hyperfocal ) : "unknown, go to LiveView to get focal length" ); y += height; bmp_printf( font, x, y, "Your lens did not report focus distance" ); return; } y += height; bmp_printf( font, x, y, "Focus dist: %s", lens_info.focus_dist == 0xFFFF ? " Infty" : lens_format_dist( lens_info.focus_dist * 10 ) ); y += height; bmp_printf( font, x, y, "Hyperfocal: %s", lens_format_dist( lens_info.hyperfocal ) ); x += 300; y -= height; bmp_printf( font, x, y, "DOF Near: %s", lens_format_dist( lens_info.dof_near ) ); y += height; bmp_printf( font, x, y, "DOF Far: %s", lens_info.dof_far >= 1000*1000 ? " Infty" : lens_format_dist( lens_info.dof_far ) ); }