Exemplo n.º 1
0
Arquivo: console.c Projeto: c10ud/CHDK
void console_draw(int force_redraw)
{
    char buf[MAX_CONSOLE_LINE_LENGTH+1];

    console_ensure_inited();

    twoColors col = user_color(conf.osd_color);

    long t = get_tick_count();
    if (t <= console_last_modified + (conf.console_timeout*1000))               // Redraw if changed
    {
        if ((console_displayed == 0) || force_redraw)
        {
            int y = (console_y + console_max_lines - 1) * FONT_HEIGHT;
            int x = console_x * FONT_WIDTH + camera_screen.disp_left;

            int c, i;
            for (c = 0, i = console_cur_line; c < console_num_lines; ++c, --i)
            {
                if (i < 0) i = MAX_CONSOLE_HISTORY-1;
                strncpy(buf,console_buf[i],console_line_length);
                buf[console_line_length] = 0;
                draw_string_justified(x, y - c * FONT_HEIGHT, buf, col, 0, console_line_length * FONT_WIDTH, TEXT_LEFT|TEXT_FILL);

                console_displayed = 1;
            }
        }
    }
    else if (console_displayed && !camera_info.state.state_kbd_script_run)      // Erase if drawn and script not running
    {
        gui_set_need_restore();
        console_displayed = 0;
    }
}
Exemplo n.º 2
0
static void gui_load_script_selected(const char *fn) {
    if (fn) {
        gui_menu_cancel_redraw();   // Stop menu redraw until after menu rebuilt from script params
        save_params_values(0);
        script_load(fn);
        gui_set_need_restore();
    }
}
Exemplo n.º 3
0
static void gui_reset_script_default(int arg)
{
    gui_menu_cancel_redraw();       // Stop menu redraw until after menu rebuilt from script params
    save_params_values(0);
    conf.script_file[0] = 0;        // Reset loaded script
    script_load(conf.script_file);
    gui_set_need_restore();
}
Exemplo n.º 4
0
//-------------------------------------------------------------------
static void rinit()
{
	// Erase screen if switching from user menu to main menu
	// in case the user menu is larger than the main menu
	// otherwise it leaves remnants of the user menu above and below
	// the main menu.
    gui_set_need_restore();
	gui_menu_init(&root_menu);
}
Exemplo n.º 5
0
static void kbd_shortcut(int button, int *var, int max_value)
{
    if (kbd_is_key_clicked(button))
    {
        (*var)++;
        if (*var > max_value)
        {
            *var = 0;
            gui_set_need_restore();
        }
    }
}
Exemplo n.º 6
0
void gui_kbd_shortcuts()
{
    static int half_disp_press_old=0;
    
    if (camera_info.state.is_shutter_half_press)
    {
        if (conf.enable_shortcuts == 1)
        {
            kbd_shortcut(SHORTCUT_TOGGLE_ZEBRA, &conf.zebra_draw, 1);
            kbd_shortcut(SHORTCUT_TOGGLE_HISTO, &conf.show_histo, SHOW_HISTO_HALF);
            kbd_shortcut(SHORTCUT_TOGGLE_OSD, &conf.show_osd, 1);
            kbd_shortcut(SHORTCUT_DISABLE_OVERRIDES, &conf.override_disable, 1);
        }
#if !CAM_HAS_MANUAL_FOCUS && CAM_HAS_ZOOM_LEVER
        // Todo, check for AF and if its running, don't override
        if (kbd_is_key_pressed(SHORTCUT_SD_SUB)) {
            if (!(conf.override_disable==1) && shooting_can_focus() && shooting_get_common_focus_mode()) {
                gui_subj_dist_override_value_enum(-1,0);
                shooting_set_focus(shooting_get_subject_distance_override_value(),SET_NOW);
            }
        } else if (kbd_is_key_pressed(SHORTCUT_SD_ADD)) {
            if (!(conf.override_disable==1) && shooting_can_focus() && shooting_get_common_focus_mode()) {
                gui_subj_dist_override_value_enum(1,0);
                shooting_set_focus(shooting_get_subject_distance_override_value(),SET_NOW);
            }
        }
#endif
    }

    half_disp_press = camera_info.state.mode_photo && camera_info.state.is_shutter_half_press && kbd_is_key_pressed(KEY_DISPLAY);
    if (half_disp_press && !half_disp_press_old)
        gui_set_need_restore();
#ifdef CAM_DISP_ALT_TEXT
    if (half_disp_press)
    {
        extern void gui_reset_alt_helper();
        gui_reset_alt_helper();
    }
#endif
    half_disp_press_old = half_disp_press;
}
Exemplo n.º 7
0
static void reset_edge_overlay()
{
    if (smbuf != NULL)
    {
        free(smbuf);
        smbuf = NULL;
    }

    if (edgebuf != NULL)
    {
        gui_set_need_restore();     // Refresh display to restore Canon OSD
        bv_free(edgebuf);
        edgebuf = NULL;
    }

    fsm_state = EDGE_LIVE;
    slice = 0;

    // Clean up state saved in core CHDK
    module_save_edge(edgebuf, fsm_state);
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
Arquivo: console.c Projeto: c10ud/CHDK
void console_redraw()
{
    gui_set_need_restore();
    console_displayed = 0;
    console_last_modified = get_tick_count();
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
//-------------------------------------------------------------------
// Full screen erase and redraw of menu
static void gui_menu_erase_and_redraw()
{
    gui_menu_redraw = 2;
    gui_set_need_restore();
}