// Push a button release action onto the stack // Can only be called from an action stack void action_push_release(long key) { // WARNING stack program flow is reversed action_push_delay(camera_info.cam_key_release_delay); action_push(key); action_push_func(action_stack_AS_RELEASE); }
// Push a button press action onto the stack // Can only be called from an action stack void action_push_press(long key) { // WARNING stack program flow is reversed action_push_delay(camera_info.cam_key_press_delay); action_push(key); action_push_func(action_stack_AS_PRESS); }
// Push the core 'shoot' actions onto the stack // Note: action stack actions are processed in reverse order void action_push_shoot(int retry) { // Init shooting state camera_info.state.state_shooting_progress = SHOOTING_PROGRESS_NONE; // Wait for camera ready to shoot or timeout action_push(retry); action_push(get_tick_count() + 5000); action_push_func(action_stack_AS_WAIT_SHOOTING_IN_PROGRESS); // Half press shutter action_push_press(KEY_SHOOT_HALF); }
// Action stack function - wait for camera ready to shoot after half press, or timeout // parameters - timeout delay, retry flag static int action_stack_AS_WAIT_SHOOTING_IN_PROGRESS() { // Get parameters int timeout = action_top(2); int retry = action_top(3); if (shooting_in_progress() || camera_info.state.mode_video) { // Remove this action from the stack action_pop_func(2); // Push the rest of the shoot actions onto the stack (reversed flow) // Push 'retry if failed' parameter for exit action action_push(retry); action_push_func(action_stack_AS_WAIT_SHOOTING_DONE); // Full press shutter action_push_click(KEY_SHOOT_FULL); // Wait for flash recharged action_push_func(action_stack_AS_WAIT_FLASH); return 1; } if (get_tick_count() >= timeout) { // Remove this action from the stack action_pop_func(2); // Return 'shoot' status to script - 1 = shutter half press timed out libscriptapi->set_as_ret(1); return 1; } return 0; }
static void md_kbd_sched_immediate_shoot(int no_release) { action_pop_func(0);// REMOVE MD ITEM // stack operations are reversed! if (!no_release) // only release shutter if allowed { action_push_release(KEY_SHOOT_FULL); } if (camera_info.cam_key_press_delay > 0) action_push_delay(camera_info.cam_key_press_delay); action_push_func(action_stack_AS_MOTION_DETECTOR); // it will removed right after exit from this function kbd_key_press(KEY_SHOOT_FULL); // not a stack operation... pressing right now // MD testing with AF LED if (camera_info.perf.md_af_tuning) { camera_info.perf.md_af_on_flag = 1; } }
int md_init_motion_detector ( int columns, int rows, int pixel_measure_mode, int detection_timeout, int measure_interval, int threshold, int draw_grid, int clipping_region_mode, int clipping_region_column1, int clipping_region_row1, int clipping_region_column2, int clipping_region_row2, int parameters, int pixels_step, int msecs_before_trigger ) { #ifdef OPT_MD_DEBUG motion_detector.comp_calls_cnt=0; #endif if( pixel_measure_mode != MD_MEASURE_MODE_Y && pixel_measure_mode != MD_MEASURE_MODE_U && pixel_measure_mode != MD_MEASURE_MODE_V && pixel_measure_mode != MD_MEASURE_MODE_R && pixel_measure_mode != MD_MEASURE_MODE_G && pixel_measure_mode != MD_MEASURE_MODE_B ) { pixel_measure_mode = MD_MEASURE_MODE_Y; } // Sanity check on grid size if (columns < 1) columns = 3; if (rows < 1) rows = 3; // If too many grid cells, reduce larger of columns and rows until it fits while ((columns * rows) > MOTION_DETECTOR_CELLS) { if (columns > rows) columns--; else rows--; } if(msecs_before_trigger<0) { msecs_before_trigger=0; } if (pixels_step<1) { pixels_step=1; } if(detection_timeout<0) { detection_timeout=0; } if(measure_interval<0) { measure_interval=0; } if(threshold<0) { threshold=0; } motion_detector.msecs_before_trigger = msecs_before_trigger; motion_detector.parameters = parameters; motion_detector.pixels_step = pixels_step; motion_detector.columns = columns; motion_detector.rows = rows; motion_detector.return_value = 0; motion_detector.pixel_measure_mode = pixel_measure_mode; motion_detector.timeout = detection_timeout; motion_detector.measure_interval = measure_interval; motion_detector.threshold = threshold; motion_detector.draw_grid = draw_grid; if (clipping_region_column1>clipping_region_column2) { motion_detector.clipping_region_column2 = clipping_region_column1; motion_detector.clipping_region_column1 = clipping_region_column2; } else { motion_detector.clipping_region_column2 = clipping_region_column2; motion_detector.clipping_region_column1 = clipping_region_column1; } if (clipping_region_row1>clipping_region_row2) { motion_detector.clipping_region_row2 = clipping_region_row1; motion_detector.clipping_region_row1 = clipping_region_row2; } else { motion_detector.clipping_region_row2 = clipping_region_row2; motion_detector.clipping_region_row1 = clipping_region_row1; } if (clipping_region_mode!=MD_REGION_NONE && clipping_region_mode!=MD_REGION_INCLUDE && clipping_region_mode!=MD_REGION_EXCLUDE) { clipping_region_mode=MD_REGION_NONE; } motion_detector.clipping_region_mode = clipping_region_mode; motion_detector.detected_cells = 0; motion_detector.previous_picture_is_ready = 0; motion_detector.start_time=get_tick_count(); motion_detector.last_measure_time = motion_detector.start_time - motion_detector.measure_interval; motion_detector.running = 1; camera_info.perf.af_led_on = 100; action_push_func(action_stack_AS_MOTION_DETECTOR); gui_set_need_restore(); return 1; }
// Push a sleep onto the stack // Can only be called from an action stack void action_push_delay(long msec) { action_push(msec); action_push_func(action_stack_AS_SLEEP); }