Exemplo n.º 1
0
// 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;
}
Exemplo n.º 2
0
static int luaCB_set_led( lua_State* L )
{
    int to, to1, to2;
    to = luaL_checknumber( L, 1 );
    to1 = luaL_checknumber( L, 2 );
    to2 = 200;
    if( lua_isnumber( L, 3 ) )
        to2 = lua_tonumber( L, 3 );
    camera_set_led(to, to1, to2);
    return 0;
}
Exemplo n.º 3
0
//-------------------------------------------------------------------
// Core keyboard handler
long kbd_process()
{
    static int key_pressed;

    if (camera_info.perf.md_af_tuning)
    {
        switch (camera_info.perf.md_af_on_flag)
        {
        case 1:
            if (get_tick_count() >= (camera_info.perf.md_detect_tick + camera_info.perf.md_af_on_delay))
            {
                camera_info.perf.md_af_on_flag = 2;
                camera_set_led(camera_info.cam_af_led,1,200);
            }
            break;
        case 2:
            if (get_tick_count() >= (camera_info.perf.md_detect_tick + camera_info.perf.md_af_on_delay + camera_info.perf.md_af_on_time))
            {
                camera_info.perf.md_af_on_flag = 0;
                camera_set_led(camera_info.cam_af_led,0,0);
            }
            break;
        }
    }

    // Reset keyboard auto repeat if no buttons pressed
    if (kbd_get_pressed_key() == 0)
        last_kbd_key = 0;

    // Set clicked key for scripts.
    if (kbd_get_clicked_key())
    {
        camera_info.state.kbd_last_clicked = kbd_get_clicked_key();
        camera_info.state.kbd_last_clicked_time = get_tick_count();
    }

    // Set Shutter Half Press state for GUI task.
    camera_info.state.is_shutter_half_press = kbd_is_key_pressed(KEY_SHOOT_HALF);

	// Alternative keyboard mode stated/exited by pressing print key.
	// While running Alt. mode shoot key will start a script execution.

	// alt-mode switch and delay emulation
 
	if ( key_pressed  && !usb_remote_active ) 
	{
        if (kbd_is_key_pressed(conf.alt_mode_button)
                || ((key_pressed >= CAM_EMUL_KEYPRESS_DELAY)
                && (key_pressed < CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION)))
        {
            if (key_pressed <= CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                key_pressed++;
            if (key_pressed == CAM_EMUL_KEYPRESS_DELAY) 
                kbd_key_press(conf.alt_mode_button);
            else if (key_pressed == CAM_EMUL_KEYPRESS_DELAY+CAM_EMUL_KEYPRESS_DURATION) 
                kbd_key_release(conf.alt_mode_button);
            return 1;
        } 
        else if (kbd_get_pressed_key() == 0)
        {
            if (key_pressed < CAM_EMUL_KEYPRESS_DELAY)
            {
                if (!kbd_blocked) 
                    enter_alt();
                else
                    exit_alt();
            }
            key_pressed = 0;
            return 1;
        }
        return 1;
    }
       
    // auto iso shift
    if (camera_info.state.is_shutter_half_press && kbd_is_key_pressed(conf.alt_mode_button)) 
        return 0;

    if (kbd_is_key_pressed(conf.alt_mode_button)) 
	{
        key_pressed = 1;
        kbd_key_release_all();          
        return 1;
    }

#ifdef CAM_TOUCHSCREEN_UI
    extern int ts_process_touch();
    if (ts_process_touch())
    {
        gui_set_need_restore();
    }
#endif

    // deals with the rest

    if ( !kbd_blocked || usb_remote_active ) 
	{
		kbd_blocked = handle_usb_remote();
	}

    if (gui_kbd_process())
        return 1;

    action_stack_process_all();

    return kbd_blocked;
}