| 1 | #include "camera.h" |
|---|
| 2 | #include "stdlib.h" |
|---|
| 3 | #include "keyboard.h" |
|---|
| 4 | #include "platform.h" |
|---|
| 5 | #include "histogram.h" |
|---|
| 6 | #include "core.h" |
|---|
| 7 | #include "lang.h" |
|---|
| 8 | #include "conf.h" |
|---|
| 9 | #include "gui.h" |
|---|
| 10 | #include "gui_draw.h" |
|---|
| 11 | #include "gui_lang.h" |
|---|
| 12 | #include "gui_batt.h" |
|---|
| 13 | #include "gui_space.h" |
|---|
| 14 | #include "gui_grid.h" |
|---|
| 15 | #include "gui_osd.h" |
|---|
| 16 | |
|---|
| 17 | //------------------------------------------------------------------- |
|---|
| 18 | typedef struct { |
|---|
| 19 | int title; |
|---|
| 20 | OSD_pos *pos; |
|---|
| 21 | OSD_pos size; |
|---|
| 22 | } OSD_elem; |
|---|
| 23 | |
|---|
| 24 | static OSD_elem osd[]={ |
|---|
| 25 | {LANG_OSD_LAYOUT_EDITOR_HISTO, &conf.histo_pos, {HISTO_WIDTH+2, HISTO_HEIGHT} }, |
|---|
| 26 | {LANG_OSD_LAYOUT_EDITOR_DOF_CALC, &conf.dof_pos, {23*FONT_WIDTH, 2*FONT_HEIGHT} }, |
|---|
| 27 | {LANG_OSD_LAYOUT_EDITOR_STATES, &conf.mode_state_pos, {12*FONT_WIDTH, 4*FONT_HEIGHT} }, |
|---|
| 28 | {LANG_OSD_LAYOUT_EDITOR_RAW, &conf.mode_raw_pos, {7*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 29 | {LANG_OSD_LAYOUT_EDITOR_MISC, &conf.values_pos, {9*FONT_WIDTH, 9*FONT_HEIGHT} }, |
|---|
| 30 | {LANG_OSD_LAYOUT_EDITOR_BAT_ICON, &conf.batt_icon_pos, {28, 12} }, |
|---|
| 31 | {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_icon_pos, {23, 15} }, |
|---|
| 32 | {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_ver_pos, {3, 50} }, |
|---|
| 33 | {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_hor_pos, {50, 3} }, |
|---|
| 34 | {LANG_OSD_LAYOUT_EDITOR_BAT_TEXT, &conf.batt_txt_pos, {5*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 35 | {LANG_OSD_LAYOUT_EDITOR_SPACE_TEXT, &conf.space_txt_pos, {5*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 36 | {LANG_OSD_LAYOUT_EDITOR_CLOCK, &conf.clock_pos, {5*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 37 | {LANG_OSD_LAYOUT_EDITOR_TEMP, &conf.temp_pos, {9*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 38 | {LANG_OSD_LAYOUT_EDITOR_VIDEO, &conf.mode_video_pos, {9*FONT_WIDTH, 4*FONT_HEIGHT} }, |
|---|
| 39 | {LANG_OSD_LAYOUT_EDITOR_EV, &conf.mode_ev_pos, {12*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 40 | #if CAM_EV_IN_VIDEO |
|---|
| 41 | {LANG_OSD_LAYOUT_EDITOR_EV_VIDEO, &conf.ev_video_pos, {70,24}}, |
|---|
| 42 | #endif |
|---|
| 43 | {0} |
|---|
| 44 | }; |
|---|
| 45 | static int osd_to_draw; |
|---|
| 46 | static int curr_item; |
|---|
| 47 | static char osd_buf[64]; |
|---|
| 48 | static char osd_buf2[10]; |
|---|
| 49 | static char osd_buf3[10]; |
|---|
| 50 | static char osd_buf4[10]; |
|---|
| 51 | |
|---|
| 52 | static int step; |
|---|
| 53 | |
|---|
| 54 | // Width (in pixels) of half-shoot Canon OSD area of the screen buffer, for restore during |
|---|
| 55 | // Zebra draw, to limit RAM usage of zebra. Only these border areas are stored in RAM. |
|---|
| 56 | // Only top and bottom are restored, not left&right. |
|---|
| 57 | #define ZEBRA_CANONOSD_BORDER_RESTORE 1 |
|---|
| 58 | #define ZFIX_TOP 29 |
|---|
| 59 | #define ZFIX_BOTTOM 30 |
|---|
| 60 | |
|---|
| 61 | static unsigned char *img_buf, *scr_buf; |
|---|
| 62 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 63 | static unsigned char *cur_buf_top, *cur_buf_bot; |
|---|
| 64 | #else |
|---|
| 65 | static unsigned char *cur_buf; |
|---|
| 66 | #endif |
|---|
| 67 | static int cur_buf_size; |
|---|
| 68 | static int timer = 0; |
|---|
| 69 | static char *buf = NULL; |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | static DOF_TYPE dof; |
|---|
| 73 | static EXPO_TYPE expo; |
|---|
| 74 | |
|---|
| 75 | #define OSD_STATE 0 |
|---|
| 76 | #define OSD_MISC 1 |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | //------------------------------------------------------------------- |
|---|
| 80 | void gui_osd_init() { |
|---|
| 81 | osd_to_draw = 1; |
|---|
| 82 | curr_item = 0; |
|---|
| 83 | step = 10; |
|---|
| 84 | draw_restore(); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | //------------------------------------------------------------------- |
|---|
| 88 | void gui_osd_draw() { |
|---|
| 89 | if (osd_to_draw) { |
|---|
| 90 | int i; |
|---|
| 91 | draw_restore(); |
|---|
| 92 | gui_osd_draw_histo(); |
|---|
| 93 | gui_osd_draw_dof(); |
|---|
| 94 | gui_batt_draw_osd(); |
|---|
| 95 | gui_space_draw_osd(); |
|---|
| 96 | gui_osd_draw_state(); |
|---|
| 97 | gui_osd_draw_raw_info(); |
|---|
| 98 | gui_osd_draw_values(); |
|---|
| 99 | gui_osd_draw_clock(0,0,0); |
|---|
| 100 | gui_osd_draw_temp(); |
|---|
| 101 | #if CAM_EV_IN_VIDEO |
|---|
| 102 | gui_osd_draw_ev_video(1); |
|---|
| 103 | #endif |
|---|
| 104 | for (i=1; i<=2; ++i) { |
|---|
| 105 | draw_rect((osd[curr_item].pos->x>=i)?osd[curr_item].pos->x-i:0, (osd[curr_item].pos->y>=i)?osd[curr_item].pos->y-i:0, |
|---|
| 106 | osd[curr_item].pos->x+osd[curr_item].size.x+i-1, osd[curr_item].pos->y+osd[curr_item].size.y+i-1, |
|---|
| 107 | COLOR_GREEN); |
|---|
| 108 | } |
|---|
| 109 | sprintf(osd_buf, " %s: x:%d y:%d s:%d ", lang_str(osd[curr_item].title), osd[curr_item].pos->x, osd[curr_item].pos->y, step); |
|---|
| 110 | draw_string(0, (osd[curr_item].pos->x<strlen(osd_buf)*FONT_WIDTH+4 && osd[curr_item].pos->y<FONT_HEIGHT+4)?screen_height-FONT_HEIGHT:0, |
|---|
| 111 | osd_buf, MAKE_COLOR(COLOR_RED, COLOR_WHITE)); |
|---|
| 112 | osd_to_draw = 0; |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | //------------------------------------------------------------------- |
|---|
| 117 | void gui_osd_kbd_process() { |
|---|
| 118 | switch (kbd_get_autoclicked_key()) { |
|---|
| 119 | case KEY_LEFT: |
|---|
| 120 | if (osd[curr_item].pos->x > 0) { |
|---|
| 121 | osd[curr_item].pos->x-=(osd[curr_item].pos->x>=step)?step:osd[curr_item].pos->x; |
|---|
| 122 | osd_to_draw = 1; |
|---|
| 123 | } |
|---|
| 124 | break; |
|---|
| 125 | case KEY_RIGHT: |
|---|
| 126 | if (osd[curr_item].pos->x < screen_width-osd[curr_item].size.x) { |
|---|
| 127 | osd[curr_item].pos->x+=(screen_width-osd[curr_item].size.x-osd[curr_item].pos->x>step)?step:screen_width-osd[curr_item].size.x-osd[curr_item].pos->x; |
|---|
| 128 | osd_to_draw = 1; |
|---|
| 129 | } else |
|---|
| 130 | osd[curr_item].pos->x = screen_width-osd[curr_item].size.x; |
|---|
| 131 | break; |
|---|
| 132 | case KEY_UP: |
|---|
| 133 | if (osd[curr_item].pos->y > 0) { |
|---|
| 134 | osd[curr_item].pos->y-=(osd[curr_item].pos->y>=step)?step:osd[curr_item].pos->y; |
|---|
| 135 | osd_to_draw = 1; |
|---|
| 136 | } |
|---|
| 137 | break; |
|---|
| 138 | case KEY_DOWN: |
|---|
| 139 | if (osd[curr_item].pos->y < screen_height-osd[curr_item].size.y) { |
|---|
| 140 | osd[curr_item].pos->y+=(screen_height-osd[curr_item].size.y-osd[curr_item].pos->y>step)?step:screen_height-osd[curr_item].size.y-osd[curr_item].pos->y; |
|---|
| 141 | osd_to_draw = 1; |
|---|
| 142 | } else |
|---|
| 143 | osd[curr_item].pos->y = screen_height-osd[curr_item].size.y; |
|---|
| 144 | break; |
|---|
| 145 | case KEY_SET: |
|---|
| 146 | ++curr_item; |
|---|
| 147 | if (!osd[curr_item].pos) |
|---|
| 148 | curr_item = 0; |
|---|
| 149 | osd_to_draw = 1; |
|---|
| 150 | break; |
|---|
| 151 | case KEY_DISPLAY: |
|---|
| 152 | step=(step==1)?10:1; |
|---|
| 153 | osd_to_draw = 1; |
|---|
| 154 | break; |
|---|
| 155 | } |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | //------------------------------------------------------------------- |
|---|
| 159 | static void gui_osd_draw_single_histo(int hist, coord x, coord y, int small) { |
|---|
| 160 | register unsigned int i, v, threshold; |
|---|
| 161 | register color cl, cl_over, cl_bg=conf.histo_color>>8; |
|---|
| 162 | coord w=HISTO_WIDTH, h=HISTO_HEIGHT; |
|---|
| 163 | |
|---|
| 164 | switch (hist) { |
|---|
| 165 | case HISTO_R: |
|---|
| 166 | cl=COLOR_RED; |
|---|
| 167 | break; |
|---|
| 168 | case HISTO_G: |
|---|
| 169 | cl=COLOR_GREEN; |
|---|
| 170 | break; |
|---|
| 171 | case HISTO_B: |
|---|
| 172 | cl=((mode_get()&MODE_MASK) == MODE_REC)?0xDF:0xCC; |
|---|
| 173 | break; |
|---|
| 174 | case HISTO_RGB: |
|---|
| 175 | case HISTO_Y: |
|---|
| 176 | default: |
|---|
| 177 | cl=conf.histo_color; |
|---|
| 178 | break; |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | if (small) { |
|---|
| 182 | h>>=1; w>>=1; |
|---|
| 183 | for (i=0; i<w; ++i) { |
|---|
| 184 | threshold = (histogram[hist][i<<1]+histogram[hist][(i<<1)+1])>>2; |
|---|
| 185 | |
|---|
| 186 | for (v=1; v<h-1; ++v) |
|---|
| 187 | draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); |
|---|
| 188 | cl_over = (threshold==h && conf.show_overexp)?conf.histo_color2>>8:cl; |
|---|
| 189 | for (; v<h; ++v) |
|---|
| 190 | draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); |
|---|
| 191 | } |
|---|
| 192 | } else { |
|---|
| 193 | for (i=0; i<w; ++i) { |
|---|
| 194 | threshold = histogram[hist][i]; |
|---|
| 195 | |
|---|
| 196 | for (v=1; v<h-3; ++v) |
|---|
| 197 | draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); |
|---|
| 198 | cl_over = (threshold==h && conf.show_overexp)?conf.histo_color2>>8:cl; |
|---|
| 199 | for (; v<h; ++v) |
|---|
| 200 | draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); |
|---|
| 201 | } |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | draw_rect(x, y, x+1+w, y+h, conf.histo_color2&0xFF); |
|---|
| 205 | //Vertical Lines |
|---|
| 206 | if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+w)*i/5, y, x+(1+w)*i/5, y+h, conf.histo_color2&0xFF); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | //------------------------------------------------------------------- |
|---|
| 210 | // free and NULL zebra buffers. free(NULL) is always OK. |
|---|
| 211 | static void gui_osd_zebra_free() { |
|---|
| 212 | free(buf); |
|---|
| 213 | buf=NULL; |
|---|
| 214 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 215 | free(cur_buf_top); |
|---|
| 216 | cur_buf_top=NULL; |
|---|
| 217 | free(cur_buf_bot); |
|---|
| 218 | cur_buf_bot=NULL; |
|---|
| 219 | #else |
|---|
| 220 | free(cur_buf); |
|---|
| 221 | cur_buf=NULL; |
|---|
| 222 | #endif |
|---|
| 223 | } |
|---|
| 224 | // prepare zebra resources, or free them |
|---|
| 225 | // returns 1 if zebra should be drawn |
|---|
| 226 | static int gui_osd_zebra_init(int show) { |
|---|
| 227 | if(show) { |
|---|
| 228 | if (!buf) { |
|---|
| 229 | timer = 0; |
|---|
| 230 | buf = malloc(screen_buffer_size); |
|---|
| 231 | scr_buf = vid_get_bitmap_fb(); |
|---|
| 232 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 233 | cur_buf_top = malloc(screen_buffer_width * ZFIX_TOP); |
|---|
| 234 | cur_buf_bot = malloc(screen_buffer_width * ZFIX_BOTTOM); |
|---|
| 235 | #else |
|---|
| 236 | cur_buf = malloc(screen_buffer_size); |
|---|
| 237 | #endif |
|---|
| 238 | // cleanup and disable zebra if any mallocs failed |
|---|
| 239 | if(!buf || |
|---|
| 240 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 241 | !cur_buf_top || |
|---|
| 242 | !cur_buf_bot |
|---|
| 243 | #else |
|---|
| 244 | !cur_buf |
|---|
| 245 | #endif |
|---|
| 246 | ) { |
|---|
| 247 | gui_osd_zebra_free(); |
|---|
| 248 | } |
|---|
| 249 | } |
|---|
| 250 | } |
|---|
| 251 | else { |
|---|
| 252 | if(buf) // if zebra was previously on, restore |
|---|
| 253 | draw_restore(); |
|---|
| 254 | |
|---|
| 255 | gui_osd_zebra_free(); |
|---|
| 256 | } |
|---|
| 257 | return (buf != NULL); |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | //------------------------------------------------------------------- |
|---|
| 261 | static void draw_pixel_buffered(unsigned int offset, color cl) { |
|---|
| 262 | buf[offset] = cl; |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | //------------------------------------------------------------------- |
|---|
| 266 | int draw_guard_pixel() { |
|---|
| 267 | unsigned char* buffer1 = vid_get_bitmap_fb()+screen_buffer_size/2; |
|---|
| 268 | unsigned char* buffer2 = buffer1+screen_buffer_size; |
|---|
| 269 | int has_disappeared=0; |
|---|
| 270 | |
|---|
| 271 | if(*buffer1!=COLOR_GREEN) has_disappeared=1; |
|---|
| 272 | if(*buffer2!=COLOR_GREEN) has_disappeared=2; |
|---|
| 273 | *buffer1 = *buffer2 = COLOR_GREEN; |
|---|
| 274 | return has_disappeared; |
|---|
| 275 | } |
|---|
| 276 | |
|---|
| 277 | //------------------------------------------------------------------- |
|---|
| 278 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 279 | unsigned char get_cur_buf(unsigned int idx) { |
|---|
| 280 | unsigned int a; |
|---|
| 281 | |
|---|
| 282 | a=screen_buffer_size - screen_buffer_width * ZFIX_BOTTOM; |
|---|
| 283 | |
|---|
| 284 | if (idx < screen_buffer_width * ZFIX_TOP) return(cur_buf_top[idx]); |
|---|
| 285 | if (idx >= a && idx < screen_buffer_size) return(cur_buf_bot[idx - a]); |
|---|
| 286 | return (COLOR_TRANSPARENT); |
|---|
| 287 | } |
|---|
| 288 | #endif |
|---|
| 289 | //------------------------------------------------------------------- |
|---|
| 290 | static void gui_osd_draw_zebra_osd() { |
|---|
| 291 | switch (conf.zebra_draw_osd) { |
|---|
| 292 | case ZEBRA_DRAW_NONE: |
|---|
| 293 | break; |
|---|
| 294 | case ZEBRA_DRAW_OSD: |
|---|
| 295 | if (conf.show_osd) { |
|---|
| 296 | draw_set_draw_proc(draw_pixel_buffered); |
|---|
| 297 | if ((mode_get()&MODE_MASK) == MODE_REC) { |
|---|
| 298 | if (conf.show_dof != DOF_DONT_SHOW) gui_osd_calc_dof(); |
|---|
| 299 | if (conf.show_grid_lines) { |
|---|
| 300 | gui_grid_draw_osd(1); |
|---|
| 301 | } |
|---|
| 302 | if (conf.show_dof == DOF_SHOW_IN_DOF) { |
|---|
| 303 | gui_osd_draw_dof(); |
|---|
| 304 | } |
|---|
| 305 | if (conf.show_state) { |
|---|
| 306 | gui_osd_draw_state(); |
|---|
| 307 | } |
|---|
| 308 | if (conf.show_remaining_raw) { |
|---|
| 309 | gui_osd_draw_raw_info(); |
|---|
| 310 | } |
|---|
| 311 | if (conf.show_values) { |
|---|
| 312 | gui_osd_draw_values(); |
|---|
| 313 | } |
|---|
| 314 | } |
|---|
| 315 | gui_batt_draw_osd(); |
|---|
| 316 | gui_space_draw_osd(); |
|---|
| 317 | if (conf.show_clock) { |
|---|
| 318 | gui_osd_draw_clock(0,0,0); |
|---|
| 319 | } |
|---|
| 320 | if (conf.show_temp>0) { |
|---|
| 321 | gui_osd_draw_temp(); |
|---|
| 322 | } |
|---|
| 323 | draw_set_draw_proc(NULL); |
|---|
| 324 | } |
|---|
| 325 | /* no break here */ |
|---|
| 326 | case ZEBRA_DRAW_HISTO: |
|---|
| 327 | default: |
|---|
| 328 | if (conf.show_histo) { |
|---|
| 329 | draw_set_draw_proc(draw_pixel_buffered); |
|---|
| 330 | gui_osd_draw_histo(); |
|---|
| 331 | draw_set_draw_proc(NULL); |
|---|
| 332 | } |
|---|
| 333 | break; |
|---|
| 334 | } |
|---|
| 335 | } |
|---|
| 336 | |
|---|
| 337 | |
|---|
| 338 | //------------------------------------------------------------------- |
|---|
| 339 | int gui_osd_draw_zebra(int show) { |
|---|
| 340 | unsigned int v, s, x, y, f, over; |
|---|
| 341 | color cl_under=conf.zebra_color>>8, cl_over=conf.zebra_color&0xFF; |
|---|
| 342 | static int need_restore=0; |
|---|
| 343 | int viewport_height; |
|---|
| 344 | int mrec = ((mode_get()&MODE_MASK) == MODE_REC); |
|---|
| 345 | int zebra_drawn=0; |
|---|
| 346 | color cls[] = { |
|---|
| 347 | COLOR_TRANSPARENT, |
|---|
| 348 | (mrec)?0xDF:0xCC, |
|---|
| 349 | COLOR_GREEN, |
|---|
| 350 | (mrec)?COLOR_BLUE_LT:0x99, |
|---|
| 351 | COLOR_RED, |
|---|
| 352 | (mrec)?0x66:0xE2, |
|---|
| 353 | (mrec)?COLOR_YELLOW:0x66, |
|---|
| 354 | COLOR_BLACK |
|---|
| 355 | }; |
|---|
| 356 | |
|---|
| 357 | if (!gui_osd_zebra_init(show)) |
|---|
| 358 | return 0; |
|---|
| 359 | |
|---|
| 360 | if(timer==0) { |
|---|
| 361 | draw_guard_pixel(); |
|---|
| 362 | timer=1; |
|---|
| 363 | return 0; |
|---|
| 364 | } |
|---|
| 365 | if(timer==1) { |
|---|
| 366 | int ready; |
|---|
| 367 | static int n=0; |
|---|
| 368 | if (!mrec) ready=1; |
|---|
| 369 | else get_property_case(PROPCASE_SHOOTING, &ready, 4); |
|---|
| 370 | n=draw_guard_pixel(); // will be 0 in PLAY mode, should be 1 or 2 in REC mode. |
|---|
| 371 | if(!ready) return 0; |
|---|
| 372 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 373 | // rescue Canon OSD from scr_buf to cur_buf_top and _bot: |
|---|
| 374 | if (n==1) { |
|---|
| 375 | memcpy(cur_buf_top, scr_buf, screen_buffer_width*ZFIX_TOP); |
|---|
| 376 | memcpy(cur_buf_bot, scr_buf + screen_buffer_size - screen_buffer_width*ZFIX_BOTTOM, screen_buffer_width*ZFIX_BOTTOM); |
|---|
| 377 | } |
|---|
| 378 | else { |
|---|
| 379 | memcpy(cur_buf_top, scr_buf + screen_buffer_size, screen_buffer_width*ZFIX_TOP); |
|---|
| 380 | memcpy(cur_buf_bot, scr_buf + 2*screen_buffer_size - screen_buffer_width*ZFIX_BOTTOM, screen_buffer_width*ZFIX_BOTTOM); |
|---|
| 381 | } |
|---|
| 382 | #else |
|---|
| 383 | // rescue Canon OSD from cur_buf |
|---|
| 384 | if(n==1) memcpy(cur_buf, scr_buf, screen_buffer_size); |
|---|
| 385 | else memcpy(cur_buf, scr_buf+screen_buffer_size, screen_buffer_size); |
|---|
| 386 | #endif |
|---|
| 387 | } |
|---|
| 388 | ++timer; |
|---|
| 389 | // Try to get the best viewport buffer. In playmode its the _d one, in |
|---|
| 390 | // record mode we try to get the fast live one first |
|---|
| 391 | if (!mrec) { |
|---|
| 392 | img_buf = vid_get_viewport_fb_d(); |
|---|
| 393 | } |
|---|
| 394 | else { |
|---|
| 395 | img_buf = vid_get_viewport_live_fb(); |
|---|
| 396 | if( !img_buf ) { |
|---|
| 397 | img_buf = vid_get_viewport_fb(); |
|---|
| 398 | } |
|---|
| 399 | } |
|---|
| 400 | viewport_height = vid_get_viewport_height(); |
|---|
| 401 | switch (conf.zebra_mode) { |
|---|
| 402 | case ZEBRA_MODE_ZEBRA_1: |
|---|
| 403 | f = 4; |
|---|
| 404 | break; |
|---|
| 405 | case ZEBRA_MODE_ZEBRA_2: |
|---|
| 406 | f = 8; |
|---|
| 407 | break; |
|---|
| 408 | case ZEBRA_MODE_SOLID: |
|---|
| 409 | f = 1; |
|---|
| 410 | break; |
|---|
| 411 | case ZEBRA_MODE_BLINKED_1: |
|---|
| 412 | f = timer&1; |
|---|
| 413 | break; |
|---|
| 414 | case ZEBRA_MODE_BLINKED_3: |
|---|
| 415 | f = timer&4; |
|---|
| 416 | break; |
|---|
| 417 | case ZEBRA_MODE_BLINKED_2: |
|---|
| 418 | default: |
|---|
| 419 | f = timer&2; |
|---|
| 420 | break; |
|---|
| 421 | } |
|---|
| 422 | // if not in no-zebra phase of blink mode zebra, draw zebra to buf[] |
|---|
| 423 | if (f) { |
|---|
| 424 | int step_x, step_v; |
|---|
| 425 | over = 255-conf.zebra_over; |
|---|
| 426 | if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} |
|---|
| 427 | for (s=0, y=1, v=0; y<=viewport_height; ++y) { |
|---|
| 428 | for (x=0; x<screen_width; x+=step_x, s+=step_x, v+=step_v) { |
|---|
| 429 | register int yy, uu, vv; |
|---|
| 430 | int sel; |
|---|
| 431 | yy = img_buf[v+1]; |
|---|
| 432 | if (conf.zebra_multichannel) { |
|---|
| 433 | uu = (signed char)img_buf[v]; |
|---|
| 434 | vv = (signed char)img_buf[v+2]; |
|---|
| 435 | sel=0; |
|---|
| 436 | if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { |
|---|
| 437 | if (((yy<<12) + vv*5743 + 2048)>>12>over) sel = 4; // R |
|---|
| 438 | if (((yy<<12) - uu*1411 - vv*2925 + 2048)>>12>over) sel |= 2; // G |
|---|
| 439 | if (((yy<<12) + uu*7258 + 2048)>>12>over) sel |= 1; // B |
|---|
| 440 | } |
|---|
| 441 | buf[s]=buf[s+1]=cls[sel]; |
|---|
| 442 | } |
|---|
| 443 | else if (((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=COLOR_TRANSPARENT; |
|---|
| 444 | else buf[s]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; |
|---|
| 445 | if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; |
|---|
| 446 | if (mrec) { |
|---|
| 447 | // draw Canon OSD to buf[] if in REC mode |
|---|
| 448 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 449 | if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s); |
|---|
| 450 | if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1); |
|---|
| 451 | #else |
|---|
| 452 | if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; |
|---|
| 453 | if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; |
|---|
| 454 | #endif |
|---|
| 455 | } |
|---|
| 456 | } |
|---|
| 457 | s+=screen_buffer_width-screen_width; |
|---|
| 458 | if (y*screen_height/viewport_height == (s+screen_buffer_width)/screen_buffer_width) { |
|---|
| 459 | memcpy(buf+s, buf+s-screen_buffer_width, screen_buffer_width); |
|---|
| 460 | s+=screen_buffer_width; |
|---|
| 461 | } |
|---|
| 462 | } |
|---|
| 463 | if (!zebra_drawn) f=0; |
|---|
| 464 | } |
|---|
| 465 | // if blink mode is in no-zebra phase OR if there was no over/underexposed pixels to draw zebra on |
|---|
| 466 | if (!f) { |
|---|
| 467 | // if zebra was drawn during previous call of this function |
|---|
| 468 | if (need_restore) { |
|---|
| 469 | if (conf.zebra_restore_screen || conf.zebra_restore_osd) { |
|---|
| 470 | draw_restore(); |
|---|
| 471 | } else { // clear buf[] of zebra, only leave Canon OSD |
|---|
| 472 | if (mrec) { // REC mode |
|---|
| 473 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 474 | // copy rescued Canon OSD to buf[] top/bottom parts and fill center with transparent color: |
|---|
| 475 | memcpy(buf, cur_buf_top, screen_buffer_width * ZFIX_TOP); |
|---|
| 476 | memcpy(buf + screen_buffer_size - screen_buffer_width * ZFIX_BOTTOM, cur_buf_bot, screen_buffer_width * ZFIX_BOTTOM); |
|---|
| 477 | for (s = screen_buffer_width*ZFIX_TOP; s < screen_buffer_size-screen_buffer_width*ZFIX_BOTTOM; s++) { |
|---|
| 478 | buf[s]=COLOR_TRANSPARENT; |
|---|
| 479 | } |
|---|
| 480 | #else |
|---|
| 481 | // copy from a complete Canon OSD rescue screen dump |
|---|
| 482 | memcpy(buf, cur_buf, screen_buffer_size); |
|---|
| 483 | #endif |
|---|
| 484 | } else { // Not REC mode |
|---|
| 485 | // No Canon OSD restore, fill buf[] with transparent color: |
|---|
| 486 | memset(buf, COLOR_TRANSPARENT, screen_buffer_size); |
|---|
| 487 | } |
|---|
| 488 | // draw CHDK osd and histogram to buf[] (if enabled in config) |
|---|
| 489 | gui_osd_draw_zebra_osd(); |
|---|
| 490 | // copy buf[] to both display buffers |
|---|
| 491 | memcpy(scr_buf, buf, screen_buffer_size); |
|---|
| 492 | memcpy(scr_buf+screen_buffer_size, buf, screen_buffer_size); |
|---|
| 493 | } |
|---|
| 494 | need_restore=0; |
|---|
| 495 | } |
|---|
| 496 | return !(conf.zebra_restore_screen && conf.zebra_restore_osd); |
|---|
| 497 | // if zebra was drawn |
|---|
| 498 | } else { |
|---|
| 499 | // draw CHDK osd and histogram to buf[] over zebra (if enabled in config) |
|---|
| 500 | gui_osd_draw_zebra_osd(); |
|---|
| 501 | // copy buf[] to both display buffers |
|---|
| 502 | memcpy(scr_buf, buf, screen_buffer_size); |
|---|
| 503 | memcpy(scr_buf+screen_buffer_size, buf, screen_buffer_size); |
|---|
| 504 | |
|---|
| 505 | need_restore=1; |
|---|
| 506 | return 1; |
|---|
| 507 | } |
|---|
| 508 | return 0; |
|---|
| 509 | } |
|---|
| 510 | |
|---|
| 511 | //------------------------------------------------------------------- |
|---|
| 512 | static void gui_osd_draw_blended_histo(coord x, coord y) { |
|---|
| 513 | register unsigned int i, v, red, grn, blu, sel; |
|---|
| 514 | int m = ((mode_get()&MODE_MASK) == MODE_REC); |
|---|
| 515 | color cls[] = { |
|---|
| 516 | conf.histo_color>>8, |
|---|
| 517 | (m)?0xDF:0xCC, |
|---|
| 518 | COLOR_GREEN, |
|---|
| 519 | (m)?COLOR_BLUE_LT:0x99, |
|---|
| 520 | COLOR_RED, |
|---|
| 521 | (m)?0x66:0xE2, |
|---|
| 522 | (m)?COLOR_YELLOW:0x66, |
|---|
| 523 | COLOR_WHITE |
|---|
| 524 | }; |
|---|
| 525 | |
|---|
| 526 | for (i=0; i<HISTO_WIDTH; ++i) { |
|---|
| 527 | red = histogram[HISTO_R][i]; |
|---|
| 528 | grn = histogram[HISTO_G][i]; |
|---|
| 529 | blu = histogram[HISTO_B][i]; |
|---|
| 530 | |
|---|
| 531 | for (v=1; v<HISTO_HEIGHT; ++v) { |
|---|
| 532 | sel = 0; |
|---|
| 533 | |
|---|
| 534 | if (v < red) sel = 4; |
|---|
| 535 | if (v < grn) sel |= 2; |
|---|
| 536 | if (v < blu) sel |= 1; |
|---|
| 537 | |
|---|
| 538 | draw_pixel(x+1+i, y+HISTO_HEIGHT-v, cls[sel]); |
|---|
| 539 | } |
|---|
| 540 | } |
|---|
| 541 | |
|---|
| 542 | draw_rect(x, y, x+1+HISTO_WIDTH, y+HISTO_HEIGHT, conf.histo_color2&0xFF); |
|---|
| 543 | //Vertical lines |
|---|
| 544 | if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+HISTO_WIDTH)*i/5, y, x+(1+HISTO_WIDTH)*i/5, y+HISTO_HEIGHT, conf.histo_color2&0xFF); |
|---|
| 545 | |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | //------------------------------------------------------------------- |
|---|
| 549 | void gui_osd_draw_histo() { |
|---|
| 550 | switch (conf.histo_layout) { |
|---|
| 551 | case OSD_HISTO_LAYOUT_Y: |
|---|
| 552 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 553 | break; |
|---|
| 554 | case OSD_HISTO_LAYOUT_A_Y: |
|---|
| 555 | gui_osd_draw_single_histo(HISTO_RGB, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 556 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 0); |
|---|
| 557 | break; |
|---|
| 558 | case OSD_HISTO_LAYOUT_R_G_B: |
|---|
| 559 | gui_osd_draw_single_histo(HISTO_R, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 560 | gui_osd_draw_single_histo(HISTO_G, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 0); |
|---|
| 561 | gui_osd_draw_single_histo(HISTO_B, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT*2, 0); |
|---|
| 562 | break; |
|---|
| 563 | case OSD_HISTO_LAYOUT_A_yrgb: |
|---|
| 564 | gui_osd_draw_single_histo(HISTO_RGB, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 565 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 1); |
|---|
| 566 | gui_osd_draw_single_histo(HISTO_R, conf.histo_pos.x+HISTO_WIDTH/2+1, conf.histo_pos.y+HISTO_HEIGHT, 1); |
|---|
| 567 | gui_osd_draw_single_histo(HISTO_G, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT+HISTO_HEIGHT/2, 1); |
|---|
| 568 | gui_osd_draw_single_histo(HISTO_B, conf.histo_pos.x+HISTO_WIDTH/2+1, conf.histo_pos.y+HISTO_HEIGHT+HISTO_HEIGHT/2, 1); |
|---|
| 569 | break; |
|---|
| 570 | case OSD_HISTO_LAYOUT_Y_argb: |
|---|
| 571 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 572 | gui_osd_draw_single_histo(HISTO_RGB, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 1); |
|---|
| 573 | gui_osd_draw_single_histo(HISTO_R, conf.histo_pos.x+HISTO_WIDTH/2+1, conf.histo_pos.y+HISTO_HEIGHT, 1); |
|---|
| 574 | gui_osd_draw_single_histo(HISTO_G, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT+HISTO_HEIGHT/2, 1); |
|---|
| 575 | gui_osd_draw_single_histo(HISTO_B, conf.histo_pos.x+HISTO_WIDTH/2+1, conf.histo_pos.y+HISTO_HEIGHT+HISTO_HEIGHT/2, 1); |
|---|
| 576 | break; |
|---|
| 577 | case OSD_HISTO_LAYOUT_BLEND: |
|---|
| 578 | gui_osd_draw_blended_histo(conf.histo_pos.x, conf.histo_pos.y); |
|---|
| 579 | break; |
|---|
| 580 | case OSD_HISTO_LAYOUT_BLEND_Y: |
|---|
| 581 | gui_osd_draw_blended_histo(conf.histo_pos.x, conf.histo_pos.y); |
|---|
| 582 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 0); |
|---|
| 583 | break; |
|---|
| 584 | case OSD_HISTO_LAYOUT_A: |
|---|
| 585 | default: |
|---|
| 586 | gui_osd_draw_single_histo(HISTO_RGB, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 587 | break; |
|---|
| 588 | } |
|---|
| 589 | |
|---|
| 590 | if (conf.histo_layout != OSD_HISTO_LAYOUT_R_G_B) { |
|---|
| 591 | if (under_exposed && conf.show_overexp) { |
|---|
| 592 | draw_filled_ellipse(conf.histo_pos.x+5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(conf.histo_color2>>8, conf.histo_color2>>8)); |
|---|
| 593 | } |
|---|
| 594 | |
|---|
| 595 | if (over_exposed && conf.show_overexp) { |
|---|
| 596 | draw_filled_ellipse(conf.histo_pos.x+HISTO_WIDTH-5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(conf.histo_color2>>8, conf.histo_color2>>8)); |
|---|
| 597 | } |
|---|
| 598 | } |
|---|
| 599 | if ((conf.show_overexp ) && kbd_is_key_pressed(KEY_SHOOT_HALF) && (under_exposed || over_exposed)) |
|---|
| 600 | draw_string(conf.histo_pos.x+HISTO_WIDTH-FONT_WIDTH*3, conf.histo_pos.y-FONT_HEIGHT, "EXP", conf.histo_color); |
|---|
| 601 | if (conf.histo_auto_ajust){ |
|---|
| 602 | if (histo_magnification) { |
|---|
| 603 | sprintf(osd_buf, " %d.%02dx ", histo_magnification/1000, histo_magnification/10%100); |
|---|
| 604 | draw_string(conf.histo_pos.x, conf.histo_pos.y-FONT_HEIGHT, osd_buf, conf.histo_color); |
|---|
| 605 | } else if (gui_get_mode()==GUI_MODE_OSD){ |
|---|
| 606 | draw_string(conf.histo_pos.x, conf.histo_pos.y-FONT_HEIGHT, " 9.99x ", conf.histo_color); |
|---|
| 607 | } else { |
|---|
| 608 | draw_filled_rect(conf.histo_pos.x, conf.histo_pos.y-FONT_HEIGHT, conf.histo_pos.x+8*FONT_WIDTH, conf.histo_pos.y-1, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); |
|---|
| 609 | } |
|---|
| 610 | } |
|---|
| 611 | } |
|---|
| 612 | |
|---|
| 613 | //------------------------------------------------------------------- |
|---|
| 614 | static void sprintf_dist(char *buf, float dist) { |
|---|
| 615 | // length of printed string is always 4 |
|---|
| 616 | if (dist<=0 || dist>=MAX_DIST) { |
|---|
| 617 | sprintf(buf, " inf"); |
|---|
| 618 | } else if (dist<1000) { |
|---|
| 619 | sprintf(buf, ".%03d", (int)dist); |
|---|
| 620 | } else if (dist<10000) { |
|---|
| 621 | sprintf(buf, "%d.%02d", (int)(dist/1000), (int)(dist/10)%100); |
|---|
| 622 | } else if (dist<100000) { |
|---|
| 623 | sprintf(buf, "%02d.%d", (int)(dist/1000), (int)(dist/100)%10); |
|---|
| 624 | } else { |
|---|
| 625 | sprintf(buf, "%4d", (int)(dist/1000)); |
|---|
| 626 | } |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | static void sprintf_canon_values(char *buf, short dist) |
|---|
| 630 | { |
|---|
| 631 | short v=((dist<0)?-dist:dist); |
|---|
| 632 | sprintf(buf, "%s%d.%02d", ((dist<0)?"-":""), v/96, v%96); |
|---|
| 633 | } |
|---|
| 634 | |
|---|
| 635 | |
|---|
| 636 | //------------------------------------------------------------------- |
|---|
| 637 | |
|---|
| 638 | void gui_osd_calc_dof() { |
|---|
| 639 | |
|---|
| 640 | int av, av_min, c_of_c, fl, v, v1, m; |
|---|
| 641 | //long lfpfl=lens_get_focus_pos_fl(); |
|---|
| 642 | |
|---|
| 643 | #if CAM_HAS_IRIS_DIAPHRAGM |
|---|
| 644 | av=shooting_get_real_aperture(); |
|---|
| 645 | #else |
|---|
| 646 | av=shooting_get_min_real_aperture(); |
|---|
| 647 | #endif |
|---|
| 648 | fl=get_focal_length(lens_get_zoom_point()); |
|---|
| 649 | dof.far_limit=-1.0; |
|---|
| 650 | dof.near_limit=-1.0; |
|---|
| 651 | dof.depth_of_field=-1.0; |
|---|
| 652 | dof.hyperfocal_distance=-1.0; |
|---|
| 653 | dof.subject_distance=-1.0; |
|---|
| 654 | |
|---|
| 655 | if ((av!=0) && (fl!=0)) { |
|---|
| 656 | if (conf.dof_subj_dist_as_near_limit) { |
|---|
| 657 | v1=(fl*fl); |
|---|
| 658 | dof.near_limit=shooting_get_canon_subject_distance(); |
|---|
| 659 | av_min=shooting_get_min_real_aperture(); |
|---|
| 660 | c_of_c=circle_of_confusion*10; |
|---|
| 661 | if ((av_min!=0) && (c_of_c!=0)) dof.hyperfocal_distance=v1/(c_of_c*av_min); |
|---|
| 662 | if ((dof.near_limit>0) && (dof.near_limit<MAX_DIST)) { |
|---|
| 663 | v=(dof.hyperfocal_distance-dof.near_limit); |
|---|
| 664 | m=dof.hyperfocal_distance*dof.near_limit; |
|---|
| 665 | if ((v>0) && (m>0)) dof.subject_distance=m/v; |
|---|
| 666 | } |
|---|
| 667 | dof.hyperfocal_distance=v1/(c_of_c*av); |
|---|
| 668 | if ((dof.subject_distance>0) && (dof.subject_distance<MAX_DIST)) { |
|---|
| 669 | v = (dof.hyperfocal_distance-dof.subject_distance); |
|---|
| 670 | m=dof.hyperfocal_distance*dof.subject_distance; |
|---|
| 671 | if ((v>0) && (m>0)) dof.far_limit=m/v; |
|---|
| 672 | dof.depth_of_field=dof.far_limit-dof.near_limit; |
|---|
| 673 | } |
|---|
| 674 | } |
|---|
| 675 | else { |
|---|
| 676 | dof.subject_distance=shooting_get_canon_subject_distance(); |
|---|
| 677 | dof.hyperfocal_distance=(fl*fl)/(10*circle_of_confusion*av); |
|---|
| 678 | if (dof.subject_distance>0 && dof.subject_distance<MAX_DIST) { |
|---|
| 679 | m = dof.hyperfocal_distance*dof.subject_distance; |
|---|
| 680 | v = (dof.hyperfocal_distance+dof.subject_distance); |
|---|
| 681 | if ((v>0) && (m>0)) dof.near_limit=m/v; |
|---|
| 682 | v = (dof.hyperfocal_distance-dof.subject_distance); |
|---|
| 683 | if ((v>0) && (m>0)) dof.far_limit=m/v; |
|---|
| 684 | dof.depth_of_field=dof.far_limit-dof.near_limit; |
|---|
| 685 | } |
|---|
| 686 | } |
|---|
| 687 | } |
|---|
| 688 | if (conf.dof_dist_from_lens) { |
|---|
| 689 | int h=shooting_get_lens_to_focal_plane_width(); |
|---|
| 690 | if (dof.subject_distance>0) dof.subject_distance-=h; |
|---|
| 691 | if (dof.far_limit>0) dof.far_limit-=h; |
|---|
| 692 | if (dof.near_limit>0) dof.near_limit-=h; |
|---|
| 693 | if (dof.hyperfocal_distance>0) dof.hyperfocal_distance-=h; |
|---|
| 694 | } |
|---|
| 695 | } |
|---|
| 696 | |
|---|
| 697 | void gui_osd_calc_expo_param() { |
|---|
| 698 | |
|---|
| 699 | expo.av96=shooting_get_av96(); |
|---|
| 700 | expo.tv96=shooting_get_tv96(); |
|---|
| 701 | expo.sv96=shooting_get_sv96(); |
|---|
| 702 | expo.iso=shooting_get_iso_real(); |
|---|
| 703 | expo.sv96_market=shooting_get_svm96(); |
|---|
| 704 | expo.iso_market=shooting_get_iso_market(); |
|---|
| 705 | expo.bv96_measured=shooting_get_bv96(); |
|---|
| 706 | expo.ev96_seted=expo.tv96+expo.av96; //Tv96+Av96 |
|---|
| 707 | expo.ev96_measured=expo.bv96_measured+expo.sv96;//Bv96+Sv96 |
|---|
| 708 | expo.dev96=expo.ev96_measured-expo.ev96_seted;// Ev96_external-Ev96_internal |
|---|
| 709 | expo.bv96_seted=expo.ev96_seted-expo.sv96; |
|---|
| 710 | expo.dev96_canon=shooting_get_canon_overexposure_value(); |
|---|
| 711 | expo.b=shooting_get_luminance(); |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | void gui_osd_draw_dof() { |
|---|
| 715 | |
|---|
| 716 | //gui_osd_calc_dof(); |
|---|
| 717 | //strcpy(osd_buf, ""); |
|---|
| 718 | draw_string(conf.dof_pos.x, conf.dof_pos.y, "S/R1/R2:", conf.osd_color); |
|---|
| 719 | sprintf_dist(osd_buf, dof.subject_distance); |
|---|
| 720 | int i=strlen(osd_buf); |
|---|
| 721 | osd_buf[i]='/'; |
|---|
| 722 | sprintf_dist(osd_buf+i+1, dof.near_limit); |
|---|
| 723 | i=strlen(osd_buf); |
|---|
| 724 | osd_buf[i]='/'; |
|---|
| 725 | sprintf_dist(osd_buf+i+1, dof.far_limit); |
|---|
| 726 | draw_string(conf.dof_pos.x+8*FONT_WIDTH, conf.dof_pos.y, osd_buf, conf.osd_color); |
|---|
| 727 | |
|---|
| 728 | draw_string(conf.dof_pos.x, conf.dof_pos.y+FONT_HEIGHT, "DOF/HYP:", conf.osd_color); |
|---|
| 729 | sprintf_dist(osd_buf, dof.depth_of_field); |
|---|
| 730 | int j=strlen(osd_buf); |
|---|
| 731 | osd_buf[j]='/'; |
|---|
| 732 | sprintf_dist(osd_buf+j+1, dof.hyperfocal_distance); |
|---|
| 733 | draw_string(conf.dof_pos.x+8*FONT_WIDTH, conf.dof_pos.y+FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 734 | |
|---|
| 735 | } |
|---|
| 736 | |
|---|
| 737 | static short n, m; //string number |
|---|
| 738 | |
|---|
| 739 | void gui_print_osd_state_string_int(const char * title, int value) { |
|---|
| 740 | strcpy(osd_buf, title); |
|---|
| 741 | sprintf(osd_buf+strlen(osd_buf), "%d", value); |
|---|
| 742 | sprintf(osd_buf+strlen(osd_buf), "%12s", ""); |
|---|
| 743 | osd_buf[12]=0; |
|---|
| 744 | draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+n, osd_buf, conf.osd_color_override); |
|---|
| 745 | n+=FONT_HEIGHT; |
|---|
| 746 | } |
|---|
| 747 | |
|---|
| 748 | void gui_print_osd_state_string_chr(const char *title, const char *value) { |
|---|
| 749 | strcpy(osd_buf, title); |
|---|
| 750 | sprintf(osd_buf+strlen(osd_buf), "%s", value); |
|---|
| 751 | sprintf(osd_buf+strlen(osd_buf), "%12s", ""); |
|---|
| 752 | osd_buf[12]=0; |
|---|
| 753 | draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+n, osd_buf, conf.osd_color_override); |
|---|
| 754 | n+=FONT_HEIGHT; |
|---|
| 755 | } |
|---|
| 756 | |
|---|
| 757 | void gui_print_osd_state_string_float(const char * title, const char * fmt, int divisor, int value) { |
|---|
| 758 | strcpy(osd_buf, title); |
|---|
| 759 | sprintf(osd_buf+strlen(osd_buf), fmt, (int)(value/divisor), (int)(value%divisor)); |
|---|
| 760 | sprintf(osd_buf+strlen(osd_buf), "%12s", ""); |
|---|
| 761 | osd_buf[12]=0; |
|---|
| 762 | draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+n, osd_buf, conf.osd_color_override); |
|---|
| 763 | n+=FONT_HEIGHT; |
|---|
| 764 | } |
|---|
| 765 | |
|---|
| 766 | void gui_print_osd_misc_string_int(const char * title, int value) { |
|---|
| 767 | strcpy(osd_buf, title); |
|---|
| 768 | sprintf(osd_buf+strlen(osd_buf), "%d", value); |
|---|
| 769 | sprintf(osd_buf+strlen(osd_buf), "%9s", ""); |
|---|
| 770 | osd_buf[9]=0; |
|---|
| 771 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 772 | m+=FONT_HEIGHT; |
|---|
| 773 | } |
|---|
| 774 | |
|---|
| 775 | /* |
|---|
| 776 | void gui_print_osd_misc_string_float(const char * title, const char * fmt, int divisor, int value) { |
|---|
| 777 | char s[16]; |
|---|
| 778 | strcpy(osd_buf, title); |
|---|
| 779 | sprintf(s, fmt, (int)(value/divisor), (int)(value%divisor)); |
|---|
| 780 | sprintf(osd_buf+strlen(osd_buf), "%6s", s); |
|---|
| 781 | //osd_buf[8]=0; |
|---|
| 782 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 783 | m+=FONT_HEIGHT; |
|---|
| 784 | } |
|---|
| 785 | */ |
|---|
| 786 | |
|---|
| 787 | void gui_print_osd_misc_string_float(const char * title, const char * fmt, int divisor, int value) { |
|---|
| 788 | strcpy(osd_buf, title); |
|---|
| 789 | sprintf(osd_buf+strlen(osd_buf), fmt, (int)(value/divisor), (int)(value%divisor)); |
|---|
| 790 | sprintf(osd_buf+strlen(osd_buf), "%9s", ""); |
|---|
| 791 | osd_buf[9]=0; |
|---|
| 792 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 793 | m+=FONT_HEIGHT; |
|---|
| 794 | } |
|---|
| 795 | |
|---|
| 796 | |
|---|
| 797 | void gui_print_osd_misc_string_dist(const char * title, int value) { |
|---|
| 798 | strcpy(osd_buf, title); |
|---|
| 799 | sprintf_dist(osd_buf+strlen(osd_buf), (float)value); |
|---|
| 800 | sprintf(osd_buf+strlen(osd_buf), "%9s", ""); |
|---|
| 801 | osd_buf[9]=0; |
|---|
| 802 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 803 | m+=FONT_HEIGHT; |
|---|
| 804 | } |
|---|
| 805 | |
|---|
| 806 | void gui_print_osd_misc_string_canon_values(const char * title, short value) { |
|---|
| 807 | strcpy(osd_buf, title); |
|---|
| 808 | sprintf_canon_values(osd_buf+strlen(osd_buf), value); |
|---|
| 809 | sprintf(osd_buf+strlen(osd_buf), "%9s", ""); |
|---|
| 810 | osd_buf[9]=0; |
|---|
| 811 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 812 | m+=FONT_HEIGHT; |
|---|
| 813 | } |
|---|
| 814 | |
|---|
| 815 | //------------------------------------------------------------------- |
|---|
| 816 | void gui_osd_draw_raw_info() |
|---|
| 817 | { |
|---|
| 818 | int x, m=(mode_get()&MODE_SHOOTING_MASK); |
|---|
| 819 | static int b; |
|---|
| 820 | if ((!((movie_status > 1) && conf.save_raw_in_video )) && (!(shooting_get_prop(PROPCASE_RESOLUTION)==5)) && (!((m==MODE_SPORTS) && conf.save_raw_in_sports)) && (!((m==MODE_AUTO) && conf.save_raw_in_auto)) && (!(conf.edge_overlay_enable && conf.save_raw_in_edgeoverlay)) && (!((shooting_get_prop(PROPCASE_DRIVE_MODE)==1) && conf.save_raw_in_burst && !(m==MODE_SPORTS))) && (!((shooting_get_prop(PROPCASE_DRIVE_MODE)>=2) && conf.save_raw_in_timer)) && (!((shooting_get_prop(PROPCASE_BRACKET_MODE)==1) && conf.save_raw_in_ev_bracketing)) ) |
|---|
| 821 | { |
|---|
| 822 | if (conf.show_remaining_raw) |
|---|
| 823 | { |
|---|
| 824 | int raw_count=GetRawCount(); |
|---|
| 825 | if (raw_count>conf.remaining_raw_treshold) |
|---|
| 826 | { |
|---|
| 827 | if (conf.dng_raw) sprintf(osd_buf, "DNG:%3d", raw_count); else sprintf(osd_buf, "RAW:%3d", raw_count); |
|---|
| 828 | draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, osd_buf, conf.osd_color); |
|---|
| 829 | } |
|---|
| 830 | else |
|---|
| 831 | { |
|---|
| 832 | |
|---|
| 833 | if (conf.dng_raw) sprintf(osd_buf, "DNG:%3d", raw_count); else sprintf(osd_buf, "RAW:%3d", raw_count); |
|---|
| 834 | |
|---|
| 835 | if (b > 6) |
|---|
| 836 | { |
|---|
| 837 | draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, osd_buf, conf.osd_color_warn); |
|---|
| 838 | b = (b>12) ? 0 : b+1; |
|---|
| 839 | } |
|---|
| 840 | else |
|---|
| 841 | { |
|---|
| 842 | draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, osd_buf, conf.osd_color); |
|---|
| 843 | b = b+1; |
|---|
| 844 | } |
|---|
| 845 | } |
|---|
| 846 | } |
|---|
| 847 | else if (conf.dng_raw) draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, "DNG", conf.osd_color); else draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, "RAW", conf.osd_color); |
|---|
| 848 | } |
|---|
| 849 | else if (conf.raw_exceptions_warn) |
|---|
| 850 | { |
|---|
| 851 | if (conf.dng_raw) gui_print_osd_state_string_chr("DNG Disabled",""); else gui_print_osd_state_string_chr("RAW Disabled",""); |
|---|
| 852 | } |
|---|
| 853 | |
|---|
| 854 | |
|---|
| 855 | } |
|---|
| 856 | //------------------------------------------------------------------- |
|---|
| 857 | void gui_osd_draw_state() { |
|---|
| 858 | int a, gui_mode=gui_get_mode(), m=(mode_get()&MODE_SHOOTING_MASK); |
|---|
| 859 | long t; |
|---|
| 860 | |
|---|
| 861 | n=0; |
|---|
| 862 | /////////////////////////// |
|---|
| 863 | //sprintf(osd_buf,"%s",get_debug()); |
|---|
| 864 | //draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+6*FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 865 | //////////////////////////// |
|---|
| 866 | |
|---|
| 867 | |
|---|
| 868 | if ((((conf.tv_enum_type) || (conf.tv_override_value)) && (conf.tv_override_koef) && !(conf.override_disable==1)) || gui_mode==GUI_MODE_OSD){ |
|---|
| 869 | if(kbd_is_key_pressed(KEY_SHOOT_HALF)) |
|---|
| 870 | { |
|---|
| 871 | t=(int)(shooting_get_shutter_speed_from_tv96(shooting_get_tv96())*100000); |
|---|
| 872 | gui_print_osd_state_string_float("TV:", "%d.%05d ", 100000, t); |
|---|
| 873 | } |
|---|
| 874 | else |
|---|
| 875 | { |
|---|
| 876 | if (conf.tv_enum_type) |
|---|
| 877 | gui_print_osd_state_string_chr("TV:",shooting_get_tv_override_value()); |
|---|
| 878 | else |
|---|
| 879 | { |
|---|
| 880 | t=(int)(shooting_get_shutter_speed_override_value()*100000); |
|---|
| 881 | gui_print_osd_state_string_float("TV:", "%d.%05d ", 100000, t); |
|---|
| 882 | } |
|---|
| 883 | } |
|---|
| 884 | } |
|---|
| 885 | if ((conf.av_override_value && !(conf.override_disable==1))|| gui_mode==GUI_MODE_OSD) |
|---|
| 886 | gui_print_osd_state_string_float("AV:", "%d.%02d ", 100, shooting_get_aperture_from_av96(shooting_get_av96_override_value())); |
|---|
| 887 | #if CAM_HAS_ND_FILTER |
|---|
| 888 | if ((conf.nd_filter_state && !(conf.override_disable==1))|| gui_mode==GUI_MODE_OSD) |
|---|
| 889 | gui_print_osd_state_string_chr("NDFILTER:", ((conf.nd_filter_state==1)?"IN":"OUT")); |
|---|
| 890 | #endif |
|---|
| 891 | if ((conf.autoiso_enable && shooting_get_iso_mode()<=0 && !(m==MODE_M || m==MODE_TV) && shooting_get_flash_mode() && (!(conf.override_disable==1 && conf.override_disable_all))) || gui_mode==GUI_MODE_OSD) |
|---|
| 892 | gui_print_osd_state_string_chr("AUTOISO:", ((conf.autoiso_enable==1)?"ON":"OFF")); |
|---|
| 893 | if ((conf.subj_dist_override_value && conf.subj_dist_override_koef && shooting_can_focus() && !(conf.override_disable==1)) || ((gui_mode==GUI_MODE_ALT) && shooting_get_common_focus_mode()) || gui_mode==GUI_MODE_OSD) { |
|---|
| 894 | gui_print_osd_state_string_int("SD:",shooting_get_subject_distance_override_value()); |
|---|
| 895 | if (gui_mode==GUI_MODE_ALT) |
|---|
| 896 | gui_print_osd_state_string_int("FACTOR:",shooting_get_subject_distance_override_koef()); |
|---|
| 897 | } |
|---|
| 898 | if ((conf.iso_override_value && conf.iso_override_koef && !(conf.override_disable==1)) || gui_mode==GUI_MODE_OSD) |
|---|
| 899 | gui_print_osd_state_string_int("ISO:", shooting_get_iso_override_value()); |
|---|
| 900 | if ((gui_mode==GUI_MODE_OSD) || (shooting_get_drive_mode())) { |
|---|
| 901 | if ((conf.tv_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) || (conf.av_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) || (conf.iso_bracket_value && conf.iso_bracket_koef && !(conf.override_disable==1 && conf.override_disable_all)) || ((conf.subj_dist_bracket_value) && (conf.subj_dist_bracket_koef) && (shooting_can_focus() && !(conf.override_disable==1 && conf.override_disable_all)))) |
|---|
| 902 | gui_print_osd_state_string_chr("BRACKET:", shooting_get_bracket_type()); |
|---|
| 903 | if (conf.tv_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) |
|---|
| 904 | gui_print_osd_state_string_chr("TV:", shooting_get_tv_bracket_value()); |
|---|
| 905 | else if (conf.av_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) |
|---|
| 906 | gui_print_osd_state_string_chr("AV:", shooting_get_av_bracket_value()); |
|---|
| 907 | else if (conf.iso_bracket_value && conf.iso_bracket_koef && !(conf.override_disable==1 && conf.override_disable_all)) |
|---|
| 908 | gui_print_osd_state_string_int("ISO:", shooting_get_iso_bracket_value()); |
|---|
| 909 | else if ((conf.subj_dist_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) && (conf.subj_dist_bracket_koef) && (shooting_can_focus())) |
|---|
| 910 | gui_print_osd_state_string_int("SD:",shooting_get_subject_distance_bracket_value()); |
|---|
| 911 | } |
|---|
| 912 | #ifdef OPT_CURVES |
|---|
| 913 | if (conf.curve_enable || gui_mode==GUI_MODE_OSD) { |
|---|
| 914 | if (conf.curve_enable==1) gui_print_osd_state_string_chr("CURVES:", "CSTM"); |
|---|
| 915 | else if (conf.curve_enable==4) gui_print_osd_state_string_chr("CURVES:", "AUTO"); |
|---|
| 916 | else if (conf.curve_enable==3) gui_print_osd_state_string_chr("CURVES:", "+2EV"); |
|---|
| 917 | else if (conf.curve_enable==2) gui_print_osd_state_string_chr("CURVES:", "+1EV"); |
|---|
| 918 | } |
|---|
| 919 | #endif |
|---|
| 920 | if (conf.override_disable == 1) gui_print_osd_state_string_chr("NO ", "OVERRIDES"); |
|---|
| 921 | if (conf.flash_manual_override) gui_print_osd_state_string_chr("Flash:", "Manual Override"); |
|---|
| 922 | /* |
|---|
| 923 | draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+n, get_debug(), conf.osd_color); |
|---|
| 924 | n+=FONT_HEIGHT;*/ |
|---|
| 925 | } |
|---|
| 926 | |
|---|
| 927 | //------------------------------------------------------------------- |
|---|
| 928 | void gui_osd_draw_values(int showtype) { |
|---|
| 929 | int iso_mode=shooting_get_iso_mode(); |
|---|
| 930 | float s=-1.0f; |
|---|
| 931 | |
|---|
| 932 | m=0; |
|---|
| 933 | |
|---|
| 934 | //gui_osd_calc_expo_param(); |
|---|
| 935 | |
|---|
| 936 | if (conf.values_show_zoom) { |
|---|
| 937 | int fl, zp=lens_get_zoom_point(), fl1=get_focal_length(zp); |
|---|
| 938 | switch (conf.zoom_value) { |
|---|
| 939 | case ZOOM_SHOW_FL: |
|---|
| 940 | sprintf(osd_buf, "Z:%d.%dmm%8s", fl1/1000, fl1%1000/100, ""); |
|---|
| 941 | break; |
|---|
| 942 | case ZOOM_SHOW_EFL: |
|---|
| 943 | fl=get_effective_focal_length(zp); |
|---|
| 944 | // scale by users adapter lens eg. Canon Wide .42 or Canon Tele 1.75 |
|---|
| 945 | fl = fl * conf.zoom_scale / 100; |
|---|
| 946 | sprintf(osd_buf, "Z:%3dmm%8s", fl/1000, ""); |
|---|
| 947 | break; |
|---|
| 948 | case ZOOM_SHOW_X: |
|---|
| 949 | default: |
|---|
| 950 | fl=get_zoom_x(zp); |
|---|
| 951 | sprintf(osd_buf, "Z:%ld/%d.%dx%8s", zp, fl/10, fl%10, ""); |
|---|
| 952 | break; |
|---|
| 953 | } |
|---|
| 954 | osd_buf[9]=0; |
|---|
| 955 | draw_string(conf.values_pos.x, conf.values_pos.y, osd_buf, conf.osd_color); |
|---|
| 956 | m+=FONT_HEIGHT; |
|---|
| 957 | } |
|---|
| 958 | |
|---|
| 959 | |
|---|
| 960 | if ((conf.values_show_real_aperture) && (showtype==1)) |
|---|
| 961 | gui_print_osd_misc_string_float("Av :", "%d.%02d ", 100, shooting_get_real_aperture()); |
|---|
| 962 | if ((conf.show_dof==DOF_SHOW_IN_MISC) && (showtype)) { |
|---|
| 963 | //if (kbd_is_key_pressed(KEY_SHOOT_HALF) && (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH)) |
|---|
| 964 | //gui_osd_calc_dof(); |
|---|
| 965 | if (conf.dof_subj_dist_in_misc) gui_print_osd_misc_string_dist("SD :", dof.subject_distance); |
|---|
| 966 | if (conf.dof_near_limit_in_misc) gui_print_osd_misc_string_dist("NL :", dof.near_limit); |
|---|
| 967 | if (conf.dof_far_limit_in_misc) gui_print_osd_misc_string_dist("FL :", dof.far_limit); |
|---|
| 968 | if (conf.dof_depth_in_misc) gui_print_osd_misc_string_dist("DOF:", dof.depth_of_field); |
|---|
| 969 | if (conf.dof_hyperfocal_in_misc) gui_print_osd_misc_string_dist("HYP:", dof.hyperfocal_distance); |
|---|
| 970 | } |
|---|
| 971 | if (showtype==1) { |
|---|
| 972 | if ((iso_mode <= 0) || !(conf.values_show_iso_only_in_autoiso_mode)) { |
|---|
| 973 | if (conf.values_show_real_iso) gui_print_osd_misc_string_int("I-R:", expo.iso); |
|---|
| 974 | if (conf.values_show_market_iso) gui_print_osd_misc_string_int("I-M:", expo.iso_market); |
|---|
| 975 | } |
|---|
| 976 | if (conf.values_show_bv_measured) gui_print_osd_misc_string_canon_values("Bvm:", expo.bv96_measured ); |
|---|
| 977 | if (conf.values_show_bv_seted) gui_print_osd_misc_string_canon_values("Bvs:", expo.bv96_seted ); |
|---|
| 978 | if (conf.values_show_ev_measured) gui_print_osd_misc_string_canon_values("Evm:", expo.ev96_measured); |
|---|
| 979 | if (conf.values_show_ev_seted ) gui_print_osd_misc_string_canon_values("Evs:", expo.ev96_seted ); |
|---|
| 980 | if (conf.values_show_overexposure) gui_print_osd_misc_string_canon_values("dE :", expo.dev96); |
|---|
| 981 | if (conf.values_show_canon_overexposure ) gui_print_osd_misc_string_canon_values("dEc:", expo.dev96_canon); |
|---|
| 982 | if (conf.values_show_luminance) gui_print_osd_misc_string_float("B :", "%d.%02d ", 100, expo.b); |
|---|
| 983 | |
|---|
| 984 | } |
|---|
| 985 | |
|---|
| 986 | } |
|---|
| 987 | |
|---|
| 988 | #define CLOCK_FORMAT_24 0 |
|---|
| 989 | #define CLOCK_FORMAT_12 1 |
|---|
| 990 | #define CLOCK_WITHOUT_SEC 1 |
|---|
| 991 | #define CLOCK_WITH_SEC 2 |
|---|
| 992 | |
|---|
| 993 | //------------------------------------------------------------------- |
|---|
| 994 | void gui_osd_draw_clock(int x, int y, color cl) { |
|---|
| 995 | unsigned long t; |
|---|
| 996 | static struct tm *ttm; |
|---|
| 997 | int w = 0; |
|---|
| 998 | int z; |
|---|
| 999 | static char am[4]; |
|---|
| 1000 | static char pm[4]; |
|---|
| 1001 | static char curr[4]; |
|---|
| 1002 | t = time(NULL); |
|---|
| 1003 | ttm = localtime(&t); |
|---|
| 1004 | unsigned int hour=(ttm->tm_hour); |
|---|
| 1005 | if (conf.clock_format == CLOCK_FORMAT_12) { |
|---|
| 1006 | switch(conf.clock_indicator) |
|---|
| 1007 | { |
|---|
| 1008 | case 1: |
|---|
| 1009 | sprintf(pm, "P"); |
|---|
| 1010 | sprintf(am, "A"); |
|---|
| 1011 | w = 1; |
|---|
| 1012 | break; |
|---|
| 1013 | case 2: |
|---|
| 1014 | sprintf(pm, "."); |
|---|
| 1015 | sprintf(am, " "); |
|---|
| 1016 | w = 1; |
|---|
| 1017 | break; |
|---|
| 1018 | default: |
|---|
| 1019 | sprintf(pm, " PM"); |
|---|
| 1020 | sprintf(am, " AM"); |
|---|
| 1021 | w = 3; |
|---|
| 1022 | break; |
|---|
| 1023 | } |
|---|
| 1024 | sprintf(curr,((hour>=12)?pm:am)); |
|---|
| 1025 | if ((ttm->tm_hour)==00) hour=12; |
|---|
| 1026 | else if ((ttm->tm_hour)>12) hour=hour-12; |
|---|
| 1027 | } |
|---|
| 1028 | switch(conf.show_clock) |
|---|
| 1029 | { |
|---|
| 1030 | case CLOCK_WITHOUT_SEC: |
|---|
| 1031 | if (conf.clock_format == CLOCK_FORMAT_24) |
|---|
| 1032 | sprintf(osd_buf, "%2u:%02u", hour, ttm->tm_min); |
|---|
| 1033 | else |
|---|
| 1034 | sprintf(osd_buf, "%2u:%02u%s", hour, ttm->tm_min,curr); |
|---|
| 1035 | z=0; |
|---|
| 1036 | break; |
|---|
| 1037 | case CLOCK_WITH_SEC: |
|---|
| 1038 | default: |
|---|
| 1039 | if (conf.clock_format == CLOCK_FORMAT_24) |
|---|
| 1040 | sprintf(osd_buf, "%2u:%02u:%02u", hour, ttm->tm_min,ttm->tm_sec); |
|---|
| 1041 | else |
|---|
| 1042 | sprintf(osd_buf, "%2u:%02u:%02u%s", hour, ttm->tm_min,ttm->tm_sec,curr); |
|---|
| 1043 | z=3; |
|---|
| 1044 | break; |
|---|
| 1045 | } |
|---|
| 1046 | if ((conf.show_clock==CLOCK_WITH_SEC || (conf.clock_format==CLOCK_FORMAT_12)) && (conf.clock_pos.x>=(z+w)*FONT_WIDTH) ) |
|---|
| 1047 | draw_string((x)?x-(z+w)*FONT_WIDTH:conf.clock_pos.x-(z+w)*FONT_WIDTH, (y)?y:conf.clock_pos.y, osd_buf, (cl)?cl:conf.osd_color); |
|---|
| 1048 | else |
|---|
| 1049 | draw_string((x)?x:conf.clock_pos.x, (y)?y:conf.clock_pos.y, osd_buf, (cl)?cl:conf.osd_color); |
|---|
| 1050 | } |
|---|
| 1051 | |
|---|
| 1052 | |
|---|
| 1053 | void gui_osd_draw_seconds() { |
|---|
| 1054 | unsigned long t; |
|---|
| 1055 | static struct tm *ttm; |
|---|
| 1056 | |
|---|
| 1057 | t = time(NULL); |
|---|
| 1058 | ttm = localtime(&t); |
|---|
| 1059 | sprintf(osd_buf, "%02u", ttm->tm_sec); |
|---|
| 1060 | if (conf.clock_pos.x<4*FONT_WIDTH){ |
|---|
| 1061 | draw_string(conf.clock_pos.x, conf.clock_pos.y, osd_buf, conf.osd_color); |
|---|
| 1062 | } |
|---|
| 1063 | else |
|---|
| 1064 | { |
|---|
| 1065 | draw_string(conf.clock_pos.x+(3*FONT_WIDTH), conf.clock_pos.y, osd_buf, conf.osd_color); |
|---|
| 1066 | } |
|---|
| 1067 | |
|---|
| 1068 | |
|---|
| 1069 | } |
|---|
| 1070 | |
|---|
| 1071 | void gui_osd_draw_movie_time_left() { |
|---|
| 1072 | |
|---|
| 1073 | static int card_used, init_space, elapsed, avg_use, time_left; |
|---|
| 1074 | static long init_time; |
|---|
| 1075 | static int record_running = 0; |
|---|
| 1076 | static int init = 0; |
|---|
| 1077 | static unsigned int skipcalls = 1; |
|---|
| 1078 | unsigned int hour=0, min=0, sec=0; |
|---|
| 1079 | int mode_video = MODE_IS_VIDEO(m); |
|---|
| 1080 | |
|---|
| 1081 | |
|---|
| 1082 | #if CAM_CHDK_HAS_EXT_VIDEO_MENU |
|---|
| 1083 | if (mode_video || movie_status > 1) { |
|---|
| 1084 | // if manual adjust, show the field item to be adjusted |
|---|
| 1085 | // if any value overriden, show the override value |
|---|
| 1086 | #if !CAM_VIDEO_QUALITY_ONLY |
|---|
| 1087 | if ((conf.video_mode == 0 && conf.fast_movie_quality_control==1) || conf.video_bitrate != VIDEO_DEFAULT_BITRATE) { |
|---|
| 1088 | // gui_print_osd_state_string_chr("Bitrate: ",video_bitrate_strings[conf.video_bitrate]); |
|---|
| 1089 | sprintf(osd_buf3, "Bit:%5s",video_bitrate_strings[conf.video_bitrate]); |
|---|
| 1090 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y+2*FONT_HEIGHT, osd_buf3, conf.osd_color); |
|---|
| 1091 | } |
|---|
| 1092 | #endif |
|---|
| 1093 | if ((conf.video_mode == 1 && conf.fast_movie_quality_control==1) || conf.video_quality != VIDEO_DEFAULT_QUALITY) { |
|---|
| 1094 | // gui_print_osd_state_string_int("Quality: ",conf.video_quality); |
|---|
| 1095 | sprintf(osd_buf4, "Qual:%2i",conf.video_quality); |
|---|
| 1096 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y+3*FONT_HEIGHT, osd_buf4, conf.osd_color); |
|---|
| 1097 | } |
|---|
| 1098 | // everything else is for stills |
|---|
| 1099 | if(mode_video) |
|---|
| 1100 | return; |
|---|
| 1101 | } |
|---|
| 1102 | #endif |
|---|
| 1103 | |
|---|
| 1104 | if (movie_reset == 1) |
|---|
| 1105 | { |
|---|
| 1106 | init = 0; |
|---|
| 1107 | movie_reset = 0; |
|---|
| 1108 | } |
|---|
| 1109 | if (movie_status > 1) record_running = 1; |
|---|
| 1110 | else |
|---|
| 1111 | {record_running = 0; |
|---|
| 1112 | init = 0; |
|---|
| 1113 | } |
|---|
| 1114 | |
|---|
| 1115 | if (record_running == 1 && init == 0) |
|---|
| 1116 | { |
|---|
| 1117 | init = 1; |
|---|
| 1118 | init_space = GetFreeCardSpaceKb(); |
|---|
| 1119 | init_time = get_tick_count(); |
|---|
| 1120 | } |
|---|
| 1121 | if (init == 1) |
|---|
| 1122 | { |
|---|
| 1123 | |
|---|
| 1124 | card_used = init_space - GetFreeCardSpaceKb(); |
|---|
| 1125 | elapsed = (int) ( get_tick_count() - init_time ) / 1000; |
|---|
| 1126 | avg_use = card_used / elapsed; // running average Kb/sec |
|---|
| 1127 | time_left = (GetFreeCardSpaceKb() / avg_use); |
|---|
| 1128 | hour = time_left / 3600; |
|---|
| 1129 | min = (time_left % 3600) / 60; |
|---|
| 1130 | sec = (time_left % 3600) % 60; |
|---|
| 1131 | |
|---|
| 1132 | if (elapsed<1) |
|---|
| 1133 | { |
|---|
| 1134 | sprintf(osd_buf, "Calc..."); |
|---|
| 1135 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y, osd_buf, conf.osd_color); |
|---|
| 1136 | } |
|---|
| 1137 | |
|---|
| 1138 | if (--skipcalls ==0) { |
|---|
| 1139 | if (elapsed>1) |
|---|
| 1140 | { |
|---|
| 1141 | if (conf.show_movie_time == 3){ |
|---|
| 1142 | sprintf(osd_buf, "%04d KB/s", avg_use); |
|---|
| 1143 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y, osd_buf, conf.osd_color); |
|---|
| 1144 | sprintf(osd_buf2, "-%02d:%02d:%02d", hour, min, sec); |
|---|
| 1145 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y+FONT_HEIGHT, osd_buf2, conf.osd_color); |
|---|
| 1146 | } |
|---|
| 1147 | if (conf.show_movie_time == 2) |
|---|
| 1148 | {sprintf(osd_buf, "%04d KB/s", avg_use); |
|---|
| 1149 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y, osd_buf, conf.osd_color); |
|---|
| 1150 | } |
|---|
| 1151 | if (conf.show_movie_time == 1) |
|---|
| 1152 | { |
|---|
| 1153 | sprintf(osd_buf, "-%02d:%02d:%02d", hour, min, sec); |
|---|
| 1154 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y, osd_buf, conf.osd_color); |
|---|
| 1155 | } |
|---|
| 1156 | } |
|---|
| 1157 | |
|---|
| 1158 | skipcalls = conf.show_movie_refresh*5; |
|---|
| 1159 | } |
|---|
| 1160 | } |
|---|
| 1161 | } |
|---|
| 1162 | |
|---|
| 1163 | void gui_osd_draw_ev() { |
|---|
| 1164 | static char *s[6]={" ", "1/6", "1/3", "1/2", "2/3", "5/6"}; |
|---|
| 1165 | short ev=shooting_get_prop(PROPCASE_EV_CORRECTION_1); |
|---|
| 1166 | if (ev/96 || (ev==0)) sprintf(osd_buf, "EV: %d %s", abs(ev/96), s[abs(ev/16%6)]); |
|---|
| 1167 | else sprintf(osd_buf, "EV: %s ", s[abs(ev/16%6)]); |
|---|
| 1168 | if (ev>0) osd_buf[4]='+'; else if (ev<0) osd_buf[4]='-'; |
|---|
| 1169 | draw_string(conf.mode_ev_pos.x, conf.mode_ev_pos.y, osd_buf, conf.osd_color); |
|---|
| 1170 | |
|---|
| 1171 | } |
|---|
| 1172 | |
|---|
| 1173 | |
|---|
| 1174 | void gui_osd_draw_temp() { |
|---|
| 1175 | if (conf.show_temp == 1) |
|---|
| 1176 | { |
|---|
| 1177 | if (conf.temperature_unit == 0) |
|---|
| 1178 | { |
|---|
| 1179 | sprintf(osd_buf," opt: %i°",get_optical_temp()); |
|---|
| 1180 | } |
|---|
| 1181 | else |
|---|
| 1182 | { |
|---|
| 1183 | sprintf(osd_buf,"opt: %i°",(get_optical_temp()*18+320)/10); |
|---|
| 1184 | } |
|---|
| 1185 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1186 | } |
|---|
| 1187 | if (conf.show_temp==2) |
|---|
| 1188 | { |
|---|
| 1189 | if (conf.temperature_unit == 0) |
|---|
| 1190 | { |
|---|
| 1191 | sprintf(osd_buf," ccd: %i°",get_ccd_temp()); |
|---|
| 1192 | } |
|---|
| 1193 | else |
|---|
| 1194 | { |
|---|
| 1195 | sprintf(osd_buf,"ccd: %i°",(get_ccd_temp()*18+320)/10); |
|---|
| 1196 | } |
|---|
| 1197 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1198 | } |
|---|
| 1199 | if (conf.show_temp==3) |
|---|
| 1200 | { |
|---|
| 1201 | if (conf.temperature_unit == 0) |
|---|
| 1202 | { |
|---|
| 1203 | sprintf(osd_buf," batt:%i°",get_battery_temp()); |
|---|
| 1204 | } |
|---|
| 1205 | else |
|---|
| 1206 | { |
|---|
| 1207 | sprintf(osd_buf,"batt:%i°",(get_battery_temp()*18+320)/10); |
|---|
| 1208 | } |
|---|
| 1209 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1210 | } |
|---|
| 1211 | if (conf.show_temp==4) |
|---|
| 1212 | { |
|---|
| 1213 | if (conf.temperature_unit == 0) |
|---|
| 1214 | { |
|---|
| 1215 | sprintf(osd_buf," opt: %i°",get_optical_temp()); |
|---|
| 1216 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1217 | sprintf(osd_buf," ccd: %i°",get_ccd_temp()); |
|---|
| 1218 | draw_string(conf.temp_pos.x, conf.temp_pos.y+FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1219 | sprintf(osd_buf," batt:%i°",get_battery_temp()); |
|---|
| 1220 | draw_string(conf.temp_pos.x, conf.temp_pos.y+2*FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1221 | } |
|---|
| 1222 | else |
|---|
| 1223 | { |
|---|
| 1224 | sprintf(osd_buf,"opt: %i°",(get_optical_temp()*18+320)/10); |
|---|
| 1225 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1226 | sprintf(osd_buf,"ccd: %i°",(get_ccd_temp()*18+320)/10); |
|---|
| 1227 | draw_string(conf.temp_pos.x, conf.temp_pos.y+FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1228 | sprintf(osd_buf,"batt:%i°",(get_battery_temp()*18+320)/10); |
|---|
| 1229 | draw_string(conf.temp_pos.x, conf.temp_pos.y+2*FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1230 | } |
|---|
| 1231 | } |
|---|
| 1232 | } |
|---|
| 1233 | |
|---|
| 1234 | |
|---|
| 1235 | |
|---|
| 1236 | //------------------------------------------------------------------- |
|---|
| 1237 | #if CAM_EV_IN_VIDEO |
|---|
| 1238 | void gui_osd_draw_ev_video(int visible){ |
|---|
| 1239 | int x0=conf.ev_video_pos.x, y0=conf.ev_video_pos.y; |
|---|
| 1240 | int i, deltax; |
|---|
| 1241 | |
|---|
| 1242 | draw_filled_rect(x0,y0,x0+70,y0+24, visible? ((conf.osd_color&0xFF00))|(conf.osd_color>>8): COLOR_TRANSPARENT); |
|---|
| 1243 | |
|---|
| 1244 | if (!visible) { return; } |
|---|
| 1245 | |
|---|
| 1246 | for (i=0;i<9;i++) draw_line(x0+2+i*8, y0+12, x0+2+i*8, y0+12-(i&1 ? 5 : 10), conf.osd_color); |
|---|
| 1247 | for (i=0;i<9;i++) draw_line(x0+2+i*8+1, y0+12, x0+2+i*8+1, y0+12-(i&1 ? 5 : 10), conf.osd_color); |
|---|
| 1248 | |
|---|
| 1249 | deltax=8*get_ev_video(); |
|---|
| 1250 | |
|---|
| 1251 | x0+=deltax; |
|---|
| 1252 | |
|---|
| 1253 | draw_line(x0+34,y0+16,x0+34,y0+22,conf.osd_color); |
|---|
| 1254 | draw_line(x0+35,y0+16,x0+35,y0+22,conf.osd_color); |
|---|
| 1255 | |
|---|
| 1256 | draw_line(x0+32,y0+19,x0+32,y0+22,conf.osd_color); |
|---|
| 1257 | draw_line(x0+33,y0+18,x0+33,y0+22,conf.osd_color); |
|---|
| 1258 | draw_line(x0+36,y0+18,x0+36,y0+22,conf.osd_color); |
|---|
| 1259 | draw_line(x0+37,y0+19,x0+37,y0+22,conf.osd_color); |
|---|
| 1260 | |
|---|
| 1261 | } |
|---|
| 1262 | #endif |
|---|