source: trunk/core/conf.c @ 698

Revision 698, 29.1 KB checked in by phyrephox, 4 years ago (diff)

for strobists:
+ option to manually override flash (for all cameras). even for ixus cams. no need for a script anymore.
important: when enabled, this will not only override flash power, but also enable the CHECK if flash is needed. in other words: your camera will use flash even in bright sunlight and even if you disabled the flash. of course the flash will not fire on cameras with popup flashs when the flash is not popped up. there are three values for the flash to be set: low, middle and POWERFUL. be careful, dont flash at home, kids.
For cameras with dedicated movie buttons, there is an extra menu item: force flash only in moviemode. when this is checked, the flash will be forced only when recording a video.

todo: do flash ev correction for cams that dont support it and also maybe DISABLE flash for cams that cannot disable it (on s5is when flash is popped up, it is ALWAYS enabled, the flash button doesnt do anything for example... also maybe for those situations you are in a church or a museum where flash is absolutely forbidden...)

feature more or less created by ewavr, thanks

  • makefile: small edit (thx to ewavr)
  • Property svn:eol-style set to native
Line 
1#include "platform.h"
2#include "keyboard.h"
3#include "conf.h"
4#include "histogram.h"
5#include "font.h"
6#include "camera.h"
7#include "raw.h"
8#include "gui_draw.h"
9#include "gui_osd.h"
10#include "gui_grid.h"
11#include "core.h"
12#include "stdlib.h"
13#include "script.h"
14
15//-------------------------------------------------------------------
16#define CONF_FILE  "A/CHDK/CCHDK.CFG"
17#define CONF_MAGICK_VALUE (0x33204741)
18
19#define CONF_INFO(id, param, type, def, func) { id, sizeof( param ), &param , type, {def}, func }
20#define CONF_DEF_PTR    1
21#define CONF_DEF_VALUE  2
22
23//-------------------------------------------------------------------
24typedef struct {
25    unsigned short      id;
26    unsigned short      size;
27    void                *var;
28    int                 type;
29    union {
30        void            *ptr;
31        int             i;
32        color           cl;
33    };
34    void                (*func)();
35} ConfInfo;
36
37//-------------------------------------------------------------------
38Conf conf;
39
40int state_shooting_progress = SHOOTING_PROGRESS_NONE;
41int state_save_raw_nth_only;
42int state_expos_recalculated;
43int state_expos_under;
44int state_expos_over;
45int auto_started;
46
47int state_debug1;
48int debug_propcase_show;
49int debug_propcase_page;
50int debug_vals_show;
51int debug_pardata_show;
52
53// reyalp: putting these in conf, since the conf values are lookups for them
54// prefixes and extentions available for raw images (index with conf.raw_prefix etc)
55const char* img_prefixes[NUM_IMG_PREFIXES]={ "IMG_", "CRW_", "SND_" /*, "AUT_", "ETC_","SDR_", "MVI_", "MRK_"*/};
56const char* img_exts[NUM_IMG_EXTS]={ ".JPG", ".CRW", ".CR2", ".THM", ".WAV"/*, ".AVI", ".MRK"*/};
57// ugh
58const char *video_bitrate_strings[VIDEO_BITRATE_STEPS]={ "0.25x", "0.5x","0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x", "2.5x", "3x"};
59
60//-------------------------------------------------------------------
61static int def_ubasic_vars[SCRIPT_NUM_PARAMS] = {0};
62static int def_batt_volts_max, def_batt_volts_min;
63static OSD_pos def_histo_pos, def_dof_pos, def_batt_icon_pos, def_space_icon_pos, def_space_hor_pos, def_space_ver_pos, def_batt_txt_pos, def_space_txt_pos,
64               def_mode_state_pos, def_mode_raw_pos, def_mode_video_pos, def_mode_ev_pos, def_values_pos, def_clock_pos, def_ev_video_pos, def_temp_pos;
65static int def_user_menu_vars[USER_MENU_ITEMS] = {0};
66
67static void conf_change_script_file();
68static void conf_change_histo_mode();
69static void conf_change_histo_layout();
70static void conf_change_font_cp();
71static void conf_change_menu_rbf_file();
72static void conf_change_menu_symbol_rbf_file();
73static void conf_change_alt_mode_button();
74static void conf_change_grid_file();
75static void conf_change_video_bitrate();
76static void conf_change_dng_ext();
77
78void ubasic_camera_set_raw(int mode)
79{
80    conf.save_raw = mode;
81}
82
83void ubasic_camera_set_nr(int mode)
84{
85        // "Auto", "Off", "On"
86    conf.raw_nr = mode;
87}
88int ubasic_camera_script_autostart()
89{       
90        // 1 = Autostarted
91        return auto_started;
92}
93
94void ubasic_camera_set_script_autostart(int state)
95{       
96        // 1 = Autostarted
97        auto_started = state;
98}
99
100int ubasic_camera_get_nr()
101{
102        // "Auto", "Off", "On"
103    return conf.raw_nr;
104}
105
106
107void clear_values()
108{       
109        if (conf.platformid != PLATFORMID) // the following config entries will be resetted if you switch the camera using the same cfg
110        {
111    conf.raw_cache = 0;
112    conf.zoom_override_value = 0;
113    conf.fast_ev = 0;
114    conf.fast_movie_control = 0;
115    conf.fast_movie_quality_control = 0;
116    conf.zoom_scale = 100;
117    conf.platformid = PLATFORMID;
118    conf.flash_video_override = 0;
119        }
120
121        if (conf.clear_override)
122        {
123         conf.av_override_value=0;
124         conf.tv_override_koef=0;
125         conf.subj_dist_override_koef=0;
126         conf.iso_override_koef=0;
127         conf.nd_filter_state=0;
128        }
129        if (conf.clear_zoom_override)
130        {
131        conf.zoom_override = 0;
132        }
133        if (conf.clear_bracket)
134        {
135         conf.av_bracket_value=0;
136         conf.tv_bracket_value=0;
137         conf.iso_bracket_koef=0;
138         conf.subj_dist_bracket_koef=0;
139        }
140     if (conf.clear_video)
141        {
142         conf.video_mode = 0;
143         conf.video_quality = VIDEO_DEFAULT_QUALITY;
144         conf.video_bitrate = VIDEO_DEFAULT_BITRATE;
145         shooting_video_bitrate_change(conf.video_bitrate);
146        }
147        conf.edge_overlay_lock = 0; // reset it because otherwise this feature cant be used at startup (when buffer is empty) - needs workaround other than this!
148}
149
150static const ConfInfo conf_info[] = {
151/* !!! Do NOT change ID for items defined already! Append a new one at the end! !!! */
152    CONF_INFO(  1, conf.show_osd,               CONF_DEF_VALUE, i:1, NULL),
153    CONF_INFO(  2, conf.save_raw,               CONF_DEF_VALUE, i:0, NULL),
154    CONF_INFO(  3, conf.script_shoot_delay,     CONF_DEF_VALUE, i:0, NULL),
155    CONF_INFO(  4, conf.show_histo,             CONF_DEF_VALUE, i:0, NULL),
156    CONF_INFO(  5, conf.ubasic_vars,            CONF_DEF_PTR,   ptr:&def_ubasic_vars, NULL),
157    CONF_INFO(  6, conf.script_param_set,       CONF_DEF_VALUE, i:0, NULL),
158    CONF_INFO(  7, conf.show_dof,               CONF_DEF_VALUE, i:DOF_DONT_SHOW, NULL),
159    CONF_INFO(  8, conf.batt_volts_max,         CONF_DEF_PTR,   ptr:&def_batt_volts_max, NULL),
160    CONF_INFO(  9, conf.batt_volts_min,         CONF_DEF_PTR,   ptr:&def_batt_volts_min, NULL),
161    CONF_INFO( 10, conf.batt_step_25,           CONF_DEF_VALUE, i:1, NULL),
162    CONF_INFO( 11, conf.batt_perc_show,         CONF_DEF_VALUE, i:1, NULL),
163    CONF_INFO( 12, conf.batt_volts_show,        CONF_DEF_VALUE, i:0, NULL),
164    CONF_INFO( 13, conf.batt_icon_show,         CONF_DEF_VALUE, i:1, NULL),
165    CONF_INFO( 14, conf.show_state,             CONF_DEF_VALUE, i:1, NULL),
166    CONF_INFO( 15, conf.show_values,            CONF_DEF_VALUE, i:0, NULL),
167    CONF_INFO( 16, conf.show_overexp,           CONF_DEF_VALUE, i:1, NULL),
168    CONF_INFO( 17, conf.histo_mode,             CONF_DEF_VALUE, i:HISTO_MODE_LINEAR, conf_change_histo_mode),
169    CONF_INFO( 18, conf.histo_auto_ajust,       CONF_DEF_VALUE, i:1, NULL),
170    CONF_INFO( 19, conf.histo_ignore_boundary,  CONF_DEF_VALUE, i:4, NULL),
171    CONF_INFO( 20, conf.histo_layout,           CONF_DEF_VALUE, i:OSD_HISTO_LAYOUT_A, conf_change_histo_layout),
172    CONF_INFO( 21, conf.histo_pos,              CONF_DEF_PTR,   ptr:&def_histo_pos, NULL),
173    CONF_INFO( 22, conf.dof_pos,                CONF_DEF_PTR,   ptr:&def_dof_pos, NULL),
174    CONF_INFO( 23, conf.batt_icon_pos,          CONF_DEF_PTR,   ptr:&def_batt_icon_pos, NULL),
175    CONF_INFO( 24, conf.batt_txt_pos,           CONF_DEF_PTR,   ptr:&def_batt_txt_pos , NULL),
176    CONF_INFO( 25, conf.mode_state_pos,         CONF_DEF_PTR,   ptr:&def_mode_state_pos , NULL),
177    CONF_INFO( 26, conf.values_pos,             CONF_DEF_PTR,   ptr:&def_values_pos , NULL),
178    CONF_INFO( 27, conf.histo_color,            CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_WHITE), NULL),
179    CONF_INFO( 28, conf.osd_color,              CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL),
180    CONF_INFO( 29, conf.batt_icon_color,        CONF_DEF_VALUE, cl:COLOR_WHITE, NULL),
181    CONF_INFO( 30, conf.menu_color,             CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL),
182    CONF_INFO( 31, conf.reader_color,           CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_GREY, COLOR_WHITE), NULL),
183    CONF_INFO( 32, conf.ricoh_ca1_mode,         CONF_DEF_VALUE, i:0, NULL),
184    CONF_INFO( 33, conf.flashlight,             CONF_DEF_VALUE, i:0, NULL),
185//    CONF_INFO( 34, conf.ns_enable_memdump,      CONF_DEF_VALUE, i:0, NULL),
186    CONF_INFO( 34, conf.debug_shortcut_action,  CONF_DEF_VALUE, i:0, NULL), // backwards compatible
187    CONF_INFO( 35, conf.raw_in_dir,             CONF_DEF_VALUE, i:0, NULL),
188    CONF_INFO( 36, conf.raw_prefix,             CONF_DEF_VALUE, i:RAW_PREFIX_CRW, NULL),
189    CONF_INFO( 37, conf.raw_ext,                CONF_DEF_VALUE, i:RAW_EXT_CRW, NULL),
190    CONF_INFO( 38, conf.reader_file,            CONF_DEF_PTR,   ptr:"A/README.TXT", conf_change_script_file),
191    CONF_INFO( 39, conf.reader_pos,             CONF_DEF_VALUE, i:0, NULL),
192    CONF_INFO( 40, conf.sokoban_level,          CONF_DEF_VALUE, i:0, NULL),
193    CONF_INFO( 41, conf.show_clock,             CONF_DEF_VALUE, i:2, NULL),
194    CONF_INFO( 42, conf.clock_pos,              CONF_DEF_PTR,   ptr:&def_clock_pos , NULL),
195    CONF_INFO( 43, conf.reader_autoscroll,      CONF_DEF_VALUE, i:0, NULL),
196    CONF_INFO( 44, conf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL),
197    CONF_INFO( 45, conf.reader_rbf_file,        CONF_DEF_PTR,   ptr:"", NULL),
198    CONF_INFO( 46, conf.reader_codepage,        CONF_DEF_VALUE, i:FONT_CP_WIN, NULL),
199    CONF_INFO( 47, conf.splash_show,            CONF_DEF_VALUE, i:1, NULL),
200    CONF_INFO( 48, conf.histo_color2,           CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_WHITE), NULL),
201    CONF_INFO( 49, conf.zebra_draw,             CONF_DEF_VALUE, i:0, NULL),
202    CONF_INFO( 50, conf.zebra_mode,             CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL),
203    CONF_INFO( 51, conf.zebra_restore_screen,   CONF_DEF_VALUE, i:1, NULL),
204    CONF_INFO( 52, conf.zebra_restore_osd,      CONF_DEF_VALUE, i:1, NULL),
205    CONF_INFO( 53, conf.zebra_over,             CONF_DEF_VALUE, i:1, NULL),
206    CONF_INFO( 54, conf.zebra_under,            CONF_DEF_VALUE, i:0, NULL),
207    CONF_INFO( 55, conf.zebra_color,            CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_RED), NULL),
208    CONF_INFO( 56, conf.zebra_draw_osd,         CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL),
209    CONF_INFO( 57, conf.user_menu_as_root,      CONF_DEF_VALUE, i:0, NULL),
210    CONF_INFO( 58, conf.zoom_value,             CONF_DEF_VALUE, i:ZOOM_SHOW_X, NULL),
211    CONF_INFO( 59, conf.use_zoom_mf,            CONF_DEF_VALUE, i:0, NULL),
212    CONF_INFO( 60, conf.raw_save_first_only,    CONF_DEF_VALUE, i:0, NULL),
213    CONF_INFO( 61, conf.reader_wrap_by_words,   CONF_DEF_VALUE, i:1, NULL),
214    CONF_INFO( 62, conf.menu_symbol_enable,     CONF_DEF_VALUE, i:1, NULL),
215    CONF_INFO( 63, conf.alt_mode_button,        CONF_DEF_VALUE, i:KEY_PRINT, conf_change_alt_mode_button),
216    CONF_INFO( 64, conf.lang_file,              CONF_DEF_PTR,   ptr:"", NULL),
217    CONF_INFO( 65, conf.font_cp,                CONF_DEF_VALUE, i:FONT_CP_WIN_1251, conf_change_font_cp),
218    CONF_INFO( 66, conf.menu_rbf_file,          CONF_DEF_PTR,   ptr:"", conf_change_menu_rbf_file),
219    CONF_INFO( 67, conf.alt_prevent_shutdown,   CONF_DEF_VALUE, i:ALT_PREVENT_SHUTDOWN_ALT, NULL),
220    CONF_INFO( 68, conf.show_grid_lines,        CONF_DEF_VALUE, i:0, NULL),
221    CONF_INFO( 69, conf.grid_lines_file,        CONF_DEF_PTR,   ptr:"", conf_change_grid_file),
222    CONF_INFO( 70, conf.raw_nr,                 CONF_DEF_VALUE, i:NOISE_REDUCTION_AUTO_CANON, NULL),
223    CONF_INFO( 71, conf.grid_force_color,       CONF_DEF_VALUE, i:0, NULL),
224    CONF_INFO( 72, conf.grid_color,             CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL),
225
226    CONF_INFO( 80, conf.dof_subj_dist_as_near_limit,CONF_DEF_VALUE, i:0, NULL),
227    CONF_INFO( 81, conf.dof_use_exif_subj_dist,     CONF_DEF_VALUE, i:0, NULL),
228    CONF_INFO( 82, conf.dof_subj_dist_in_misc,      CONF_DEF_VALUE, i:1, NULL),
229    CONF_INFO( 83, conf.dof_near_limit_in_misc,     CONF_DEF_VALUE, i:1, NULL),
230    CONF_INFO( 84, conf.dof_far_limit_in_misc,      CONF_DEF_VALUE, i:1, NULL),
231    CONF_INFO( 85, conf.dof_hyperfocal_in_misc,     CONF_DEF_VALUE, i:1, NULL),
232    CONF_INFO( 86, conf.dof_depth_in_misc,          CONF_DEF_VALUE, i:0, NULL),
233
234        CONF_INFO( 87, conf.values_show_in_review,    CONF_DEF_VALUE, i:0, NULL),
235    CONF_INFO( 88, conf.values_show_zoom,         CONF_DEF_VALUE, i:1, NULL),
236    CONF_INFO( 89, conf.values_show_real_aperture,CONF_DEF_VALUE, i:0, NULL),
237    CONF_INFO( 90, conf.values_show_real_iso,     CONF_DEF_VALUE, i:1, NULL),
238    CONF_INFO( 91, conf.values_show_market_iso,   CONF_DEF_VALUE, i:0, NULL),
239    CONF_INFO( 92, conf.values_show_iso_only_in_autoiso_mode, CONF_DEF_VALUE, i:0, NULL),
240    CONF_INFO( 93, conf.values_show_ev_seted,     CONF_DEF_VALUE, i:0, NULL),
241    CONF_INFO( 94, conf.values_show_ev_measured,  CONF_DEF_VALUE, i:0, NULL),
242    CONF_INFO( 95, conf.values_show_bv_measured,  CONF_DEF_VALUE, i:0, NULL),
243    CONF_INFO( 96, conf.values_show_bv_seted,     CONF_DEF_VALUE, i:0, NULL),
244    CONF_INFO( 97, conf.values_show_overexposure, CONF_DEF_VALUE, i:0, NULL),
245    CONF_INFO( 98, conf.values_show_luminance,    CONF_DEF_VALUE, i:0, NULL),
246
247    CONF_INFO( 99, conf.video_mode,             CONF_DEF_VALUE, i:0, NULL),
248    CONF_INFO(100, conf.video_quality,          CONF_DEF_VALUE, i:VIDEO_DEFAULT_QUALITY,NULL),
249    CONF_INFO(101, conf.video_bitrate,          CONF_DEF_VALUE, i:VIDEO_DEFAULT_BITRATE, conf_change_video_bitrate),
250   
251    CONF_INFO(102, conf.tv_override_value,      CONF_DEF_VALUE, i:0, NULL),     
252    CONF_INFO(103, conf.tv_override_koef,       CONF_DEF_VALUE, i:0, NULL),     
253
254    CONF_INFO(104, conf.av_override_value,      CONF_DEF_VALUE, i:0, NULL),
255    CONF_INFO(105, conf.iso_override_value,     CONF_DEF_VALUE, i:0, NULL),
256    CONF_INFO(106, conf.iso_override_koef,      CONF_DEF_VALUE, i:0, NULL),
257   
258    CONF_INFO(107, conf.subj_dist_override_value,CONF_DEF_VALUE, i:0, NULL),
259    CONF_INFO(108, conf.subj_dist_override_koef, CONF_DEF_VALUE, i:0, NULL),
260   
261    CONF_INFO(109, conf.tv_bracket_value,       CONF_DEF_VALUE, i:0, NULL),
262    CONF_INFO(110, conf.av_bracket_value,       CONF_DEF_VALUE, i:0, NULL),
263    CONF_INFO(111, conf.iso_bracket_value,      CONF_DEF_VALUE, i:0, NULL),
264    CONF_INFO(112, conf.iso_bracket_koef,       CONF_DEF_VALUE, i:0, NULL),
265    CONF_INFO(113, conf.subj_dist_bracket_value,CONF_DEF_VALUE, i:0, NULL),
266    CONF_INFO(114, conf.subj_dist_bracket_koef, CONF_DEF_VALUE, i:0, NULL),
267    CONF_INFO(115, conf.bracket_type,           CONF_DEF_VALUE, i:0, NULL),
268   
269    CONF_INFO(116, conf.recalc_exposure,        CONF_DEF_VALUE, i:0, NULL),
270    CONF_INFO(117, conf.tv_exposure_order,      CONF_DEF_VALUE, i:2, NULL),
271    CONF_INFO(118, conf.av_exposure_order,      CONF_DEF_VALUE, i:1, NULL),
272    CONF_INFO(119, conf.iso_exposure_order,     CONF_DEF_VALUE, i:3, NULL),
273   
274    CONF_INFO(120, conf.script_startup,         CONF_DEF_VALUE, i:0, NULL),
275    CONF_INFO(121, conf.remote_enable,          CONF_DEF_VALUE, i:0, NULL),
276   
277    CONF_INFO(122, conf.values_show_canon_overexposure, CONF_DEF_VALUE, i:0, NULL),
278    CONF_INFO(123, conf.clear_override,         CONF_DEF_VALUE, i:1, NULL),
279   
280    CONF_INFO(124, conf.show_osd_in_review,     CONF_DEF_VALUE, i:0, NULL),
281   
282    CONF_INFO(125, conf.dof_dist_from_lens,     CONF_DEF_VALUE, i:0, NULL),
283   
284    CONF_INFO(126, conf.clear_bracket,          CONF_DEF_VALUE, i:1, NULL),
285    CONF_INFO(127, conf.zebra_multichannel,     CONF_DEF_VALUE, i:0, NULL),
286
287    CONF_INFO(128, conf.nd_filter_state,        CONF_DEF_VALUE, i:0, NULL),
288    CONF_INFO(129, conf.histo_show_ev_grid,     CONF_DEF_VALUE, i:0, NULL),
289   
290    CONF_INFO(130, conf.osd_color_warn,         CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_RED), NULL),
291    CONF_INFO(131, conf.space_color,            CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL),
292    CONF_INFO(132, conf.space_icon_show,        CONF_DEF_VALUE, i:0, NULL),
293    CONF_INFO(133, conf.space_icon_pos,         CONF_DEF_PTR, ptr:&def_space_icon_pos, NULL),
294    CONF_INFO(134, conf.space_perc_show,        CONF_DEF_VALUE, i:0, NULL),
295    CONF_INFO(135, conf.space_mb_show,          CONF_DEF_VALUE, i:1, NULL),
296    CONF_INFO(136, conf.space_txt_pos,          CONF_DEF_PTR,   ptr:&def_space_txt_pos , NULL),
297    CONF_INFO(137, conf.show_remaining_raw,     CONF_DEF_VALUE, i:1, NULL),
298    CONF_INFO(138, conf.mode_raw_pos,           CONF_DEF_PTR,   ptr:&def_mode_raw_pos , NULL),
299    CONF_INFO(139, conf.show_raw_state,         CONF_DEF_VALUE, i:1, NULL),
300   
301    CONF_INFO(140, conf.show_values_in_video,   CONF_DEF_VALUE, i:0, NULL),
302    CONF_INFO(141, conf.tv_enum_type,           CONF_DEF_VALUE, i:1, NULL),
303
304    CONF_INFO(142, conf.user_menu_enable,       CONF_DEF_VALUE, i:0, NULL),
305    CONF_INFO(143, conf.user_menu_vars,         CONF_DEF_PTR,   ptr:&def_user_menu_vars, NULL),
306    CONF_INFO(144, conf.zoom_scale,             CONF_DEF_VALUE, i:100, NULL),
307    CONF_INFO(145, conf.space_bar_show,         CONF_DEF_VALUE, i:1, NULL),
308    CONF_INFO(146, conf.space_bar_size,         CONF_DEF_VALUE, i:1, NULL),
309    CONF_INFO(147, conf.space_ver_pos,          CONF_DEF_PTR, ptr:&def_space_ver_pos, NULL),
310    CONF_INFO(148, conf.space_hor_pos,          CONF_DEF_PTR, ptr:&def_space_hor_pos, NULL),   
311    CONF_INFO(149, conf.space_bar_width,        CONF_DEF_VALUE, i:2, NULL),
312    CONF_INFO(150, conf.space_perc_warn,        CONF_DEF_VALUE, i:10, NULL),
313    CONF_INFO(151, conf.space_mb_warn,          CONF_DEF_VALUE, i:20, NULL),
314    CONF_INFO(152, conf.space_warn_type,        CONF_DEF_VALUE, i:0, NULL),
315    CONF_INFO(153, conf.remaining_raw_treshold, CONF_DEF_VALUE, i:0, NULL),
316    CONF_INFO(154, conf.unlock_optical_zoom_for_video, CONF_DEF_VALUE, i:1, NULL),
317    CONF_INFO(155, conf.clock_format,           CONF_DEF_VALUE, i:0, NULL),
318    CONF_INFO(156, conf.clock_indicator,        CONF_DEF_VALUE, i:0, NULL),
319    CONF_INFO(157, conf.clock_halfpress,        CONF_DEF_VALUE, i:1, NULL),
320   
321    CONF_INFO(158, conf.autoiso_enable,         CONF_DEF_VALUE, i:0, NULL),
322    CONF_INFO(159, conf.autoiso_shutter,        CONF_DEF_VALUE, i:0, NULL),
323    CONF_INFO(160, conf.autoiso_user_factor,    CONF_DEF_VALUE, i:5, NULL),
324    CONF_INFO(161, conf.autoiso_is_factor,      CONF_DEF_VALUE, i:2, NULL),
325    CONF_INFO(162, conf.autoiso_max_iso_hi,     CONF_DEF_VALUE, i:55, NULL),
326    CONF_INFO(163, conf.autoiso_max_iso_auto,   CONF_DEF_VALUE, i:35, NULL),
327    CONF_INFO(164, conf.autoiso_min_iso,        CONF_DEF_VALUE, i:5, NULL),
328
329    CONF_INFO(165, conf.menu_title_color,       CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_WHITE, COLOR_BLACK), NULL),
330    CONF_INFO(166, conf.menu_cursor_color,      CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG), NULL),
331    CONF_INFO(167, conf.menu_center,            CONF_DEF_VALUE, i:1, NULL),
332    CONF_INFO(168, conf.mute_on_zoom,           CONF_DEF_VALUE, i:0, NULL),
333    CONF_INFO(169, conf.bad_pixel_removal,      CONF_DEF_VALUE, i:0, NULL),
334    CONF_INFO(170, conf.video_af_key,           CONF_DEF_VALUE, i:0, NULL),
335    CONF_INFO(171, conf.osd_color_override,     CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_RED), NULL),
336    CONF_INFO(172, conf.override_disable,       CONF_DEF_VALUE, i:2, NULL),
337    CONF_INFO(173, conf.override_disable_all,   CONF_DEF_VALUE, i:1, NULL),
338    CONF_INFO(174, conf.hide_osd,   CONF_DEF_VALUE, i:1, NULL),
339    CONF_INFO(175, conf.save_raw_in_video,      CONF_DEF_VALUE, i:1, NULL),
340    CONF_INFO(176, conf.show_movie_time,        CONF_DEF_VALUE, i:3, NULL),
341    CONF_INFO(177, conf.show_movie_refresh,     CONF_DEF_VALUE, i:1, NULL),
342    CONF_INFO(178, conf.mode_video_pos,         CONF_DEF_PTR,   ptr:&def_mode_video_pos , NULL),
343    CONF_INFO(179, conf.clear_video,            CONF_DEF_VALUE, i:0, NULL),
344    CONF_INFO(180, conf.fast_ev,                CONF_DEF_VALUE, i:0, NULL),
345    CONF_INFO(181, conf.fast_ev_step,           CONF_DEF_VALUE, i:1, NULL),
346    CONF_INFO(182, conf.mode_ev_pos,            CONF_DEF_PTR,   ptr:&def_mode_ev_pos , NULL),
347    CONF_INFO(183, conf.menu_symbol_rbf_file,   CONF_DEF_PTR,   ptr:"A/CHDK/SYMBOLS/icon_10.rbf", conf_change_menu_symbol_rbf_file),
348    CONF_INFO(184, conf.menu_symbol_color,      CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL),
349    CONF_INFO(185, conf.curve_file,             CONF_DEF_PTR, ptr:"", NULL),
350    CONF_INFO(186, conf.curve_enable,           CONF_DEF_VALUE, i:0, NULL),
351    CONF_INFO(187, conf.edge_overlay_enable,    CONF_DEF_VALUE, i:0, NULL),
352    CONF_INFO(188, conf.edge_overlay_thresh,    CONF_DEF_VALUE, i:40, NULL),
353    CONF_INFO(189, conf.edge_overlay_color,     CONF_DEF_VALUE, cl:0x66, NULL),
354    CONF_INFO(190, conf.synch_enable,           CONF_DEF_VALUE, i:0, NULL),
355    CONF_INFO(191, conf.synch_delay_enable,     CONF_DEF_VALUE, i:0, NULL),
356    CONF_INFO(192, conf.synch_delay_value,      CONF_DEF_VALUE, i:100, NULL),
357    CONF_INFO(193, conf.synch_delay_coarse_value, CONF_DEF_VALUE, i:0, NULL),
358    CONF_INFO(194, conf.script_file,            CONF_DEF_PTR,   ptr:"", conf_change_script_file),
359    CONF_INFO(195, conf.mem_view_addr_init,     CONF_DEF_VALUE, i:0x1000, NULL),
360    CONF_INFO(196, conf.save_raw_in_sports,     CONF_DEF_VALUE, i:0, NULL),
361    CONF_INFO(197, conf.save_raw_in_burst,      CONF_DEF_VALUE, i:0, NULL),
362    CONF_INFO(198, conf.save_raw_in_ev_bracketing, CONF_DEF_VALUE, i:0, NULL),
363    CONF_INFO(199, conf.save_raw_in_timer,      CONF_DEF_VALUE, i:0, NULL),
364    CONF_INFO(200, conf.raw_exceptions_warn,    CONF_DEF_VALUE, i:1, NULL),
365    CONF_INFO(201, conf.menu_select_first_entry, CONF_DEF_VALUE, i:1, NULL),
366    CONF_INFO(202, conf.fast_movie_control,     CONF_DEF_VALUE, i:0, NULL),
367    CONF_INFO(203, conf.show_temp,              CONF_DEF_VALUE, i:1, NULL),
368    CONF_INFO(204, conf.temp_pos,               CONF_DEF_PTR,   ptr:&def_temp_pos , NULL),
369    CONF_INFO(205, conf.fast_movie_quality_control, CONF_DEF_VALUE, i:1, NULL),
370    CONF_INFO(206, conf.remote_zoom_enable,     CONF_DEF_VALUE, i:0, NULL),
371    CONF_INFO(207, conf.zoom_timeout,           CONF_DEF_VALUE, i:5, NULL),
372        CONF_INFO(208, conf.start_sound,     CONF_DEF_VALUE, i:0, NULL),
373    CONF_INFO(209, conf.sub_batch_prefix,  CONF_DEF_VALUE, i:2, NULL), // SND_
374    CONF_INFO(210, conf.sub_batch_ext,  CONF_DEF_VALUE, i:1, NULL), // .CRW
375    CONF_INFO(211, conf.sub_in_dark_value,  CONF_DEF_VALUE, i:30, NULL),
376    CONF_INFO(212, conf.sub_out_dark_value,  CONF_DEF_VALUE, i:0, NULL),
377        CONF_INFO(213, conf.debug_display,     CONF_DEF_VALUE, i:0, NULL),
378        CONF_INFO(214, conf.script_param_save,     CONF_DEF_VALUE, i:1, NULL),
379    CONF_INFO(215, conf.ev_video_pos,           CONF_DEF_PTR,   ptr:&def_ev_video_pos, NULL),
380    CONF_INFO(216, conf.zoom_override_value,     CONF_DEF_VALUE, i:0, NULL),
381    CONF_INFO(217, conf.zoom_override,      CONF_DEF_VALUE, i:0, NULL),
382    CONF_INFO(218, conf.clear_zoom_override,         CONF_DEF_VALUE, i:1, NULL),                       
383    CONF_INFO(219, conf.bracketing_add_raw_suffix,         CONF_DEF_VALUE, i:0, NULL),                 
384    CONF_INFO(220, conf.temperature_unit,              CONF_DEF_VALUE, i:0, NULL),
385    CONF_INFO(221, conf.clear_zoom_override,         CONF_DEF_VALUE, i:1, NULL),                       
386    CONF_INFO(222, conf.edge_overlay_play,    CONF_DEF_VALUE, i:0, NULL),
387    CONF_INFO(223, conf.edge_overlay_lock,              CONF_DEF_VALUE, i:0, NULL),
388    CONF_INFO(224, conf.edge_overlay_zoom,                CONF_DEF_VALUE, i:1, NULL),
389    CONF_INFO(225, conf.raw_cache,              CONF_DEF_VALUE, i:0, NULL),
390    CONF_INFO(226, conf.dng_raw,                CONF_DEF_VALUE, i:0, conf_change_dng),
391    CONF_INFO(227, conf.flash_sync_curtain,     CONF_DEF_VALUE, i:0, NULL),
392    CONF_INFO(228, conf.raw_timer,     CONF_DEF_VALUE, i:0, NULL),
393    CONF_INFO(229, conf.platformid,     CONF_DEF_VALUE, i:PLATFORMID, NULL),
394    CONF_INFO(230, conf.save_raw_in_edgeoverlay,     CONF_DEF_VALUE, i:0, NULL),
395    CONF_INFO(231, conf.save_raw_in_auto,     CONF_DEF_VALUE, i:0, NULL),
396    CONF_INFO(232, conf.flash_video_override,     CONF_DEF_VALUE, i:0, NULL),
397    CONF_INFO(233, conf.flash_video_override_power,     CONF_DEF_VALUE, i:0, NULL),
398    CONF_INFO(234, conf.raw_dng_ext,     CONF_DEF_VALUE, i:0, NULL),
399    CONF_INFO(235, conf.dng_usb_ext,     CONF_DEF_VALUE, i:0, conf_change_dng_ext),
400    CONF_INFO(236, conf.flash_manual_override,     CONF_DEF_VALUE, i:0, NULL),
401    };
402#define CONF_NUM (sizeof(conf_info)/sizeof(conf_info[0]))
403
404//-------------------------------------------------------------------
405static void conf_change_histo_mode() {
406    histogram_set_mode(conf.histo_mode);
407}
408
409static void conf_change_histo_layout() {
410    if (conf.histo_layout==OSD_HISTO_LAYOUT_Y || conf.histo_layout==OSD_HISTO_LAYOUT_Y_argb) {
411        histogram_set_main(HISTO_Y);
412    } else {
413        histogram_set_main(HISTO_RGB);
414    }
415}
416
417static void conf_change_font_cp() {
418    font_init();
419    font_set(conf.font_cp);
420}
421
422static void conf_change_script_file() {
423    script_load(conf.script_file, 2);
424}
425
426static void conf_change_menu_rbf_file() {
427    if (!rbf_load(conf.menu_rbf_file))
428        rbf_load_from_8x16(current_font);
429    rbf_set_codepage(FONT_CP_WIN);
430}
431
432static void conf_change_menu_symbol_rbf_file() {
433    if(!rbf_load_symbol(conf.menu_symbol_rbf_file)) conf.menu_symbol_enable=0;          //AKA
434}
435
436static void conf_change_alt_mode_button() {
437#if CAM_ADJUSTABLE_ALT_BUTTON
438    kbd_set_alt_mode_key_mask(conf.alt_mode_button);
439#else
440    conf.alt_mode_button = KEY_PRINT;
441#endif
442}
443
444static void conf_change_grid_file() {
445    grid_lines_load(conf.grid_lines_file);
446}
447
448static void conf_change_video_bitrate() {
449    shooting_video_bitrate_change(conf.video_bitrate);
450 }
451
452void conf_change_dng(void){
453#if DNG_SUPPORT
454 if (conf.dng_raw) {
455  if (!badpixel_list_loaded_b()) load_bad_pixels_list_b("A/CHDK/badpixel.bin");
456  if (!badpixel_list_loaded_b()) conf.dng_raw=0;
457 }
458 else unload_bad_pixels_list_b();
459#endif
460}
461
462void conf_change_dng_ext(void){
463#if defined (DNG_EXT_FROM)
464 save_ext_for_dng();
465 if (conf.dng_usb_ext) change_ext_to_dng(); else change_ext_to_default();
466#endif
467}
468
469//-------------------------------------------------------------------
470static void conf_init_defaults() {
471    // init some defaults values
472    def_batt_volts_max = get_vbatt_max();
473    def_batt_volts_min = get_vbatt_min();
474    def_histo_pos.x = 45;
475    def_histo_pos.y = vid_get_bitmap_screen_height()-HISTO_HEIGHT-40;
476    def_dof_pos.x = 90;
477    def_dof_pos.y = 45;
478    def_batt_icon_pos.x = 178;
479    def_batt_icon_pos.y = 0;
480    def_batt_txt_pos.x=178;
481    def_batt_txt_pos.y=1*FONT_HEIGHT;
482    def_space_icon_pos.x = vid_get_bitmap_screen_width()-100;
483    def_space_icon_pos.y = 0;
484    def_space_ver_pos.x = vid_get_bitmap_screen_width()-7;
485    def_space_ver_pos.y = 0;
486    def_space_hor_pos.x = 0;
487    def_space_hor_pos.y = vid_get_bitmap_screen_height()-7;
488    def_space_txt_pos.x=128;
489    def_space_txt_pos.y=0;
490    def_mode_state_pos.x=35;
491    def_mode_state_pos.y=0;
492    def_mode_raw_pos.x=vid_get_bitmap_screen_width()-7*FONT_WIDTH-2;
493    def_mode_raw_pos.y=vid_get_bitmap_screen_height()-3*FONT_HEIGHT-2;
494    def_mode_video_pos.x=vid_get_bitmap_screen_width()-25*FONT_WIDTH-2;
495    def_mode_video_pos.y=vid_get_bitmap_screen_height()-6*FONT_HEIGHT-2;
496    def_mode_ev_pos.x=vid_get_bitmap_screen_width()-40*FONT_WIDTH-2;
497    def_mode_ev_pos.y=vid_get_bitmap_screen_height()-8*FONT_HEIGHT-2;
498    def_values_pos.x=vid_get_bitmap_screen_width()-9*FONT_WIDTH;
499    def_values_pos.y=30;
500    def_clock_pos.x=vid_get_bitmap_screen_width()-5*FONT_WIDTH-2;
501    def_clock_pos.y=0;
502    def_temp_pos.x=vid_get_bitmap_screen_width()-9*FONT_WIDTH-2;
503    def_temp_pos.y=1*FONT_HEIGHT;
504    def_ev_video_pos.x=18;
505    def_ev_video_pos.y=80;
506
507}
508
509//-------------------------------------------------------------------
510void conf_load_defaults() {
511    register int i;
512
513    for (i=0; i<CONF_NUM; ++i) {
514        switch (conf_info[i].type) {
515            case CONF_DEF_VALUE:
516                memcpy(conf_info[i].var, &(conf_info[i].i), conf_info[i].size);
517                break;
518            case CONF_DEF_PTR:
519                memcpy(conf_info[i].var, conf_info[i].ptr, conf_info[i].size);
520                break;
521        }
522        if (conf_info[i].func) {
523            conf_info[i].func();
524        }
525    }
526}
527
528//-------------------------------------------------------------------
529void conf_save() {
530    static const long t=CONF_MAGICK_VALUE;
531    register int i;
532    int fd;
533    char *buf=umalloc(sizeof(t)+CONF_NUM*(sizeof(conf_info[0].id)+sizeof(conf_info[0].size))+sizeof(conf));
534    char *p=buf;
535
536    fd = open(CONF_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0777);
537    if (fd>=0){
538        memcpy(p, &t, sizeof(t));
539        p+=sizeof(t);
540        for (i=0; i<CONF_NUM; ++i) {
541            memcpy(p, &(conf_info[i].id), sizeof(conf_info[i].id));
542            p+=sizeof(conf_info[i].id);
543            memcpy(p, &(conf_info[i].size), sizeof(conf_info[i].size));
544            p+=sizeof(conf_info[i].size);
545            memcpy(p, conf_info[i].var, conf_info[i].size);
546            p+=conf_info[i].size;
547        }
548
549        write(fd, buf, p-buf);
550        close(fd);
551    }
552        ufree(buf);
553}
554
555//-------------------------------------------------------------------
556void conf_restore() {
557    int fd, rcnt, i;
558    unsigned short id, size;
559    char *buf;
560    int offs;
561    struct stat st;
562
563    conf_init_defaults();
564
565    conf_load_defaults();
566
567    if( stat(CONF_FILE,&st) != 0 && st.st_size < sizeof(int))
568        return;
569
570    if(!(buf=umalloc(st.st_size)))
571        return;
572
573    fd = open(CONF_FILE, O_RDONLY, 0777);
574    if( fd < 0 ) {
575        ufree(buf);
576        return;
577    }
578   
579    rcnt = read(fd,buf,st.st_size);
580    close(fd);
581    // read magick value
582    if (*(int *)buf!=CONF_MAGICK_VALUE || rcnt != st.st_size) {
583        ufree(buf);
584        return;
585    }
586    offs=sizeof(int);
587    while (1) {
588        if (offs + sizeof(short) > rcnt)
589            break;
590        id=*((short *)(buf + offs));
591        offs += sizeof(short);
592
593        if (offs + sizeof(short) > rcnt)
594            break;
595        size=*((short *)(buf + offs));
596        offs += sizeof(short);
597
598        for (i=0; i<CONF_NUM; ++i) {
599            if (conf_info[i].id==id && conf_info[i].size==size) {
600                if (offs + size <= rcnt) {
601                   memcpy(conf_info[i].var, buf+offs, size);
602                   if (conf_info[i].func) {
603                       conf_info[i].func();
604                   }
605                }
606                offs += size;
607                break;
608            }
609        }
610        if (i == CONF_NUM) { // unknown id, just skip data
611            offs += size;
612        }
613    }
614    ufree(buf);
615    // clear any "clear on restart" values
616    clear_values();
617}
618
619//-------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.