// Stack process function for running MD logic static int action_stack_AS_MOTION_DETECTOR() { // MD testing with AF LED if (camera_info.perf.md_af_tuning) { if (camera_info.perf.af_led_on == 0) { camera_info.perf.af_led_on--; camera_info.perf.af_led.tick_count = get_tick_count(); camera_set_led(camera_info.cam_af_led,1,200); } else if (camera_info.perf.af_led_on > 0) { camera_info.perf.af_led_on--; } } if (md_detect_motion() == 0) { if (motion_detector.return_value) { camera_info.perf.md_detect_tick = get_tick_count(); } // MD testing with AF LED if (camera_info.perf.md_af_tuning) { camera_set_led(camera_info.cam_af_led,0,0); if (motion_detector.return_value) { time_counter_capture(&camera_info.perf.af_led); } } // We need to recover the motion detector's // result and push it onto the thread's stack. libscriptapi->set_as_ret(motion_detector.return_value); action_pop_func(0); return 1; } return 0; }
void process_script() { long t; int Lres; // process stack operations if (kbd_int_stack_ptr){ switch (KBD_STACK_PREV(1)){ case SCRIPT_MOTION_DETECTOR: if(md_detect_motion()==0){ kbd_int_stack_ptr-=1; if (L) { // We need to recover the motion detector's // result from ubasic variable 0 and push // it onto the thread's stack. -- AUJ lua_pushnumber( Lt, ubasic_get_variable(0) ); } } return; case SCRIPT_PRESS: kbd_key_press(KBD_STACK_PREV(2)); kbd_int_stack_ptr-=2; // pop op. return; case SCRIPT_RELEASE: kbd_key_release(KBD_STACK_PREV(2)); kbd_int_stack_ptr-=2; // pop op. return; case SCRIPT_SLEEP: t = get_tick_count(); // FIXME take care if overflow occurs if (delay_target_ticks == 0){ /* setup timer */ delay_target_ticks = t+KBD_STACK_PREV(2); } else { if (delay_target_ticks <= t){ delay_target_ticks = 0; kbd_int_stack_ptr-=2; // pop sleep op. } } return; case SCRIPT_PR_WAIT_SAVE: state_shooting_progress = SHOOTING_PROGRESS_NONE; state_expos_recalculated = 0; histogram_stop(); kbd_int_stack_ptr-=1; // pop op. return; case SCRIPT_WAIT_SAVE:{ if (state_shooting_progress == SHOOTING_PROGRESS_DONE) kbd_int_stack_ptr-=1; // pop op. return; } case SCRIPT_WAIT_FLASH:{ if (shooting_is_flash_ready()) kbd_int_stack_ptr-=1; // pop op. return; } case SCRIPT_WAIT_EXPHIST:{ if (state_expos_recalculated) { kbd_int_stack_ptr-=1; // pop op. state_expos_under = under_exposed; state_expos_over = over_exposed; } return; } case SCRIPT_PR_WAIT_EXPHIST: { if (shooting_in_progress() || mvideo) { state_expos_recalculated = 0; histogram_restart(); kbd_int_stack_ptr-=1; // pop op. } return; } case SCRIPT_WAIT_CLICK: { t = get_tick_count(); if (delay_target_ticks == 0){ /* setup timer */ delay_target_ticks = t+((KBD_STACK_PREV(2))?KBD_STACK_PREV(2):86400000); } else { kbd_last_clicked = kbd_get_clicked_key(); if (kbd_last_clicked || delay_target_ticks <= t) { if (!kbd_last_clicked) kbd_last_clicked=0xFFFF; delay_target_ticks = 0; kbd_int_stack_ptr-=2; // pop op. } } return; } default: /*finished();*/ script_end(); } } if (state_kbd_script_run != 3) { if( L ) { int top; if (state_lua_kbd_first_call_to_resume) { state_lua_kbd_first_call_to_resume = 0; top = 0; } else { top = lua_gettop(Lt); } Lres = lua_resume( Lt, top ); if (Lres != LUA_YIELD && Lres != 0) { script_console_add_line( lua_tostring( Lt, -1 ) ); wait_and_end(); return; } if (Lres != LUA_YIELD) { script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); script_end(); } } else { ubasic_run(); if (ubasic_finished()) { script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); script_end(); } } } }