Changeset 1035 for trunk/core/raw.c


Ignore:
Timestamp:
01/09/11 03:15:50 (2 years ago)
Author:
reyalP
Message:

scriptless badpixel.bin creation, from ultimA in http://chdk.setepontos.com/index.php?topic=5793.msg59376#msg59376

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/raw.c

    r1017 r1035  
    77        #include "dng.h" 
    88        #include "math.h" 
     9        #include "keyboard.h" 
     10    #include "action_stack.h" 
     11    #include "gui_draw.h" 
     12    #include "gui_mbox.h" 
     13    #include "gui_lang.h" 
    914#endif 
    1015#ifdef OPT_CURVES 
     
    5055//------------------------------------------------------------------- 
    5156 
    52 unsigned int get_bad_count_and_write_file(char *fn){ 
     57unsigned int get_bad_count_and_write_file(const char *fn){ 
    5358 int count=0; 
    5459 unsigned short c[2]; 
     
    123128 
    124129    // ! ! ! exclusively for special script which creates badpixel.bin ! ! ! 
     130    // NOTE: get_bad_count_and_write_file() must be called from here and cannot be called 
     131    // outside of this function. 
    125132    if (conf.save_raw==255) conf.save_raw=get_bad_count_and_write_file("A/CHDK/bad_tmp.bin"); 
    126133    // 
     
    442449 return binary_count; 
    443450} 
    444 #endif 
     451 
     452// ----------------------------------------------- 
     453 
     454enum BadpixelFSM 
     455{ 
     456    BADPIX_START, 
     457    BADPIX_S1, 
     458    BADPIX_S2 
     459}; 
     460 
     461int badpixel_task_stack(long p) 
     462{ 
     463    static unsigned int badpix_cnt1, badpix_cnt2; 
     464    static int raw_conf_bck; 
     465 
     466    switch(p) 
     467    { 
     468 
     469    case BADPIX_START: 
     470        action_pop(); 
     471 
     472        console_clear(); 
     473        console_add_line("Wait please... "); 
     474        console_add_line("This takes a few seconds,"); 
     475        console_add_line("don't panic!"); 
     476         
     477        raw_conf_bck = conf.save_raw; 
     478        conf.save_raw = 255; 
     479         
     480        shooting_set_tv96_direct(96, SET_LATER); 
     481        action_push(BADPIX_S1); 
     482        action_push(AS_SHOOT); 
     483        action_push_delay(3000); 
     484        break; 
     485    case BADPIX_S1: 
     486        action_pop();         
     487 
     488        badpix_cnt1 = conf.save_raw; 
     489        shooting_set_tv96_direct(96, SET_LATER); 
     490 
     491        action_push(BADPIX_S2); 
     492        action_push(AS_SHOOT); 
     493        break; 
     494    case BADPIX_S2: 
     495        action_pop(); 
     496 
     497        badpix_cnt2 = conf.save_raw; 
     498        conf.save_raw = raw_conf_bck; 
     499 
     500        console_clear(); 
     501        if (badpix_cnt1 == badpix_cnt2) 
     502        { 
     503            char msg[32]; 
     504            console_add_line("badpixel.bin created."); 
     505            sprintf(msg, "Bad pixel count: %d", badpix_cnt1); 
     506            console_add_line(msg); 
     507        } 
     508        else 
     509        { 
     510            console_add_line("badpixel.bin failed."); 
     511            console_add_line("Please try again."); 
     512        } 
     513         
     514        action_push_delay(3000); 
     515        break; 
     516    default: 
     517        action_stack_standard(p); 
     518        break; 
     519    } 
     520    
     521    return 1; 
     522} 
     523 
     524 
     525void create_badpixel_bin() 
     526{ 
     527    if (!(mode_get() & MODE_REC)) 
     528    { 
     529        gui_mbox_init(LANG_ERROR, LANG_MSG_RECMODE_REQUIRED, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
     530        return; 
     531    } 
     532         
     533    gui_set_mode(GUI_MODE_ALT); 
     534    action_stack_create(&badpixel_task_stack, BADPIX_START); 
     535} 
     536 
     537#endif 
Note: See TracChangeset for help on using the changeset viewer.