root/include/conf.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef CONF_H
   2 #define CONF_H
   3 
   4 // CHDK Config items interface
   5 
   6 // Note: used in modules and platform independent code. 
   7 // Do not add platform dependent stuff in here (#ifdef/#endif compile options or camera dependent values)
   8 
   9 //==========================================================
  10 
  11 #include "stdlib.h"
  12 #include "color.h"
  13 #include "script.h"
  14 
  15 //==========================================================
  16 
  17 #define CONF_STR_LEN        100
  18 
  19 #define CONF_EMPTY          0
  20 // regular char-int-short value
  21 #define CONF_VALUE          1
  22 #define CONF_DEF_VALUE      1
  23 // pointer to function returning int
  24 #define CONF_FUNC_PTR       2
  25 // pointer to array of int
  26 #define CONF_INT_PTR        3
  27 // pointer to the string
  28 #define CONF_CHAR_PTR       4
  29 // OSD_pos
  30 #define CONF_OSD_POS        5
  31 // Pointer to struct containing item count, item size and pointer to items
  32 #define CONF_STRUCT_PTR     6
  33 
  34 typedef struct {
  35     unsigned short  x, y;
  36 } OSD_pos;
  37 
  38 typedef struct {
  39     unsigned short  x, y;
  40 } OSD_scale;
  41 
  42 typedef struct {
  43     int isNumb, isStr, isPInt, isPos;
  44     int numb;
  45     char* str;
  46     int* pInt;
  47     OSD_pos pos;
  48 } tConfigVal;
  49 
  50 // Struct to handle variable sized arrays of 'things' in config
  51 typedef struct {
  52     int             num_items;
  53     int             item_size;
  54     int             (*saved_size)();
  55     char*           (*save)(char *dst);
  56     int             (*load)(char *src);
  57 } tVarArrayConfig;
  58 
  59 // User Menu config structures
  60 typedef struct {
  61     int     var;            // index or hash of main menu item or script
  62     char    *script_file;   // name of script file
  63     char    *script_title;  // name of script (title from script)
  64 } tUserMenuItem;
  65 
  66 typedef struct {
  67     tVarArrayConfig cfg;
  68     tUserMenuItem   *items;
  69 } tUserMenuConfig;
  70 
  71 //==========================================================
  72 
  73 // Changes to the 'conf' structure may require an update to the CONF_VERSION definition
  74 // If add field to the end of structure minor api version should be increased.
  75 // If any other change (remove something, change order, add not to the end, change meaning), major api version should be increased
  76 // Don't make any of the entries conditionally compiled in - this will change the offsets between cameras causing problems with
  77 // making the modules camera/platform independent
  78 
  79 #define CONF_VERSION            {3,6}       // Version for Conf structure
  80 
  81 typedef struct
  82 {
  83     int save_raw;
  84     int save_raw_in_video;
  85     int save_raw_in_sports;
  86     int save_raw_in_burst;
  87     int save_raw_in_edgeoverlay;
  88     int save_raw_in_auto;
  89     int save_raw_in_ev_bracketing;
  90     int save_raw_in_timer;
  91     int raw_exceptions_warn;
  92     int raw_in_dir;
  93     int raw_prefix;
  94     int raw_ext;
  95     int raw_save_first_only; //for series shooting
  96     int raw_nr;
  97     int sub_batch_prefix; // output of batch subtracts
  98     int sub_batch_ext;
  99     int raw_cache;
 100     int dng_raw;
 101     int dng_version;    // User selectable DNG version (0=1.3, 1=1.1) - select 1.1 for CHDK to do bad pixel removal (requires creation of badpixel.bin)
 102     int raw_timer;
 103     int raw_dng_ext;
 104     int dng_usb_ext;
 105     int dng_crop_size;  // User selectable DNG crop size - 0 = JPEG size (as defined in platform_camera.h), 1 = Active Area, 2 = Full sensor
 106 
 107     int show_osd;
 108     int hide_osd;
 109     int show_osd_in_review;
 110     int rotate_osd;
 111     int script_shoot_delay;
 112     int show_histo;
 113     int script_allow_lua_native_calls;
 114     char script_file[CONF_STR_LEN];
 115 
 116     int show_dof;
 117     int batt_volts_max;
 118     int batt_volts_min;
 119     int batt_perc_show;
 120     int batt_volts_show;
 121     int batt_icon_show;
 122     int space_bar_show;
 123     int space_bar_size;
 124     int space_bar_width;
 125     int space_icon_show;
 126     int show_clock;
 127     int show_temp;
 128     int temperature_unit;
 129     int clock_format;
 130     int clock_indicator;
 131     int clock_halfpress;
 132     int space_perc_show;
 133     int space_mb_show;
 134     int show_partition_nr;
 135     int space_perc_warn;
 136     int space_mb_warn;
 137     int space_warn_type;
 138     int show_movie_time;
 139     int show_movie_refresh;
 140 
 141     int zoom_value;
 142 
 143     int show_state;
 144     int show_remaining_raw;
 145     int remaining_raw_treshold;
 146     int show_raw_state;
 147     int show_values;
 148     int show_values_in_video;
 149     int show_overexp;
 150     int show_hiddenfiles;
 151 
 152     int histo_mode;
 153     int histo_auto_ajust;
 154     int histo_ignore_boundary;
 155     int histo_layout;
 156     int histo_show_ev_grid;
 157 
 158     int zebra_draw;
 159     int zebra_mode;
 160     int zebra_restore_screen;
 161     int zebra_restore_osd;
 162     int zebra_over;
 163     int zebra_under;
 164     int zebra_draw_osd;
 165     int zebra_multichannel;
 166 
 167     OSD_pos histo_pos;
 168     OSD_pos dof_pos;
 169     OSD_pos batt_icon_pos;
 170     OSD_pos space_icon_pos;
 171     OSD_pos space_hor_pos;
 172     OSD_pos space_ver_pos;
 173     OSD_pos batt_txt_pos;
 174     OSD_pos space_txt_pos;
 175     OSD_pos mode_state_pos;
 176     OSD_pos mode_raw_pos;
 177     OSD_pos values_pos;
 178     OSD_pos clock_pos;
 179     OSD_pos mode_video_pos;
 180     OSD_pos mode_ev_pos;
 181     OSD_pos temp_pos;
 182     OSD_pos ev_video_pos;
 183     OSD_pos usb_info_pos;
 184     
 185     OSD_scale histo_scale;
 186     OSD_scale dof_scale;
 187     OSD_scale batt_icon_scale;
 188     OSD_scale space_icon_scale;
 189     OSD_scale space_hor_scale;
 190     OSD_scale space_ver_scale;
 191     OSD_scale batt_txt_scale;
 192     OSD_scale space_txt_scale;
 193     OSD_scale mode_state_scale;
 194     OSD_scale mode_raw_scale;
 195     OSD_scale values_scale;
 196     OSD_scale clock_scale;
 197     OSD_scale mode_video_scale;
 198     OSD_scale mode_ev_scale;
 199     OSD_scale temp_scale;
 200     OSD_scale ev_video_scale;
 201     OSD_scale usb_info_scale;
 202 
 203     // User adjustable colors
 204     confColor histo_color;
 205     confColor histo_color2;     // markers/border
 206     confColor osd_color;
 207     confColor osd_color_warn;
 208     confColor osd_color_override;
 209     confColor space_color;
 210     confColor menu_color;
 211     confColor menu_title_color;
 212     confColor menu_cursor_color;
 213     confColor menu_symbol_color;
 214     confColor reader_color;
 215     confColor zebra_color;      // under/over
 216     confColor grid_color;
 217     confColor edge_overlay_color;
 218 
 219     int menu_center;
 220     int menu_select_first_entry;
 221     int menu_symbol_enable;
 222 
 223     int font_cp;
 224     char menu_rbf_file[CONF_STR_LEN];
 225     char menu_symbol_rbf_file[CONF_STR_LEN];
 226 
 227     char lang_file[CONF_STR_LEN];
 228 
 229     char reader_file[CONF_STR_LEN];
 230     int  reader_pos;
 231     int  reader_autoscroll;
 232     int  reader_autoscroll_delay;
 233     char reader_rbf_file[100];
 234     int  reader_codepage;
 235     int  reader_wrap_by_words;
 236 
 237     int flashlight;
 238     int fast_ev;
 239     int fast_ev_step;
 240     int fast_image_quality;
 241     int fast_movie_control;
 242     int fast_movie_quality_control;
 243     int splash_show;
 244     int start_sound;
 245     int platformid;
 246 
 247     int use_zoom_mf;
 248     long alt_mode_button; //for S-series
 249     int alt_prevent_shutdown;
 250 
 251     int show_grid_lines;
 252     char grid_lines_file[CONF_STR_LEN];
 253     int grid_force_color;
 254     char grid_title[36];
 255 
 256     int video_mode;
 257     int video_quality;
 258     int video_bitrate;
 259 
 260     int tv_bracket_value;
 261     int av_bracket_value;
 262     int iso_bracket_value;
 263     int iso_bracket_koef;
 264     int subj_dist_bracket_value;
 265     int subj_dist_bracket_koef;
 266     int bracket_type;
 267     int bracketing_add_raw_suffix;
 268     int clear_bracket;
 269     int clear_video;
 270     int override_disable;       // Uses negative/obscure logic.
 271                                 // 0 = CHDK Tv/Av/ISO/SD overrides are enabled
 272                                 // 1 = Overrides are disabled
 273                                 // 2 = Overrides are enabled and the shortcut button to enable/disable them is disabled
 274                                 // Notes: Option 2 is depracated from version 1.2
 275                                 //        Disabling these overrides does not disable Auto ISO and Bracketing overrides (see next item)
 276     int override_disable_all;   // 0 = Auto ISO and Bracketing enabled, even if other overrides disabled above
 277                                 // 1 = Auto ISO and Bracketing enabled only when other overrides are enabled
 278 
 279     int tv_override_enabled;
 280     int tv_override_value;
 281     int tv_override_long_exp;
 282     int tv_override_short_exp;
 283     int tv_enum_type;           // 0 = Ev Step, 1 = Long Exposure (HH:MM:SS), 2 = Short Exposure (0.xxxxx)
 284     int av_override_enabled;
 285     int av_override_value;
 286 
 287     int nd_filter_state;
 288 
 289     int iso_override_value;
 290     int iso_override_koef;
 291     int subj_dist_override_value;
 292     int subj_dist_override_koef;
 293     int clear_override;
 294 
 295     int autoiso_enable;
 296     int autoiso_shutter_enum;
 297     int autoiso_user_factor;
 298     int autoiso_is_factor;
 299     int autoiso_max_iso_hi;
 300     int autoiso_max_iso_auto;
 301     int autoiso_min_iso;
 302     int autoiso2_shutter_enum;
 303     int autoiso2_max_iso_auto;
 304     //AutoISO2 precalced values
 305     float autoiso2_coef;        // C2=( iso2_max_auto_real - iso_max_auto_real) / ( tv_num[autoiso_shutter] - tv_numerator[autoiso2_shutter])
 306     int autoiso_max_iso_hi_real;    // converted from GUI (possible marketing) to real iso value
 307     int autoiso_max_iso_auto_real;
 308     int autoiso_min_iso_real;
 309     int autoiso2_max_iso_auto_real;
 310     int autoiso2_over;
 311     
 312     int overexp_threshold;
 313     int overexp_ev_enum;    // 0-off, 1=-1/3, ..
 314 
 315     int dof_subj_dist_as_near_limit;
 316     int dof_use_exif_subj_dist;
 317     int dof_subj_dist_in_misc;
 318     int dof_near_limit_in_misc;
 319     int dof_far_limit_in_misc;
 320     int dof_hyperfocal_in_misc;
 321     int dof_depth_in_misc;
 322 
 323     int values_show_in_review;
 324     int values_show_zoom;
 325     int values_show_real_aperture;
 326     int values_show_real_iso;
 327     int values_show_market_iso;
 328     int values_show_iso_only_in_autoiso_mode;
 329     int values_show_ev_seted;
 330     int values_show_ev_measured;
 331     int values_show_bv_measured;
 332     int values_show_bv_seted;
 333     int values_show_overexposure;
 334     int values_show_canon_overexposure;
 335     int values_show_luminance;
 336 
 337     int debug_shortcut_action;   // 0=none, 1=dump, 2=page display
 338     int debug_display;           // 0=none, 1=props, 2=flash param, 3=tasks
 339     int debug_propcase_page;     // save propcase page
 340     int debug_lua_restart_on_error; // 0=no, 1=yes
 341     int debug_misc_vals_show;    // 0=no, 1=yes
 342 
 343     int script_startup;          // remote autostart
 344     int remote_enable;           // remote enable
 345     int user_menu_enable;
 346     int user_menu_as_root;
 347     tUserMenuConfig user_menu_vars;
 348     int zoom_scale;
 349     int unlock_optical_zoom_for_video;
 350     int mute_on_zoom;
 351     int bad_pixel_removal;
 352     int video_af_key;
 353 
 354     char curve_file[CONF_STR_LEN];
 355     int curve_enable;
 356 
 357     int edge_overlay_enable;
 358     int edge_overlay_filter;
 359     int edge_overlay_thresh;
 360     int edge_overlay_zoom;              // shall zoom be set when *edg file is loaded?
 361     int edge_overlay_pano;              // whether a full press changes back to live mode
 362     int edge_overlay_pano_overlap;      // overlap in % in pano mode
 363     int edge_overlay_show;              // whether to show overlay even when no button is pressed
 364     int edge_overlay_play;              // whether edge overlay is switched on also for play mode
 365 
 366     int synch_enable;
 367     int ricoh_ca1_mode;
 368     int synch_delay_enable;
 369     int synch_delay_value;
 370 
 371     int script_param_set;
 372     int script_param_save;
 373 
 374     long mem_view_addr_init;
 375     int flash_sync_curtain;
 376     int flash_video_override;
 377     int flash_manual_override;
 378     int flash_video_override_power;
 379     int flash_enable_exp_comp;
 380     int flash_exp_comp;
 381 
 382     // Overrides to disable touchscreen U/I components (IXUS 310)
 383     int touchscreen_disable_video_controls;
 384     int touchscreen_disable_shortcut_controls;
 385 
 386         // Enable USB icon
 387     int usb_info_enable; 
 388 
 389         // gen 2 USB remote
 390         int remote_switch_type;
 391         int remote_control_mode;
 392 
 393     int ext_video_time;
 394     
 395     int remote_enable_scripts;  // usb remote activates scripts in <ALT> mode
 396     
 397     int zoom_assist_button_disable;    // used to disable the zoom assist button on SX30 & SX40 for people who keep accidentaly pressing it
 398 
 399     int gps_record;
 400     int gps_navi_show;
 401     int gps_navi_hide;
 402     int gps_compass_show;
 403     int gps_compass_hide;
 404     int gps_coordinates_show;
 405     int gps_height_show;
 406     int gps_waypoint_save;
 407     int gps_track_time;
 408     int gps_wait_for_signal;
 409     int gps_compass_time;
 410     int gps_navi_time;
 411     int gps_wait_for_signal_time;
 412     int gps_compass_smooth;
 413     int gps_batt;
 414     int gps_countdown;
 415     int gps_2D_3D_fix;
 416     int gps_countdown_blink;
 417     int gps_rec_play_set;
 418     int gps_play_dark_set;
 419     int gps_rec_play_time;
 420     int gps_play_dark_time;
 421     int gps_rec_play_set_1;
 422     int gps_play_dark_set_1;
 423     int gps_rec_play_time_1;
 424     int gps_play_dark_time_1;
 425     int gps_show_symbol;
 426 
 427     int gps_batt_warn;
 428     int gps_track_symbol;
 429     int gps_test_timezone;
 430     int gps_beep_warn;
 431     int gps_on_off;
 432 
 433     int tbox_char_map;          // Text input box language/char map
 434     int show_alt_helper;        // Show <ALT> mode help screen
 435     int show_alt_helper_delay;  // Delay before showing help screen
 436     
 437     long extra_button; // extra button for use in ALT mode, 0 when disabled
 438 
 439     int module_logging;
 440 
 441     int enable_shortcuts;     // enable keyboard shortcuts
 442 
 443     int console_show;           // 0 = ALT mode only, 1 = always
 444     int console_timeout;        // Delay after last update to stop showing console (seconds)
 445 
 446     int memdmp_start;           // start address for memory dump
 447     int memdmp_size;            // amount of memory to dump in bytes (0 for all RAM)
 448     
 449     int remote_input_channel;   // remote input channel,  0=USB, 1=A/D
 450     
 451     int hotshoe_override;       // flash hot shoe override (0=no override, 1='not occupied', 2='occupied')
 452 
 453     int allow_unsafe_io;        // Allow open/close/write to continue if fileio_semaphore times out (instead of returning error)
 454 
 455     int disable_lfn_parser_ui;     // 0 = use built-in opendir functions for long filenames in filebrowser on dryos,
 456                                    // 1 = only use firmware opendir
 457 
 458     int enable_raw_shortcut;    // enable RAW state toggle keyboard shortcut, 0=no, 1=yes, 2=yes with RAW OSD enabled
 459 
 460     int osd_platformid; // platform ID in OSD cfg file
 461 
 462     int save_raw_in_canon_raw; // disable raw when Canon raw enabled
 463 
 464     int clean_overlay;  // invisible Canon overlay: 0 = never, 1 = rec mode, 2 = during movie record
 465 
 466     int unlock_av_out_in_rec;  // Force video out when in Rec if AV bit is set. Bool
 467 
 468     int check_firmware_crc;  // Check firmware CRC on startup. 0 = no. 1 = Check and set to 0. 2 = always
 469 
 470 } Conf;
 471 
 472 extern Conf conf;
 473 
 474 //==========================================================
 475 
 476 // Some macros to simplify the code
 477 
 478 // True if TV/AV/ISO/SD overrides are enabled, false if disabled (excludes Auto ISO and bracketing overrides which can be still be enabled)
 479 #define overrides_are_enabled   ( conf.override_disable != 1 )
 480 // True if Auto ISO and bracketing overrides are enabled, false if disabled
 481 #define autoiso_and_bracketing_overrides_are_enabled    ( !(conf.override_disable == 1 && conf.override_disable_all) )
 482 
 483 // True if a TV override value is set, false otherwise
 484 #define TV_OVERRIDE_EV_STEP     0
 485 #define TV_OVERRIDE_SHORT_EXP   1
 486 #define TV_OVERRIDE_LONG_EXP    2
 487 #define is_tv_override_enabled  (  conf.tv_override_enabled && overrides_are_enabled && \
 488                                     ((conf.tv_enum_type == TV_OVERRIDE_EV_STEP) || \
 489                                      (conf.tv_override_short_exp && (conf.tv_enum_type == TV_OVERRIDE_SHORT_EXP)) ||  \
 490                                      (conf.tv_override_long_exp && (conf.tv_enum_type == TV_OVERRIDE_LONG_EXP)) \
 491                                      ) \
 492                                 )
 493 // True if a AV override value is set, false otherwise
 494 #define is_av_override_enabled  ( conf.av_override_enabled && overrides_are_enabled )
 495 // True if a ISO override value is set, false otherwise
 496 #define is_iso_override_enabled ( conf.iso_override_value && conf.iso_override_koef && overrides_are_enabled )
 497 // True if a SD (subject distance) override value is set, false otherwise
 498 #define SD_OVERRIDE_OFF         0
 499 #define SD_OVERRIDE_ON          1
 500 #define SD_OVERRIDE_INFINITY    2
 501 #define is_sd_override_enabled  ( conf.subj_dist_override_value && conf.subj_dist_override_koef && overrides_are_enabled )
 502 
 503 // True if a TV bracketing value is set, false otherwise
 504 #define is_tv_bracketing_enabled  ( conf.tv_bracket_value && autoiso_and_bracketing_overrides_are_enabled )
 505 // True if a AV bracketing value is set, false otherwise
 506 #define is_av_bracketing_enabled  ( conf.av_bracket_value && autoiso_and_bracketing_overrides_are_enabled )
 507 // True if a ISO bracketing value is set, false otherwise
 508 #define is_iso_bracketing_enabled ( conf.iso_bracket_value && conf.iso_bracket_koef && autoiso_and_bracketing_overrides_are_enabled )
 509 // True if a SD (subject distance) bracketing value is set, false otherwise
 510 #define is_sd_bracketing_enabled  ( conf.subj_dist_bracket_value && conf.subj_dist_bracket_koef && autoiso_and_bracketing_overrides_are_enabled && shooting_can_focus() )
 511 
 512 #define ALT_PREVENT_SHUTDOWN_NO         0
 513 #define ALT_PREVENT_SHUTDOWN_ALT        1
 514 #define ALT_PREVENT_SHUTDOWN_ALT_SCRIPT 2
 515 #define ALT_PREVENT_SHUTDOWN_ALWAYS     3
 516 
 517 #define SHOOTING_PROGRESS_NONE          0
 518 #define SHOOTING_PROGRESS_STARTED       1
 519 #define SHOOTING_PROGRESS_PROCESSING    2
 520 #define SHOOTING_PROGRESS_DONE          3
 521 
 522 // script conf.script_startup values
 523 #define SCRIPT_AUTOSTART_NONE             0
 524 #define SCRIPT_AUTOSTART_ALWAYS           1
 525 #define SCRIPT_AUTOSTART_ONCE             2
 526 #define SCRIPT_AUTOSTART_ALT              3
 527 
 528 extern void conf_save();
 529 extern void conf_restore();
 530 extern void conf_load_defaults();
 531 extern void conf_change_dng(void);
 532 extern void conf_update_prevent_shutdown(void);
 533 extern void cb_autoiso_menu_change(unsigned int item);  // gui.c
 534 extern int conf_getValue(unsigned short id, tConfigVal* configVal);
 535 extern int conf_setValue(unsigned short id, tConfigVal configVal);
 536 extern void conf_setAutosave(int n);
 537 
 538 // reyalp: putting these in conf, since the conf values are lookups for them
 539 // prefixes and extentions available for raw images (index with conf.raw_prefix etc)
 540 #define NUM_IMG_FOLDER_NAMES 3  // 
 541 #define NUM_IMG_PREFIXES 3  // IMG_ CRW_ SND_ (could add ETC_ SDR_ AUT_ MVI_ MRK_)
 542 #define NUM_IMG_EXTS 5      // .JPG .CRW .CR2 .THM .WAV (could add .AVI .MRK)
 543 extern const char* img_folders[NUM_IMG_FOLDER_NAMES];
 544 extern const char* img_prefixes[NUM_IMG_PREFIXES];
 545 extern const char* img_exts[NUM_IMG_EXTS];
 546 
 547 // is raw data available in the current mode and not blocked by current "raw exceptions" ?
 548 extern int is_raw_enabled();
 549 // is raw data valid raw data available in the current mode
 550 extern int is_raw_possible();
 551 
 552 //-------------------------------------------------------------------
 553 
 554 typedef struct {
 555     unsigned short      id;
 556     unsigned char       size;
 557     char                type;
 558     void                *var;
 559     union {
 560         void            *ptr;
 561         int             i;
 562         confColor       cl;
 563         OSD_pos         pos;
 564         OSD_scale       scale;
 565         long            (*func)(void);
 566     };
 567     unsigned int        last_saved;     // Record last value saved to file to determine if file needs updating
 568 } ConfInfo;
 569 
 570 #define CONF_INFO(id, param, type, def)             { id, sizeof( param ), type, &param, {def}, 0 }
 571 #define CONF_INFO2(id, param, type, px, py)         { id, sizeof( param ), type, &param, {pos:{px,py}}, 0 }
 572 #define CONF_INFOP(id, param, type, px, py)         { id, sizeof( param ), type, &param, {pos:{(px)*CAM_SCREEN_WIDTH/360,(py)*CAM_SCREEN_HEIGHT/240}}, 0 }
 573 #define CONF_INFOC(id, param, type, bc, fc, bt, ft) { id, sizeof( param ), type, &param, {cl:{fg:{fc,ft},bg:{bc,bt}}}, 0 }
 574 
 575 extern void config_save(ConfInfo *conf_info, const char *filename, int config_base);
 576 extern void config_restore(ConfInfo *confinfo, const char *filename, void (*info_func)(unsigned short id));
 577 
 578 extern int save_config_file(int config_base, const char *filename);
 579 extern int load_config_file(int config_base, const char *filename);
 580 
 581 extern void resetColors();
 582 
 583 //-------------------------------------------------------------------
 584 
 585 #endif

/* [<][>][^][v][top][bottom][index][help] */