static void console_task( void* unused ) { console_init(); int dirty = 0; TASK_LOOP { // show the console only when there are no Canon dialogs on the screen if (console_visible && (display_idle() || is_pure_play_photo_or_movie_mode())) { if (dirty) console_draw(0); dirty = 1; } else if (dirty) { canon_gui_enable_front_buffer(1); dirty = 0; } else if (console_visible && !gui_menu_shown()) console_draw(1); if (!gui_menu_shown() && strlen(console_status_text)) { console_show_status(); } msleep(200); } }
static void movie_rec_halfshutter_step() { if (!movie_rec_key) return; if (!is_movie_mode() || !liveview_display_idle() || gui_menu_shown()) return; if (HALFSHUTTER_PRESSED) { if (movie_rec_key_long) { // need to keep halfshutter pressed for one second for (int i = 0; i < 10; i++) { msleep(100); if (!HALFSHUTTER_PRESSED) break; } if (!HALFSHUTTER_PRESSED) return; info_led_on(); NotifyBox(1000, "OK"); } while (HALFSHUTTER_PRESSED) msleep(50); if (NOT_RECORDING && ALLOW_MOVIE_START) schedule_movie_start(); else if(ALLOW_MOVIE_STOP) schedule_movie_end(); } }
/** * SET: show/hide console (while running, or 10 seconds after finished) * */ static unsigned int script_keypress_cbr(unsigned int key) { if (gui_menu_shown()) return 1; if (script_state == SCRIPT_RUNNING) { //~ if (handle_picoc_lib_keys(event)==0) return 0; } //~ extern int console_visible; if (script_state != SCRIPT_IDLE) // toggle show/hide { if (key == MODULE_KEY_PRESS_SET && display_idle()) { console_toggle(); return 0; } } /* if (script_state == SCRIPT_JUST_FINISHED) // after script finished, hide the console on first key press { if (key == MODULE_KEY_UNPRESS_SET) { return 0; } if (console_visible) { console_hide(); return 1; } }*/ return 1; }
static void run_script(const char *script) { extern int ml_started; while (!ml_started) msleep(100); // for startup scripts script_state = SCRIPT_RUNNING; msleep(500); console_clear(); console_show(); console_set_help_text("SET: show/hide"); console_set_status_text("Script running..."); int exit_code = tcc_compile_and_run(get_script_path(script_selected)); if (exit_code == 0) { console_puts( "Script finished.\n"); } else { console_printf( "Script error: %d.\n", exit_code); msleep(500); gui_stop_menu(); msleep(500); console_show(); } // restore some settings to normal, if script changed them //~ script_cleanup_af(); bmp_draw_to_idle(0); canon_gui_enable_front_buffer(0); beep(); script_state = SCRIPT_JUST_FINISHED; console_set_status_text("Script finished. "); msleep(500); redraw(); msleep(500); for (int i = 0; i < 100; i++) { msleep(100); if (gui_menu_shown()) break; if (get_halfshutter_pressed()) break; } console_hide(); script_state = SCRIPT_IDLE; console_set_status_text(""); }
//~ int get_focus_dir() { return focus_dir; } int is_follow_focus_active() { #ifdef FEATURE_FOLLOW_FOCUS if (!follow_focus) return 0; if (!lv) return 0; if (is_manual_focus()) return 0; if (!liveview_display_idle()) return 0; if (gui_menu_shown()) return 0; #ifdef FEATURE_LCD_SENSOR_SHORTCUTS if (display_sensor && get_lcd_sensor_shortcuts() && follow_focus_mode==0) return 0; #endif if (get_halfshutter_pressed()) return 0; return 1; #else return 0; #endif }
static void shutter_lock_step() { if (is_movie_mode()) // no effect in photo mode { int shutter = lens_info.raw_shutter; if (shutter_lock_value == 0) shutter_lock_value = shutter; // make sure it's some valid value if (!gui_menu_shown()) // lock shutter { if (shutter != shutter_lock_value) // i.e. revert it if changed { //~ lens_set_rawaperture(COERCE(lens_info.raw_aperture + shutter - shutter_lock_value, 16, 96)); msleep(100); lens_set_rawshutter(shutter_lock_value); msleep(100); } } else shutter_lock_value = shutter; // accept change from ML menu } }
/** * SET: show/hide console (while running, or 10 seconds after finished) * */ int handle_picoc_keys(struct event * event) { if (IS_FAKE(event)) return 1; // only process real buttons, not emulated presses if (gui_menu_shown()) return 1; if (script_state == SCRIPT_RUNNING) { //~ if (handle_picoc_lib_keys(event)==0) return 0; } extern int console_visible; if (script_state != SCRIPT_IDLE) // toggle show/hide { if (event->param == BGMT_PRESS_SET && display_idle()) { console_toggle(); return 0; } } if (script_state == SCRIPT_JUST_FINISHED) // after script finished, hide the console on first key press { if (event->param == BGMT_UNPRESS_SET) { return 0; } if (console_visible && event->param != GMT_OLC_INFO_CHANGED && #ifdef GMT_GUICMD_PRESS_BUTTON_SOMETHING event->param != GMT_GUICMD_PRESS_BUTTON_SOMETHING && #endif 1) { console_hide(); return 1; } } return 1; }
static unsigned int autoexpo_keypress(unsigned int key) { if(gui_menu_shown()) last_key = key; return 1; }
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 movtweak_step() { #ifdef FEATURE_MOVIE_REC_KEY movie_rec_halfshutter_step(); #endif #ifdef FEATURE_MOVIE_RESTART static int recording_prev = 0; #if defined(CONFIG_5D2) || defined(CONFIG_50D) || defined(CONFIG_7D) if(!RECORDING_H264 && recording_prev && !movie_was_stopped_by_set) // see also gui.c #else if(!RECORDING_H264 && recording_prev && wait_for_lv_err_msg(0)) #endif { if (movie_restart) { msleep(500); movie_start(); } } recording_prev = RECORDING_H264; if(!RECORDING_H264) { movie_was_stopped_by_set = 0; } #endif if (is_movie_mode()) { #ifdef CONFIG_WB_WORKAROUND kelvin_wb_workaround_step(); #endif #ifdef FEATURE_SHUTTER_LOCK if (shutter_lock) shutter_lock_step(); #endif } #ifdef FEATURE_FORCE_LIVEVIEW if ((enable_liveview && DLG_MOVIE_PRESS_LV_TO_RESUME) || (enable_liveview == 2 && DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED)) { msleep(200); // double-check if ((enable_liveview && DLG_MOVIE_PRESS_LV_TO_RESUME) || (enable_liveview == 2 && DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED)) force_liveview(); } #endif //~ update_lvae_for_autoiso_n_displaygain(); #ifdef FEATURE_FORCE_HDMI_VGA if (hdmi_force_vga && is_movie_mode() && (lv || PLAY_MODE) && !gui_menu_shown()) { if (hdmi_code == 5) { msleep(1000); gui_uilock(UILOCK_EVERYTHING); BMP_LOCK( ChangeHDMIOutputSizeToVGA(); msleep(300); ) msleep(2000); gui_uilock(UILOCK_NONE); msleep(5000); }
static void focus_stack( int count, int num_steps, int skip_frame, // skip first frame for stack or original frame for bracket int pre_focus, // zoom to start position and then only go in one direction int is_bracket // perform dumb bracketing if no range is set via follow focus ) { focus_stack_should_stop = 0; int delay = 0; if (drive_mode == DRIVE_SELFTIMER_2SEC) delay = 2; else if (drive_mode == DRIVE_SELFTIMER_REMOTE) delay = 10; if (delay) wait_notify(delay, "Focus stack"); if (focus_stack_check_stop()) return; NotifyBox(1000, "Focus stack: %dx%d", count, ABS(num_steps) ); msleep(1000); int prev_drive_mode = set_drive_single(); int f0 = hdr_script_get_first_file_number(skip_frame); fstack_zoom = lv_dispsize; // if we start the focus stack zoomed in, keep this zoom level throughout the operation int focus_moved_total = 0; if (pre_focus) { NotifyBox(1000, "Pre-focusing %d steps...", ABS(num_steps*pre_focus) ); focus_stack_ensure_preconditions(); if (LensFocus(-num_steps*pre_focus) == 0) { beep(); return; } focus_moved_total -= (num_steps*pre_focus); } int i, real_steps; for( i=0 ; i < count ; i++ ) { if (focus_stack_check_stop()) break; NotifyBox(1000, "Focus stack: %d of %d", i+1, count ); focus_stack_ensure_preconditions(); if (focus_stack_check_stop()) break; if (gui_menu_shown() || CURRENT_DIALOG_MAYBE == 2) break; // menu open? stop here if (!( (!is_bracket && skip_frame && (i == 0)) || // first frame in SNAP-stack (is_bracket && (skip_frame == 1) && (i == 0)) || // first frame in SNAP-bracket (is_bracket && (skip_frame == count) && (i == count-1)) // last frame in SNAP-bracket )) { hdr_shot(0,1); msleep(300); } if( count-1 == i ) break; focus_stack_ensure_preconditions(); if (focus_stack_check_stop()) break; // skip orginal frame on SNAP-bracket (but dont double-focus if last frame) if (is_bracket && skip_frame && (skip_frame == i+2) && (skip_frame != count)) { real_steps = num_steps*2; i++; } else { real_steps = num_steps; } NotifyBox(1000, "Focusing %d steps...", ABS(real_steps)); msleep(500); if (LensFocus(real_steps) == 0) break; focus_moved_total += real_steps; } msleep(1000); NotifyBoxHide(); // Restore to the starting focus position if (focus_moved_total) { NotifyBox(1000, "Reversing %d steps...", ABS(focus_moved_total)); msleep(500); focus_stack_ensure_preconditions(); LensFocus(-focus_moved_total); NotifyBoxHide(); } if (i >= count-1) { NotifyBox(2000, "Focus stack done!" ); msleep(1000); hdr_create_script(f0, 1); } else { NotifyBox(2000, "Focus stack not completed"); } if (prev_drive_mode != -1) lens_set_drivemode(prev_drive_mode); }
static int focus_stack_check_stop() { if (gui_menu_shown()) focus_stack_should_stop = 1; if (CURRENT_DIALOG_MAYBE == 2) focus_stack_should_stop = 1; // Canon menu open return focus_stack_should_stop; }