From 5cac94f007114aafc4a358eb3775a91871fe3853 Mon Sep 17 00:00:00 2001 From: phyrephox Date: Tue, 25 Nov 2008 22:42:15 +0000 Subject: [PATCH] * updated french.lng + added "saving time switch" in raw menu (better in debug menu?) - it is disabled at default (when enabled, shows time it takes to save raw/dng) + added a feature that allows using cfgs from a different camera by resetting "critical" settings on startup of the platform id doesnt match (more settings? less settings? need input) + added "get_platform_id" to ubasic, which returns platformid (integer), with the help of this you can code platform depending scripts (in lua we dont need this, as we can get strings there) + finally added Bill's user menu mod - see http://chdk.setepontos.com/index.php/topic,2179.msg20301.html#msg20301 (something's still need to be done about the models without zoom lever) git-svn-id: http://tools.assembla.com/svn/chdk/trunk@593 6794e30b-3f2a-0410-a806-a2bbca1c07ff --- CHDK/LANG/english.lng | 1 + CHDK/LANG/french.lng | 10 ++++ CHDK/LANG/german.lng | 3 +- core/conf.c | 13 +++++ core/gui.c | 130 ++++++++++++++++++++++++++++------------- core/gui_lang.c | 1 + core/gui_lang.h | 3 +- core/gui_menu.c | 121 +++++++++++++++++++++++++++++++------- core/gui_menu.h | 2 +- core/raw.c | 10 ++-- doc/version.txt | 7 +++ include/conf.h | 2 + lib/ubasic/tokenizer.c | 1 + lib/ubasic/tokenizer.h | 1 + lib/ubasic/ubasic.c | 4 ++ makefile.inc | 2 +- version.inc | 2 +- 17 files changed, 243 insertions(+), 70 deletions(-) diff --git a/CHDK/LANG/english.lng b/CHDK/LANG/english.lng index dcd0da79..2aa479ba 100644 --- a/CHDK/LANG/english.lng +++ b/CHDK/LANG/english.lng @@ -565,3 +565,4 @@ 424 "DNG format" 425 "RAW buffer cached" 426 "Cannot load CHDK/badpixel.bin" +427 "Show raw saving time" \ No newline at end of file diff --git a/CHDK/LANG/french.lng b/CHDK/LANG/french.lng index 8b8831dd..c684e58c 100644 --- a/CHDK/LANG/french.lng +++ b/CHDK/LANG/french.lng @@ -516,3 +516,13 @@ 414 " Clear on start" 415 "Ajouter un suffix RAW" 416 " Fahrenheit" +417 "Load Edge Overlay" +418 "Save Edge Overlay" +419 "Enable in Play" +420 "Free internal Memory" +421 "Load+Set Zoom" +422 "Lock Edge Overlay" +423 "Rear curtain flash sync" +424 "DNG format" +425 "RAW buffer cached" +426 "Cannot load CHDK/badpixel.bin" diff --git a/CHDK/LANG/german.lng b/CHDK/LANG/german.lng index 3853ab83..a5fd35b6 100644 --- a/CHDK/LANG/german.lng +++ b/CHDK/LANG/german.lng @@ -601,4 +601,5 @@ // DNG 424 "DNG-Format" 425 "RAW-Puffer nutzen" -426 "Datei badpixel.bin fehlt!" \ No newline at end of file +426 "Datei badpixel.bin fehlt!" +427 "Zeige raw speicherzeit" \ No newline at end of file diff --git a/core/conf.c b/core/conf.c index fdaa9a19..97f78501 100644 --- a/core/conf.c +++ b/core/conf.c @@ -106,6 +106,17 @@ int ubasic_camera_get_nr() void clear_values() { + if (conf.platformid != (int)PLATFORMID) // the following config entries will be resetted if you switch the camera using the same cfg + { + conf.raw_cache = 0; + conf.zoom_override_value = 0; + conf.fast_ev = 0; + conf.fast_movie_control = 0; + conf.fast_movie_quality_control = 0; + conf.zoom_scale = 100; + conf.platformid = (int)PLATFORMID; + } + if (conf.clear_override) { conf.av_override_value=0; @@ -377,6 +388,8 @@ static const ConfInfo conf_info[] = { CONF_INFO(225, conf.raw_cache, CONF_DEF_VALUE, i:0, NULL), CONF_INFO(226, conf.dng_raw, CONF_DEF_VALUE, i:0, conf_change_dng), CONF_INFO(227, conf.flash_sync_curtain, CONF_DEF_VALUE, i:0, NULL), + CONF_INFO(228, conf.raw_timer, CONF_DEF_VALUE, i:0, NULL), + CONF_INFO(229, conf.platformid, CONF_DEF_VALUE, i:(int)PLATFORMID, NULL), }; #define CONF_NUM (sizeof(conf_info)/sizeof(conf_info[0])) diff --git a/core/gui.c b/core/gui.c index d8d2b153..74f5f199 100644 --- a/core/gui.c +++ b/core/gui.c @@ -652,27 +652,17 @@ static CMenuItem visual_submenu_items[] = { }; static CMenu visual_submenu = {0x28,LANG_MENU_VIS_TITLE, NULL, visual_submenu_items }; -void blank_menu() -{}; - -static CMenuItem user_submenu_items[] = { - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}, - {0x20,LANG_MENU_MAIN_TITLE, MENUITEM_PROC, (int*)rinit}, - {0} +/* + * 1 extra entry for the "Main menu" and 1 for null when the menu is full with user selections + * Compiler will zero init remaining portion of array so no there is no hidden relationship between + * this structure and the value of USER_MENU_ITEMS. The value of USER_MENU_ITEMS can be anything you + * wish and everything automagically works. +*/ + +static CMenuItem user_submenu_items[USER_MENU_ITEMS + 2] = { + {0x20,LANG_MENU_MAIN_TITLE, MENUITEM_PROC, (int*)rinit} }; + static CMenu user_submenu = {0x2e,LANG_MENU_USER_MENU, NULL, user_submenu_items }; static CMenuItem raw_state_submenu_items[] = { @@ -767,6 +757,7 @@ static CMenuItem raw_submenu_items[] = { {0x5c, LANG_MENU_DNG_FORMAT, MENUITEM_BOOL | MENUITEM_ARG_CALLBACK, &conf.dng_raw , (int)cb_change_dng }, #endif {0x5c,LANG_MENU_RAW_CACHED, MENUITEM_BOOL, &conf.raw_cache }, + {0x5c,LANG_MENU_RAW_TIMER, MENUITEM_BOOL, &conf.raw_timer }, {0x51,LANG_MENU_BACK, MENUITEM_UP }, {0} }; @@ -827,21 +818,75 @@ static int gui_user_menu_flag; void rinit(){ gui_menu_init(&root_menu); - draw_restore(); - gui_force_restore(); } -static CMenuItem blank_menu_item = {0x0,LANG_MENU_ITEM_BLANK, MENUITEM_PROC, (int*)blank_menu,0}; +//------------------------------------------------------------------- +void +mod_user_menu(CMenuItem curr_menu_item, int* cur_memnu_item_indx, int mod) { +int i; +CMenuItem tmp_menu_item; + switch(mod) { -void add_user_menu(CMenuItem curr_menu_item, int* gui_menu_add_item, int del) { - if (*gui_menu_add_item 1)) { + tmp_menu_item = user_submenu_items[*cur_memnu_item_indx -1]; + user_submenu_items[*cur_memnu_item_indx -1] = user_submenu_items[*cur_memnu_item_indx]; + user_submenu_items[*cur_memnu_item_indx] = tmp_menu_item; + *cur_memnu_item_indx -=1; + } + break; + + case 3: + /* + * Move entry down below next entry if next entry is not empty + */ + if (*cur_memnu_item_indx == 0) /* don't allow moving "user menu" */ + break; + if((*cur_memnu_item_indx < (USER_MENU_ITEMS)) && (user_submenu_items[*cur_memnu_item_indx +1].text)) { + tmp_menu_item = user_submenu_items[*cur_memnu_item_indx +1]; + user_submenu_items[*cur_memnu_item_indx + 1] = user_submenu_items[*cur_memnu_item_indx]; + user_submenu_items[*cur_memnu_item_indx] = tmp_menu_item; + *cur_memnu_item_indx +=1; + } + break; + + } } //------------------------------------------------------------------- @@ -3083,15 +3128,22 @@ int find_mnu(CMenu *curr_menu, int mnu, int count) void user_menu_save() { int x; for (x=0; xtitle != LANG_MENU_USER_MENU) - add_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_add_item, 0); - else - add_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_add_item, 1); - gui_menu_redraw=1; + if (curr_menu->title != LANG_MENU_USER_MENU) { + /* + * Add new entry + * user menu is currently not visible so no redraw necessary + */ + mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 1); + } + else { + int x; + /* + * Remove entry from menu + */ + mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 0); + + + /* + * Check to see if the last visible entry was deleted and we need need + * to move up our top menu item. + */ + if(gui_menu_top_item) + if(!curr_menu->menu[gui_menu_top_item + num_lines-1].text) + gui_menu_top_item--; + + /* + * menu list is smaller so have to redraw everything to get + * things like scroll bar correct. + */ + gui_menu_redraw=2; + + /* + * Count the numer of menu entries + */ + for(x = 0; curr_menu->menu[x].text; x++) + ; + + /* + * if the new menu is smaller than visible menu lines on screen + * you have to restore full screen before menu redraw. + * If you don't do this, then a new smaller menu will be drawn + * on top of the older larger menu + * + */ + if(x < num_lines) + draw_restore(); + } } break; case JOGDIAL_LEFT: @@ -127,7 +166,6 @@ static char sbuf[7]; (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR); int_incr = 1; gui_menu_redraw=1; - if (curr_menu->title == LANG_MENU_USER_MENU) gui_menu_add_item = gui_menu_curr_item; } break; case JOGDIAL_RIGHT: @@ -149,7 +187,6 @@ static char sbuf[7]; (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR); int_incr = 1; gui_menu_redraw=1; - if (curr_menu->title == LANG_MENU_USER_MENU) gui_menu_add_item = gui_menu_curr_item; } break; case KEY_LEFT: @@ -398,21 +435,50 @@ static char sbuf[7]; #if CAM_HAS_ZOOM_LEVER case KEY_ZOOM_IN: - if (int_incr >= 10){ - int_incr /= 10; - } - sprintf(sbuf, "±%d",int_incr); - draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); - draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); - break; + /* + * Move current entry up in menu + * if in user menu edit mode and viewing user menu + */ + if( (conf.user_menu_enable == 3) && (curr_menu->title == LANG_MENU_USER_MENU)) { + mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 2); + if(gui_menu_curr_item < gui_menu_top_item+1) { + if(gui_menu_curr_item) + gui_menu_top_item = gui_menu_curr_item-1; + } + + gui_menu_redraw=1; + } + else { + if (int_incr >= 10){ + int_incr /= 10; + } + sprintf(sbuf, "±%d",int_incr); + draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); + draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); + } + break; case KEY_ZOOM_OUT: - if (int_incr <= 1000){ - int_incr *= 10; - } - sprintf(sbuf, "±%d",int_incr); - draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); - break; + /* + * Move current entry down in menu + * if in user menu edit mode and viewing user menu + */ + if( (conf.user_menu_enable == 3) && (curr_menu->title == LANG_MENU_USER_MENU)) { + mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 3); + gui_menu_redraw=1; + if(gui_menu_curr_item > gui_menu_top_item + num_lines -2) { + if((gui_menu_curr_item < USER_MENU_ITEMS) && curr_menu->menu[gui_menu_curr_item +1].text) + gui_menu_top_item++; + } + } + else { + if (int_incr <= 1000){ + int_incr *= 10; + } + sprintf(sbuf, "±%d",int_incr); + draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); + } + break; case KEY_DISPLAY: if (gui_menu_stack_ptr > 0){ @@ -492,7 +558,18 @@ void gui_menu_draw() { for (imenu=gui_menu_top_item, i=0, yy=y; curr_menu->menu[imenu].text && i>8)&0xFF,(conf.menu_symbol_color>>8)&0xFF):conf.menu_symbol_color; //color 8Bit=Hintergrund 8Bit=Vordergrund + /* + * When cursor is over a symbol, force symbol background color to be the menu cursor color but + * keep the symbol color user defined. + * old method was to set the symbol color to the symbol background color when the cursor highlighted it. + * This method allows the user to have any symbol color and background color they want with the restriction + * that the symbol background color will match the rest of the line when the cursor highlights it. + * It creates a nice consistent look expecially when the symbol color matches the menu text color. + * without this mod, there is no way to ever make the symbol color match the color of the rest of text menu line + * when the cursor highlights a line. + */ + cl_symbol=(gui_menu_curr_item==imenu)?MAKE_COLOR((cl>>8)&0xFF,(conf.menu_symbol_color)&0xFF):conf.menu_symbol_color; //color 8Bit=Hintergrund 8Bit=Vordergrund + xx = x; switch (curr_menu->menu[imenu].type & MENUITEM_MASK) { diff --git a/core/gui_menu.h b/core/gui_menu.h index 8c580b5c..e93b110a 100644 --- a/core/gui_menu.h +++ b/core/gui_menu.h @@ -48,7 +48,7 @@ typedef struct { extern void gui_menu_init(CMenu *menu_ptr); extern void gui_menu_kbd_process(); extern void gui_menu_draw(); -extern void add_user_menu(CMenuItem curr_menu_item, int* gui_menu_add_item, int del); +extern void mod_user_menu(CMenuItem curr_menu_item, int* gui_menu_add_item, int mod); //------------------------------------------------------------------- #endif diff --git a/core/raw.c b/core/raw.c index 74a23351..26db7e1e 100644 --- a/core/raw.c +++ b/core/raw.c @@ -167,10 +167,12 @@ timer=get_tick_count(); if (thumbnail_buf) free(thumbnail_buf); } #endif -timer=get_tick_count()-timer; -sprintf(txt, "saving time=%d", timer); -script_console_add_line(txt); - +if (conf.raw_timer) + { + timer=get_tick_count()-timer; + sprintf(txt, "saving time=%d", timer); + script_console_add_line(txt); + } } finished(); diff --git a/doc/version.txt b/doc/version.txt index 2e0c2ce1..95a90afb 100644 --- a/doc/version.txt +++ b/doc/version.txt @@ -2,6 +2,13 @@ CHDK Trunk / Autobuild History version / revision / author +0.8.3 / #593 / PhyrePhoX + +* updated french.lng ++ added "saving time switch" in raw menu (better in debug menu?) - it is disabled at default (when enabled, shows time it takes to save raw/dng) ++ added a feature that allows using cfgs from a different camera by resetting "critical" settings on startup of the platform id doesnt match (more settings? less settings? need input) ++ added "get_platform_id" to ubasic, which returns platformid (integer), with the help of this you can code platform depending scripts (in lua we dont need this, as we can get strings there) + 0.8.2 / #592 / PhyrePhoX * fixed a590 zoom table (see http://chdk.setepontos.com/index.php/topic,2659.msg24733.html#msg24733) diff --git a/include/conf.h b/include/conf.h index 090717bb..369d63c9 100644 --- a/include/conf.h +++ b/include/conf.h @@ -29,6 +29,7 @@ typedef struct { int sub_out_dark_value; // minimum value to output from subtract, i.e. dark value of your final image int raw_cache; int dng_raw; + int raw_timer; int show_osd; int hide_osd; @@ -147,6 +148,7 @@ typedef struct { int fast_movie_quality_control; int splash_show; int start_sound; + int platformid; int use_zoom_mf; long alt_mode_button; //for S-series diff --git a/lib/ubasic/tokenizer.c b/lib/ubasic/tokenizer.c index 5195ae2f..607439cb 100644 --- a/lib/ubasic/tokenizer.c +++ b/lib/ubasic/tokenizer.c @@ -120,6 +120,7 @@ static const struct keyword_token keywords[] = { {"get_movie_status", TOKENIZER_GET_MOVIE_STATUS}, {"get_mode", TOKENIZER_GET_MODE}, // Returns 0 in recordmode, 1 in playmode {"get_near_limit", TOKENIZER_GET_NEAR_LIMIT}, + {"get_platform_id", TOKENIZER_GET_PLATFORM_ID}, {"get_propset", TOKENIZER_GET_PROPSET}, {"get_prop", TOKENIZER_GET_PROP}, {"get_quality", TOKENIZER_GET_QUALITY}, diff --git a/lib/ubasic/tokenizer.h b/lib/ubasic/tokenizer.h index f419abde..5b3e5837 100644 --- a/lib/ubasic/tokenizer.h +++ b/lib/ubasic/tokenizer.h @@ -185,6 +185,7 @@ typedef enum { TOKENIZER_GET_QUALITY, TOKENIZER_SET_RESOLUTION, TOKENIZER_SET_QUALITY, + TOKENIZER_GET_PLATFORM_ID, } ubasic_token; diff --git a/lib/ubasic/ubasic.c b/lib/ubasic/ubasic.c index 63bc6b4a..c634f331 100644 --- a/lib/ubasic/ubasic.c +++ b/lib/ubasic/ubasic.c @@ -269,6 +269,10 @@ case TOKENIZER_IS_PRESSED: accept(TOKENIZER_GET_MOVIE_STATUS); r = movie_status; break; + case TOKENIZER_GET_PLATFORM_ID: + accept(TOKENIZER_GET_PLATFORM_ID); + r = (int)PLATFORMID; + break; case TOKENIZER_GET_DRIVE_MODE: accept(TOKENIZER_GET_DRIVE_MODE); r = shooting_get_prop(PROPCASE_DRIVE_MODE); diff --git a/makefile.inc b/makefile.inc index 7a84b41f..2d38432a 100644 --- a/makefile.inc +++ b/makefile.inc @@ -286,7 +286,7 @@ endif CTHUMB=-mthumb CFLAGS+=-mthumb-interwork CFLAGS+=-I$(topdir)include $(PLFLAGS) $(CPPFLAGS) -CFLAGS+=-DPLATFORM=\"$(PLATFORM)\" -DPLATFORMSUB=\"$(PLATFORMSUB)\" -DHDK_VERSION=\"$(VER)\" -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" -DCAMERA_$(PLATFORM)=1 +CFLAGS+=-DPLATFORM=\"$(PLATFORM)\" -DPLATFORMSUB=\"$(PLATFORMSUB)\" -DPLATFORMID=\"$(PLATFORMID)\" -DHDK_VERSION=\"$(VER)\" -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" -DCAMERA_$(PLATFORM)=1 CFLAGS+=-Wall -Wno-unused -Wno-format LDFLAGS=-L$(topdir)lib/math -L$(topdir)lib/font LDFLAGS+=-L$(topdir)lib/libc -L$(topdir)lib/ubasic diff --git a/version.inc b/version.inc index a24ce397..f6b892c5 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -BUILD_NUMBER := 0.8.2 +BUILD_NUMBER := 0.8.3