コード例 #1
0
ファイル: main.c プロジェクト: c10ud/CHDK
void core_spytask()
{
    int cnt = 1;
    int i=0;
#ifdef CAM_HAS_GPS
    int gps_delay_timer = 200 ;
    int gps_state = -1 ;
#endif
#if (OPT_DISABLE_CAM_ERROR)
    extern void DisableCamError();
    int dce_cnt=0;
    int dce_prevmode=0;
    int dce_nowmode;
#endif
    
    parse_version(&chdk_version, BUILD_NUMBER, BUILD_SVNREV);

    // Init camera_info bits that can't be done statically
    camera_info_init();

    spytask_can_start=0;

    extern void aram_malloc_init(void);
    aram_malloc_init();

    extern void exmem_malloc_init(void);
    exmem_malloc_init();

#ifdef CAM_CHDK_PTP
    extern void init_chdk_ptp_task();
    init_chdk_ptp_task();
#endif

    while((i++<400) && !spytask_can_start) msleep(10);

    started();
    msleep(50);
    finished();

#if !CAM_DRYOS
    drv_self_unhide();
#endif

    conf_restore();

    extern void gui_init();
    gui_init();

#if CAM_CONSOLE_LOG_ENABLED
    extern void cam_console_init();
    cam_console_init();
#endif

    static char *chdk_dirs[] =
    {
        "A/CHDK",
        "A/CHDK/FONTS",
        "A/CHDK/SYMBOLS",
        "A/CHDK/SCRIPTS",
        "A/CHDK/LANG",
        "A/CHDK/BOOKS",
        "A/CHDK/MODULES",
        "A/CHDK/MODULES/CFG",
        "A/CHDK/GRIDS",
        "A/CHDK/CURVES",
        "A/CHDK/DATA",
        "A/CHDK/LOGS",
        "A/CHDK/EDGE",
    };
    for (i = 0; i < sizeof(chdk_dirs) / sizeof(char*); i++)
        mkdir_if_not_exist(chdk_dirs[i]);

    no_modules_flag = stat("A/CHDK/MODULES/FSELECT.FLT",0) ? 1 : 0 ;

    // Calculate the value of get_tick_count() when the clock ticks over to the next second
    // Used to calculate the SubSecondTime value when saving DNG files.
    long t1, t2;
    t2 = time(0);
    do
    {
        t1 = t2;
        camera_info.tick_count_offset = get_tick_count();
        t2 = time(0);
        msleep(10);
    } while (t1 != t2);
    camera_info.tick_count_offset = camera_info.tick_count_offset % 1000;

    // remote autostart
    if (conf.script_startup==SCRIPT_AUTOSTART_ALWAYS)
    {
        script_autostart();
    }
    else if (conf.script_startup==SCRIPT_AUTOSTART_ONCE)
    {
        conf.script_startup=SCRIPT_AUTOSTART_NONE;
        conf_save();
        script_autostart();
    }

    shooting_init();

    while (1)
    {
        // Set up camera mode & state variables
        mode_get();
        // update HDMI power override based on mode and remote settings
#ifdef CAM_REMOTE_HDMI_POWER_OVERRIDE
        extern void update_hdmi_power_override(void);
        update_hdmi_power_override();
#endif

        extern void set_palette();
        set_palette();

#if (OPT_DISABLE_CAM_ERROR)
        dce_nowmode = camera_info.state.mode_play;
        if (dce_prevmode==dce_nowmode)
        {                       //no mode change
            dce_cnt++;          // overflow is not a concern here
        }
        else
        {                       //mode has changed
            dce_cnt=0;
        }
        if (dce_cnt==100)
        {                       // 1..2s past play <-> rec mode change
            DisableCamError();
        }
        dce_prevmode=dce_nowmode;
#endif

        if ( memdmptick && (get_tick_count() >= memdmptick) )
        {
            memdmptick = 0;
            dump_memory();
        }

#ifdef CAM_HAS_GPS
        if ( --gps_delay_timer == 0 )
        {
            gps_delay_timer = 50 ;
            if ( gps_state != (int)conf.gps_on_off )
            {
                gps_state = (int)conf.gps_on_off ;
                init_gps_startup(!gps_state) ; 
            }
        }
#endif        
        
        // Change ALT mode if the KBD task has flagged a state change
        gui_activate_alt_mode();

#ifdef  CAM_LOAD_CUSTOM_COLORS
        // Color palette function
        extern void load_chdk_palette();
        load_chdk_palette();
#endif

        if (raw_data_available)
        {
            raw_process();
            extern void hook_raw_save_complete();
            hook_raw_save_complete();
            raw_data_available = 0;
#ifdef CAM_HAS_GPS
            if (((int)conf.gps_on_off == 1) && ((int)conf.gps_waypoint_save == 1)) gps_waypoint();
#endif
#if defined(CAM_CALC_BLACK_LEVEL)
            // Reset to default in case used by non-RAW process code (e.g. raw merge)
            camera_sensor.black_level = CAM_BLACK_LEVEL;
#endif
            continue;
        }

        if ((camera_info.state.state_shooting_progress != SHOOTING_PROGRESS_PROCESSING) || recreview_hold)
        {
            if (((cnt++) & 3) == 0)
                gui_redraw();
        }

        if (camera_info.state.state_shooting_progress != SHOOTING_PROGRESS_PROCESSING)
        {
            if (conf.show_histo)
                libhisto->histogram_process();

            if ((camera_info.state.gui_mode_none || camera_info.state.gui_mode_alt) && conf.edge_overlay_thresh && conf.edge_overlay_enable)
            {
                // We need to skip first tick because stability
                if (chdk_started_flag)
                {
                    libedgeovr->edge_overlay();
                }
            }
        }

        if ((camera_info.state.state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) && (!shooting_in_progress()))
        {
            camera_info.state.state_shooting_progress = SHOOTING_PROGRESS_DONE;
        }

        i = 0;

#ifdef DEBUG_PRINT_TO_LCD
        sprintf(osd_buf, "%d", cnt );	// modify cnt to what you want to display
        draw_txt_string(1, i++, osd_buf, user_color(conf.osd_color));
#endif
#if defined(OPT_FILEIO_STATS)
        sprintf(osd_buf, "%3d %3d %3d %3d %3d %3d %3d %4d",
                camera_info.fileio_stats.fileio_semaphore_errors, camera_info.fileio_stats.close_badfile_count,
                camera_info.fileio_stats.write_badfile_count, camera_info.fileio_stats.open_count,
                camera_info.fileio_stats.close_count, camera_info.fileio_stats.open_fail_count,
                camera_info.fileio_stats.close_fail_count, camera_info.fileio_stats.max_semaphore_timeout);
        draw_txt_string(1, i++, osd_buf,user_color( conf.osd_color));
#endif

        if (camera_info.perf.md_af_tuning)
        {
            sprintf(osd_buf, "MD last %-4d min %-4d max %-4d avg %-4d", 
                camera_info.perf.af_led.last, camera_info.perf.af_led.min, camera_info.perf.af_led.max, 
                (camera_info.perf.af_led.count>0)?camera_info.perf.af_led.sum/camera_info.perf.af_led.count:0);
            draw_txt_string(1, i++, osd_buf, user_color(conf.osd_color));
        }

        // Process async module unload requests
        module_tick_unloader();

        msleep(20);
        chdk_started_flag=1;
    }
}
コード例 #2
0
ファイル: main.c プロジェクト: BioDesignRealWorld/CHDK
void core_spytask()
{
    int cnt = 1;
    int i=0;

    // Init camera_info bits that can't be done statically
    camera_info_init();

    spytask_can_start=0;

#ifdef OPT_EXMEM_MALLOC
    extern void exmem_malloc_init(void);
    exmem_malloc_init();
#endif

#ifdef CAM_CHDK_PTP
    extern void init_chdk_ptp_task();
    init_chdk_ptp_task();
#endif

    while((i++<400) && !spytask_can_start) msleep(10);

    started();
    msleep(50);
    finished();

#if !CAM_DRYOS
    drv_self_unhide();
#endif

    conf_restore();

    extern void gui_init();
    gui_init();

#if CAM_CONSOLE_LOG_ENABLED
    extern void cam_console_init();
    cam_console_init();
#endif

    mkdir("A/CHDK");
    mkdir("A/CHDK/FONTS");
    mkdir("A/CHDK/SYMBOLS");
    mkdir("A/CHDK/SCRIPTS");
    mkdir("A/CHDK/LANG");
    mkdir("A/CHDK/BOOKS");
    mkdir("A/CHDK/MODULES");
    mkdir("A/CHDK/MODULES/CFG");
    mkdir("A/CHDK/GRIDS");
    mkdir("A/CHDK/CURVES");
    mkdir("A/CHDK/DATA");
    mkdir("A/CHDK/LOGS");
    mkdir("A/CHDK/EDGE");

    // Calculate the value of get_tick_count() when the clock ticks over to the next second
    // Used to calculate the SubSecondTime value when saving DNG files.
    long t1, t2;
    t2 = time(0);
    do
    {
        t1 = t2;
        camera_info.tick_count_offset = get_tick_count();
        t2 = time(0);
        msleep(10);
    } while (t1 != t2);
    camera_info.tick_count_offset = camera_info.tick_count_offset % 1000;

    // remote autostart
    if (conf.script_startup==1)
    {
        script_autostart();
    }
    else if (conf.script_startup==2)
    {
        conf.script_startup=0;
        conf_save();
        script_autostart();
    }

    shooting_init();

    while (1)
    {
        if ( memdmptick && (get_tick_count() >= memdmptick) )
        {
            memdmptick = 0;
            dump_memory();
        }
        // Change ALT mode if the KBD task has flagged a state change
        gui_activate_alt_mode();

#ifdef  CAM_LOAD_CUSTOM_COLORS
        // Color palette function
        extern void load_chdk_palette();
        load_chdk_palette();
#endif

        if (raw_data_available)
        {
            raw_process();
            extern void hook_raw_save_complete();
            hook_raw_save_complete();
            raw_data_available = 0;
#ifdef CAM_HAS_GPS
            if( (int)conf.gps_waypoint_save == 1 ) wegpunkt();
#endif
            continue;
        }

        if ((camera_info.state.state_shooting_progress != SHOOTING_PROGRESS_PROCESSING) || recreview_hold)
        {
            if (((cnt++) & 3) == 0)
                gui_redraw();
        }

        if (camera_info.state.state_shooting_progress != SHOOTING_PROGRESS_PROCESSING)
        {
            if (conf.show_histo)
                histogram_process();

#ifdef OPT_EDGEOVERLAY
            if(((gui_get_mode()==GUI_MODE_NONE) || (gui_get_mode()==GUI_MODE_ALT)) && conf.edge_overlay_thresh && conf.edge_overlay_enable)
            {
                // We need to skip first tick because stability
                static int skip_counter=1;

                if (skip_counter>0)
                {
                    skip_counter--;
                }
                else
                {
                    libedgeovr->edge_overlay();
                }
            }
#endif
        }

        if ((camera_info.state.state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) && (!shooting_in_progress()))
        {
            camera_info.state.state_shooting_progress = SHOOTING_PROGRESS_DONE;
        }

        i = 0;

#ifdef DEBUG_PRINT_TO_LCD
        sprintf(osd_buf, "%d", cnt );	// modify cnt to what you want to display
        draw_txt_string(1, i++, osd_buf, conf.osd_color);
#endif

        if (camera_info.perf.md_af_tuning)
        {
            sprintf(osd_buf, "MD last %-4d min %-4d max %-4d avg %-4d", 
                camera_info.perf.af_led.last, camera_info.perf.af_led.min, camera_info.perf.af_led.max, 
                (camera_info.perf.af_led.count>0)?camera_info.perf.af_led.sum/camera_info.perf.af_led.count:0);
            draw_txt_string(1, i++, osd_buf, conf.osd_color);
        }

        // Process async module unload requests
        module_tick_unloader();

        msleep(20);
        chdk_started_flag=1;
    }
}
コード例 #3
0
ファイル: main.c プロジェクト: barryk/CHDK-SD1200
void core_spytask()
{
    int cnt = 1;
    int i=0;

    raw_need_postprocess = 0;

    spytask_can_start=0;

    while((i++<400) && !spytask_can_start) msleep(10);

    started();
    msleep(50);
    finished();
    drv_self_unhide();

    conf_restore();
    gui_init();

#if CAM_CONSOLE_LOG_ENABLED
    console_init();
#endif

    mkdir("A/CHDK");
    mkdir("A/CHDK/FONTS");
    mkdir("A/CHDK/SYMBOLS");
    mkdir("A/CHDK/SCRIPTS");
    mkdir("A/CHDK/LANG");
    mkdir("A/CHDK/BOOKS");
    mkdir("A/CHDK/GRIDS");
#ifdef OPT_CURVES
    mkdir("A/CHDK/CURVES");
#endif
    mkdir("A/CHDK/DATA");
    mkdir("A/CHDK/LOGS");
#ifdef OPT_EDGEOVERLAY
    mkdir("A/CHDK/EDGE");
#endif
    auto_started = 0;

    if (conf.script_startup==1) script_autostart();				// remote autostart
    if (conf.script_startup==2) {
        conf.script_startup=0;
        conf_save();
        script_autostart();
    }
    while (1) {

        if (raw_data_available) {
            raw_need_postprocess = raw_savefile();
            hook_raw_save_complete();
            raw_data_available = 0;
            continue;
        }

        if (state_shooting_progress != SHOOTING_PROGRESS_PROCESSING) {
            if (((cnt++) & 3) == 0)
                gui_redraw();

            histogram_process();
#ifdef OPT_EDGEOVERLAY
            if(conf.edge_overlay_thresh && conf.edge_overlay_enable) edge_overlay();
#endif
        }

        if ((state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) && (!shooting_in_progress())) {
            state_shooting_progress = SHOOTING_PROGRESS_DONE;
            if (raw_need_postprocess) raw_postprocess();
        }

        msleep(20);
    }
}