- Timestamp:
- 01/09/11 02:59:52 (2 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
-
core/conf.c (modified) (1 diff)
-
core/gui.c (modified) (21 diffs)
-
core/gui_draw.c (modified) (1 diff)
-
core/gui_menu.c (modified) (1 diff)
-
core/kbd.c (modified) (5 diffs)
-
core/luascript.c (modified) (2 diffs)
-
core/main.c (modified) (3 diffs)
-
core/motion_detector.h (modified) (1 diff)
-
core/ptp.c (modified) (11 diffs)
-
core/script.c (modified) (19 diffs)
-
include/gui.h (modified) (1 diff)
-
include/script.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/conf.c
r986 r1034 422 422 423 423 static void conf_change_script_file() { 424 #ifdef OPT_SCRIPTING 424 425 script_load(conf.script_file, 2); 426 #endif 425 427 } 426 428 -
trunk/core/gui.c
r1022 r1034 37 37 #include "gui_grid.h" 38 38 #include "histogram.h" 39 #include "script.h"40 39 #include "motion_detector.h" 41 40 #include "raw.h" … … 46 45 #include "edgeoverlay.h" 47 46 #endif 47 #ifdef OPT_SCRIPTING 48 #include "script.h" 49 int script_params_has_changed=0; 50 #endif 48 51 //------------------------------------------------------------------- 49 52 … … 51 54 #define SPLASH_TIME 20 52 55 53 int script_params_has_changed=0;54 56 //shortcuts 55 57 //------------------------------------------------------------------ … … 145 147 static void gui_draw_fselect(int arg); 146 148 static void gui_draw_osd_le(int arg); 147 static void gui_load_script(int arg);148 static void gui_load_script_default(int arg);149 149 #ifdef OPT_TEXTREADER 150 150 static void gui_draw_read(int arg); … … 244 244 static const char* gui_video_af_key_enum(int change, int arg); 245 245 static const char* gui_show_movie_time(int change, int arg); 246 static const char* gui_script_autostart_enum(int change, int arg);247 static const char* gui_script_param_set_enum(int change, int arg);248 246 static const char* gui_override_disable_enum(int change, int arg); 249 247 #ifdef OPT_CURVES … … 260 258 static void gui_menuproc_edge_load(int arg); 261 259 static const char* gui_edge_pano_enum(int change, int arg); 260 #endif 261 262 #ifdef OPT_SCRIPTING 263 static void gui_load_script(int arg); 264 static void gui_load_script_default(int arg); 265 static const char* gui_script_autostart_enum(int change, int arg); 266 static const char* gui_script_param_set_enum(int change, int arg); 262 267 #endif 263 268 … … 306 311 static CMenu remote_submenu = {0x86,LANG_MENU_REMOTE_PARAM_TITLE, NULL, remote_submenu_items }; 307 312 313 314 #ifdef OPT_SCRIPTING 308 315 static CMenuItem script_submenu_items_top[] = { 309 316 {0x35,LANG_MENU_SCRIPT_LOAD, MENUITEM_PROC, (int*)gui_load_script }, … … 333 340 sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0])]; 334 341 static CMenu script_submenu = {0x27,LANG_MENU_SCRIPT_TITLE, NULL, script_submenu_items }; 335 342 #endif 336 343 337 344 static CMenuItem games_submenu_items[] = { … … 394 401 {0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION, MENUITEM_ENUM, (int*)gui_debug_shortcut_enum }, 395 402 {0x5c,LANG_MENU_RAW_TIMER, MENUITEM_BOOL, &conf.raw_timer }, 403 #ifdef OPT_LUA 396 404 {0x5c,LANG_MENU_LUA_RESTART, MENUITEM_BOOL, &conf.debug_lua_restart_on_error }, 405 #endif 397 406 #if CAM_MULTIPART 398 407 {0x33,LANG_MENU_DEBUG_CREATE_MULTIPART , MENUITEM_PROC, (int*)gui_menuproc_break_card }, … … 859 868 {0x22,LANG_MENU_MAIN_OSD_PARAM, MENUITEM_SUBMENU, (int*)&osd_submenu }, 860 869 {0x28,LANG_MENU_MAIN_VISUAL_PARAM, MENUITEM_SUBMENU, (int*)&visual_submenu }, 870 #ifdef OPT_SCRIPTING 861 871 {0x27,LANG_MENU_MAIN_SCRIPT_PARAM, MENUITEM_SUBMENU, (int*)&script_submenu }, 872 #endif 862 873 {0x29,LANG_MENU_MAIN_MISC, MENUITEM_SUBMENU, (int*)&misc_submenu }, 863 874 #ifndef OPTIONS_AUTOSAVE … … 1035 1046 } 1036 1047 #endif 1048 1049 #ifdef OPT_SCRIPTING 1037 1050 //------------------------------------------------------------------- 1038 1051 const char* gui_script_autostart_enum(int change, int arg) { … … 1059 1072 } 1060 1073 1074 //------------------------------------------------------------------- 1075 void gui_update_script_submenu() { 1076 register int p=0, i; 1077 1078 for (i=0; i<sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0]); ++p, ++i) { 1079 script_submenu_items[p]=script_submenu_items_top[i]; 1080 } 1081 for (i=0; i<SCRIPT_NUM_PARAMS; ++i) { 1082 if (script_param_order[i]) { 1083 script_submenu_items[p].symbol=0x0; 1084 script_submenu_items[p].text=(int)script_params[script_param_order[i]-1]; 1085 script_submenu_items[p].type=MENUITEM_INT; 1086 script_submenu_items[p].value=&conf.ubasic_vars[script_param_order[i]-1]; 1087 ++p; 1088 } 1089 } 1090 for (i=0; i<sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0]); ++p, ++i) { 1091 script_submenu_items[p]=script_submenu_items_bottom[i]; 1092 } 1093 } 1094 1095 //------------------------------------------------------------------- 1096 static void gui_load_script_selected(const char *fn) { 1097 if (fn) 1098 script_load(fn, 1); 1099 } 1100 1101 void gui_load_script(int arg) { 1102 DIR *d; 1103 char *path="A/CHDK/SCRIPTS"; 1104 1105 // if exists "A/CHDK/SCRIPTS" go into 1106 d=opendir(path); 1107 if (d) { 1108 closedir(d); 1109 } else { 1110 path="A"; 1111 } 1112 1113 gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, path, gui_load_script_selected); 1114 } 1115 1116 void gui_load_script_default(int arg) { 1117 script_load(conf.script_file, 0); 1118 if (conf.script_param_save) { 1119 save_params_values(1); 1120 } 1121 } 1122 #endif 1061 1123 1062 1124 //------------------------------------------------------------------- … … 1291 1353 //------------------------------------------------------------------- 1292 1354 const char* gui_alt_power_enum(int change, int arg) { 1293 static const char* modes[]={ "Never", "Alt", "Script","Always" }; 1355 // Script option is retained even if scripting is disabled, otherwise conf values will change 1356 // Equivalent to ALT 1357 static const char* modes[]={ "Never", "Alt", "Script", "Always" }; 1294 1358 gui_enum_value_change(&conf.alt_prevent_shutdown,change,sizeof(modes)/sizeof(modes[0])); 1295 1359 … … 1566 1630 return lang_str((int)gui_change_simple_enum(&conf.bad_pixel_removal,change,(const char **)modes,sizeof(modes)/sizeof(modes[0]))); 1567 1631 } 1568 1569 //-------------------------------------------------------------------1570 void gui_update_script_submenu() {1571 register int p=0, i;1572 1573 for (i=0; i<sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0]); ++p, ++i) {1574 script_submenu_items[p]=script_submenu_items_top[i];1575 }1576 for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {1577 if (script_param_order[i]) {1578 script_submenu_items[p].symbol=0x0;1579 script_submenu_items[p].text=(int)script_params[script_param_order[i]-1];1580 script_submenu_items[p].type=MENUITEM_INT;1581 script_submenu_items[p].value=&conf.ubasic_vars[script_param_order[i]-1];1582 ++p;1583 }1584 }1585 for (i=0; i<sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0]); ++p, ++i) {1586 script_submenu_items[p]=script_submenu_items_bottom[i];1587 }1588 }1589 1632 1590 1633 //------------------------------------------------------------------- … … 1874 1917 gui_draw_osd(); 1875 1918 draw_txt_string(20, 14, "<ALT>", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG)); 1919 #ifdef OPT_SCRIPTING 1876 1920 if ((mode_get()&MODE_MASK) == MODE_REC) { 1877 1921 draw_txt_string(0, 14, script_title, MAKE_COLOR(COLOR_ALT_BG, COLOR_FG)); … … 1882 1926 } 1883 1927 } 1928 #endif 1884 1929 console_draw(); 1885 1930 break; … … 2071 2116 } 2072 2117 #endif 2118 #ifdef OPT_SCRIPTING 2073 2119 } else if (kbd_is_key_clicked(KEY_SET)) { 2074 2120 gui_menu_init(&script_submenu); 2075 2121 gui_mode = GUI_MODE_MENU; 2076 2122 draw_restore(); 2123 #endif 2077 2124 } else { 2078 2125 #if !CAM_HAS_MANUAL_FOCUS && CAM_CAN_SD_OVERRIDE … … 2237 2284 conf_save_new_settings_if_changed(); 2238 2285 #endif 2239 ubasic_error = 0; 2286 #ifdef OPT_UBASIC 2287 ubasic_error = UBASIC_E_NONE; 2288 #endif 2240 2289 draw_restore(); 2241 2290 if (gui_mode == GUI_MODE_READ && !rbf_load(conf.menu_rbf_file)) … … 2565 2614 gui_draw_debug_vals_osd(); 2566 2615 2616 #ifdef OPT_UBASIC 2567 2617 if (ubasic_error){ 2568 2618 const char *msg; … … 2575 2625 draw_txt_string(0, 0, osd_buf, MAKE_COLOR(COLOR_RED, COLOR_YELLOW)); 2576 2626 } 2627 #endif 2577 2628 } 2578 2629 … … 2771 2822 gui_fselect_init(LANG_STR_FILE_BROWSER, "A", NULL); 2772 2823 } 2773 2774 //-------------------------------------------------------------------2775 static void gui_load_script_selected(const char *fn) {2776 if (fn)2777 script_load(fn, 1);2778 }2779 void gui_load_script(int arg) {2780 DIR *d;2781 char *path="A/CHDK/SCRIPTS";2782 2783 // if exists "A/CHDK/SCRIPTS" go into2784 d=opendir(path);2785 if (d) {2786 closedir(d);2787 } else {2788 path="A";2789 }2790 2791 gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, path, gui_load_script_selected);2792 }2793 2794 void gui_load_script_default(int arg) {2795 script_load(conf.script_file, 0);2796 if (conf.script_param_save) {2797 save_params_values(1);2798 }2799 }2800 2801 2824 2802 2825 //------------------------------------------------------------------- -
trunk/core/gui_draw.c
r804 r1034 5 5 #include "conf.h" 6 6 #include "font.h" 7 #include "ubasic.h"8 7 #include "gui_draw.h" 9 8 -
trunk/core/gui_menu.c
r936 r1034 4 4 #include "keyboard.h" 5 5 #include "conf.h" 6 #include "ubasic.h"7 6 #include "font.h" 8 7 #include "lang.h" -
trunk/core/kbd.c
r1032 r1034 107 107 #endif 108 108 109 #ifdef OPT_SCRIPTING 109 110 // remote autostart 110 111 void script_autostart() … … 116 117 script_start_gui( 1 ); 117 118 } 119 #endif 120 118 121 void exit_alt() 119 122 { … … 234 237 } 235 238 /*-------------------- Alex scriptless remote additions end ---------------------*/ 239 #ifdef OPT_SCRIPTING 236 240 if (kbd_is_key_pressed(KEY_SHOOT_FULL)) { 237 241 key_pressed = 100; … … 241 245 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED)); 242 246 script_end(); 243 } else if (L) { 247 } 248 #ifdef OPT_LUA 249 else if (L) { 244 250 state_kbd_script_run = 2; 245 251 lua_run_restore(); 246 252 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED)); 247 253 script_end(); 248 } else { 254 } 255 #endif 256 #ifdef OPT_UBASIC 257 else { 249 258 state_kbd_script_run = 2; 250 259 if (jump_label("restore") == 0) { … … 253 262 } 254 263 } 255 } 264 #endif 265 } 266 #endif 256 267 257 268 action_stack_process_all(); -
trunk/core/luascript.c
r1032 r1034 9 9 #include "conf.h" 10 10 #include "shot_histogram.h" 11 #include "ubasic.h"12 11 #include "stdlib.h" 13 12 #include "raw.h" … … 566 565 int pixels_step = (luaL_optnumber(L,15,6)); 567 566 int msecs_before_trigger = (luaL_optnumber(L,16,0)); 568 ubasic_set_variable(0, 0);569 567 if(md_init_motion_detector( 570 568 columns, rows, pixel_measure_mode, detection_timeout, -
trunk/core/main.c
r1022 r1034 7 7 #include "histogram.h" 8 8 #include "raw.h" 9 #include "motion_detector.h"10 9 #ifdef OPT_EDGEOVERLAY 11 10 #include "edgeoverlay.h" … … 145 144 auto_started = 0; 146 145 146 #ifdef OPT_SCRIPTING 147 147 if (conf.script_startup==1) script_autostart(); // remote autostart 148 148 if (conf.script_startup==2) { … … 151 151 script_autostart(); 152 152 } 153 #endif 153 154 154 155 while (1) { -
trunk/core/motion_detector.h
r1000 r1034 96 96 #include "../include/platform.h" 97 97 #include "../include/stdlib.h" 98 #include "../include/script.h"99 100 98 101 99 #define MOTION_DETECTOR_CELLS 1024 -
trunk/core/ptp.c
r1022 r1034 1 1 #include "camera.h" 2 2 #ifdef CAM_CHDK_PTP 3 #include "stddef.h" 3 4 #include "platform.h" 4 5 #include "stdlib.h" 5 6 #include "ptp.h" 6 #include "action_stack.h"7 #include "lua.h"8 7 #include "kbd.h" 9 8 … … 12 11 static int buf_size=0; 13 12 13 #ifdef OPT_LUA 14 14 #include "script.h" 15 #include "action_stack.h" 15 16 16 17 static lua_State *get_lua_thread(lua_State *L) … … 24 25 return Lt; 25 26 } 27 #endif 26 28 27 29 static int handle_ptp( … … 98 100 static union { 99 101 char *str; 102 #ifdef OPT_LUA 100 103 lua_State *lua_state; 104 #endif 101 105 } temp_data; 102 106 static int temp_data_kind = 0; // 0: nothing, 1: ascii string, 2: lua object … … 128 132 case PTP_CHDK_ScriptStatus: 129 133 ptp.num_param = 1; 134 // TODO script_is_running should always be defined, just ret 0 if script disabled 135 #ifdef OPT_SCRIPTING 130 136 ptp.param1 = script_is_running()?PTP_CHDK_SCRIPT_STATUS_RUN:0; 137 #else 138 ptp.param1 = 0; 139 #endif 131 140 break; 132 141 case PTP_CHDK_GetMemory: … … 185 194 if ( param2 & PTP_CHDK_TD_DOWNLOAD ) 186 195 { 187 const char *s ;188 size_t l ;196 const char *s = NULL; 197 size_t l = 0; 189 198 190 199 if ( temp_data_kind == 0 ) … … 198 207 s = temp_data.str; 199 208 l = temp_data_extra; 200 } else { // temp_data_kind == 2 209 } 210 #ifdef OPT_LUA 211 else { // temp_data_kind == 2 201 212 s = lua_tolstring(get_lua_thread(temp_data.lua_state),1,&l); 202 213 } 214 #endif 203 215 204 216 if ( !send_ptp_data(data,s,l) ) … … 212 224 { 213 225 free(temp_data.str); 214 } else if ( temp_data_kind == 2 ) 226 } 227 #ifdef OPT_LUA 228 else if ( temp_data_kind == 2 ) 215 229 { 216 230 lua_close(temp_data.lua_state); 217 231 } 232 #endif 218 233 temp_data_kind = 0; 219 234 … … 239 254 { 240 255 free(temp_data.str); 241 } else if ( temp_data_kind == 2 ) 256 } 257 #ifdef OPT_LUA 258 else if ( temp_data_kind == 2 ) 242 259 { 243 260 lua_close(temp_data.lua_state); 244 261 } 262 #endif 245 263 temp_data_kind = 0; 246 264 } … … 371 389 break; 372 390 391 #ifdef OPT_LUA 373 392 case PTP_CHDK_ExecuteScript: 374 393 { … … 451 470 break; 452 471 } 472 #endif 453 473 454 474 default: -
trunk/core/script.c
r1032 r1034 9 9 #include "console.h" 10 10 #include "action_stack.h" 11 #include "luascript.h"12 #include "lauxlib.h"13 11 #include "motion_detector.h" 14 12 #include "shot_histogram.h" … … 16 14 #include "gui_lang.h" 17 15 #include "kbd.h" 16 17 #ifdef OPT_LUA 18 #include "lauxlib.h" 19 #endif 18 20 19 21 //------------------------------------------------------------------- … … 80 82 static int script_loaded_params[SCRIPT_NUM_PARAMS]; 81 83 static long running_script_stack_name = -1; 84 85 #ifdef OPT_LUA 82 86 static int state_lua_kbd_first_call_to_resume; // AUJ 87 #endif 83 88 84 89 //------------------------------------------------------------------- … … 450 455 } 451 456 457 #ifdef OPT_LUA 452 458 static int is_lua() 453 459 { … … 461 467 && s[len-4] == '.'; 462 468 } 469 #endif 463 470 464 471 static void wait_and_end(void) … … 479 486 480 487 if (state_kbd_script_run != 3) { 488 #ifdef OPT_LUA 481 489 if( L ) { 482 490 int top; … … 506 514 } 507 515 } else 516 #endif 508 517 { 518 #ifdef OPT_UBASIC 509 519 ubasic_run(); 510 520 if (ubasic_finished()) { … … 513 523 script_end(); 514 524 } 525 #endif 515 526 } 516 527 } … … 531 542 { 532 543 action_pop(); 544 #ifdef OPT_LUA 533 545 if (L) 534 546 { … … 538 550 lua_pushnumber( Lt, md_get_result() ); 539 551 } else 552 #endif 540 553 { 554 #ifdef OPT_UBASIC 541 555 ubasic_set_md_ret(md_get_result()); 556 #endif 542 557 } 543 558 } … … 570 585 { 571 586 script_print_screen_end(); 587 #ifdef OPT_LUA 572 588 if( L ) { 573 589 lua_script_reset(); 574 } 575 else { 590 } else 591 #endif 592 { 593 #ifdef OPT_UBASIC 576 594 ubasic_end(); 595 #endif 577 596 } 578 597 md_close_motion_detector(); … … 611 630 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED)); 612 631 632 #ifdef OPT_LUA 613 633 if( is_lua() ) { 614 634 if( !lua_script_start(script_source_str) ) { … … 626 646 } 627 647 state_lua_kbd_first_call_to_resume = 1; 628 } else { // ubasic 648 } else 649 #endif 650 { // ubasic 651 #ifdef OPT_UBASIC 629 652 ubasic_init(script_source_str); 630 653 … … 632 655 ubasic_set_variable(i, conf.ubasic_vars[i]); 633 656 } 657 #endif 634 658 } 635 659 … … 641 665 } 642 666 667 #ifdef OPT_LUA 643 668 long script_start_ptp( char *script , int keep_result ) 644 669 { … … 651 676 return script_stack_start(); 652 677 } 653 678 #endif 679 680 #ifndef UBASIC_TEST 654 681 int camera_is_pressed(const char *s) 655 682 { … … 659 686 return (kbd_is_key_pressed(k)); 660 687 } else { 661 if (is_lua()) 688 #ifdef OPT_LUA 689 if (is_lua()) { 662 690 luaL_error( L, "unknown key" ); 663 else 691 } else 692 #endif 693 { 694 #ifdef OPT_UBASIC 664 695 ubasic_error = UBASIC_E_UNK_KEY; 696 #endif 697 } 665 698 } 666 699 return 0; … … 674 707 return (kbd_last_clicked == k); 675 708 } else { 676 if (is_lua()) 709 #ifdef OPT_LUA 710 if (is_lua()) { 677 711 luaL_error( L, "unknown key" ); 678 else 712 } else 713 #endif 714 { 715 #ifdef OPT_UBASIC 679 716 ubasic_error = UBASIC_E_UNK_KEY; 717 #endif 718 } 680 719 } 681 720 return 0; 682 721 } 683 722 684 723 #ifdef OPT_UBASIC 685 724 void camera_press(const char *s) 686 725 { … … 733 772 action_wait_for_click(t); 734 773 } 735 774 #endif 775 776 #endif -
trunk/include/gui.h
r993 r1034 33 33 extern enum Gui_Mode gui_get_mode(); 34 34 extern void gui_set_mode(enum Gui_Mode mode); 35 36 #ifdef OPT_SCRIPTING 35 37 extern void gui_update_script_submenu(); 38 #endif 36 39 37 40 #endif -
trunk/include/script.h
r1021 r1034 7 7 #define SCRIPT_DATA_PATH "A/CHDK/DATA/" 8 8 9 #ifdef OPT_UBASIC 9 10 #include "ubasic.h" 11 #endif 12 13 #ifdef OPT_LUA 10 14 #include "../core/luascript.h" 15 #endif 11 16 12 17 //------------------------------------------------------------------- … … 32 37 void script_end(); 33 38 long script_start_gui( int autostart ); 39 40 #ifdef OPT_LUA 34 41 long script_start_ptp( char *script , int keep_result ); 42 #endif 35 43 36 44 #endif
Note: See TracChangeset
for help on using the changeset viewer.