- Timestamp:
- 01/04/11 05:09:10 (2 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
-
core/gui.c (modified) (1 diff)
-
core/kbd.c (modified) (9 diffs)
-
core/kbd.h (modified) (1 diff)
-
core/luascript.c (modified) (5 diffs)
-
core/luascript.h (modified) (1 diff)
-
core/motion_detector.c (modified) (3 diffs)
-
core/ptp.c (modified) (4 diffs)
-
core/script.c (modified) (3 diffs)
-
include/script.h (modified) (2 diffs)
-
lib/ubasic/camera_functions.c (modified) (2 diffs)
-
lib/ubasic/camera_functions.h (modified) (1 diff)
-
lib/ubasic/ubasic.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/gui.c
r1008 r1020 5 5 #include "conf.h" 6 6 #include "camera.h" 7 #include "ubasic.h"8 7 #include "font.h" 9 8 #include "lang.h" -
trunk/core/kbd.c
r1017 r1020 7 7 #include "action_stack.h" 8 8 #include "camera.h" 9 #include "histogram.h" 10 #include "gui_lang.h" 11 #include "console.h" 9 12 #include "lang.h" 10 #include "ubasic.h"11 #include "histogram.h"12 #include "script.h"13 13 #include "gui_lang.h" 14 #include "motion_detector.h" 15 #include "console.h" 16 #include "lua.h" 17 #include "lualib.h" 18 #include "lauxlib.h" 19 #include "luascript.h" 20 #include "../lib/lua/lstate.h" // for L->nCcalls, baseCcalls 21 #include "shot_histogram.h" 22 23 static int script_action_stack(long p); 24 14 15 long kbd_last_clicked; 16 int state_kbd_script_run; 17 int kbd_blocked; 18 static long delay_target_ticks; 25 19 static int soft_half_press = 0; 26 static int kbd_blocked;27 20 static int key_pressed; 28 int state_kbd_script_run;29 int state_lua_kbd_first_call_to_resume; // AUJ30 static long delay_target_ticks;31 static long running_script_stack_name = -1;32 long kbd_last_clicked;33 34 21 35 22 // ------ add by Masuji SUTO (start) -------------- … … 120 107 #endif 121 108 122 void md_kbd_sched_immediate_shoot(int no_release) 123 { 124 action_pop();// REMOVE MD ITEM 125 126 // stack operations are reversed! 127 if (!no_release) // only release shutter if allowed 128 { 129 action_push_release(KEY_SHOOT_FULL); 130 action_push_delay(20); 131 } 132 action_push(AS_MOTION_DETECTOR); // it will removed right after exit from this function 133 kbd_key_press(KEY_SHOOT_FULL); // not a stack operation... pressing right now 134 } 135 136 static lua_State* L, *Lt; 137 static int lua_keep_result; 138 139 static int is_lua() 140 { 141 int len; 142 char const* s; 143 s = conf.script_file; 144 len = strlen( s ); 145 return len >= 4 && ( s[len-1] == 'a' || s[len-1] == 'A' ) 146 && ( s[len-2] == 'u' || s[len-2] == 'U' ) 147 && ( s[len-3] == 'l' || s[len-3] == 'L' ) 148 && s[len-4] == '.'; 149 } 150 151 static void lua_count_hook(lua_State *L, lua_Debug *ar) 152 { 153 if( L->nCcalls <= L->baseCcalls ) 154 lua_yield( L, 0 ); 155 } 156 157 void lua_script_reset() 158 { 159 if ( !lua_keep_result ) 160 { 161 lua_close( L ); 162 L = 0; 163 } 164 Lt = 0; 165 } 166 167 static int lua_script_start( char const* script ) 168 { 169 lua_keep_result = 0; 170 L = lua_open(); 171 luaL_openlibs( L ); 172 register_lua_funcs( L ); 173 174 Lt = lua_newthread( L ); 175 lua_setfield( L, LUA_REGISTRYINDEX, "Lt" ); 176 if( luaL_loadstring( Lt, script ) != 0 ) { 177 script_console_add_line( lua_tostring( Lt, -1 ) ); 178 lua_script_reset(); 179 return 0; 180 } 181 lua_sethook(Lt, lua_count_hook, LUA_MASKCOUNT, 1000 ); 182 return 1; 183 } 184 185 int script_is_running() 186 { 187 return !action_stack_is_finished(running_script_stack_name); 188 } 189 190 static long script_stack_start() 191 { 192 running_script_stack_name = action_stack_create(&script_action_stack, AS_SCRIPT_RUN); 193 return running_script_stack_name; 194 } 195 196 long script_start_ptp( char *script , int keep_result ) 197 { 198 lua_script_start(script); 199 lua_keep_result = keep_result; 200 state_lua_kbd_first_call_to_resume = 1; 201 state_kbd_script_run = 1; 202 kbd_blocked = 1; 203 auto_started = 0; 204 return script_stack_start(); 205 } 206 207 void *lua_get_result() 208 { 209 lua_State* r = L; 210 L = 0; 211 return r; 212 } 213 214 215 static void wait_and_end(void) 216 { 217 script_console_add_line("PRESS SHUTTER TO CLOSE"); 218 219 // We're not running any more, but we have scheduled stuff that 220 // needs to finish. So keep the script marked as running, but don't 221 // call any more scripting functions. 222 state_kbd_script_run = 3; 223 } 224 225 long script_start_gui( int autostart ) 226 { 227 int i; 228 229 shot_histogram_set(0); 230 if (autostart) 231 auto_started = 1; 232 else 233 auto_started = 0; 234 235 kbd_last_clicked = 0; 236 237 /*if (!autostart)*/ kbd_key_release_all(); 238 239 console_clear(); 240 script_print_screen_init(); 241 242 if (conf.script_param_save) { 243 save_params_values(0); 244 } 245 if( autostart ) 246 script_console_add_line("***Autostart***"); 247 else 248 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED)); 249 250 if( is_lua() ) { 251 if( !lua_script_start(script_source_str) ) { 252 script_print_screen_end(); 253 wait_and_end(); 254 return -1; 255 } 256 for (i=0; i<SCRIPT_NUM_PARAMS; ++i) { 257 if( script_params[i][0] ) { 258 char var = 'a'+i; 259 lua_pushlstring( L, &var, 1 ); 260 lua_pushnumber( L, conf.ubasic_vars[i] ); 261 lua_settable( L, LUA_GLOBALSINDEX ); 262 } 263 } 264 state_lua_kbd_first_call_to_resume = 1; 265 } else { // ubasic 266 ubasic_init(script_source_str); 267 268 for (i=0; i<SCRIPT_NUM_PARAMS; ++i) { 269 ubasic_set_variable(i, conf.ubasic_vars[i]); 270 } 271 } 272 273 state_kbd_script_run = 1; 274 275 conf_update_prevent_shutdown(); 276 277 return script_stack_start(); 278 } 279 280 void script_end() 281 { 282 script_print_screen_end(); 283 if( L ) { 284 lua_script_reset(); 285 } 286 else { 287 ubasic_end(); 288 } 289 md_close_motion_detector(); 290 shot_histogram_set(0); 291 kbd_key_release_all(); 292 state_kbd_script_run = 0; 293 294 conf_update_prevent_shutdown(); 295 296 vid_bitmap_refresh(); 297 } 298 299 static void process_script() 300 { // Note: This function is called from an action stack for AS_SCRIPT_RUN. 301 302 long t; 303 int Lres; 304 305 if (state_kbd_script_run != 3) { 306 if( L ) { 307 int top; 308 if (state_lua_kbd_first_call_to_resume) { 309 state_lua_kbd_first_call_to_resume = 0; 310 top = 0; 311 } else { 312 top = lua_gettop(Lt); 313 } 314 Lres = lua_resume( Lt, top ); 315 316 if (Lres != LUA_YIELD && Lres != 0) { 317 script_console_add_line( lua_tostring( Lt, -1 ) ); 318 if(conf.debug_lua_restart_on_error){ 319 lua_script_reset(); 320 script_start_gui(0); 321 } else { 322 wait_and_end(); 323 } 324 return; 325 } 326 327 if (Lres != LUA_YIELD) { 328 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); 329 action_pop(); 330 script_end(); 331 } 332 } else 333 { 334 ubasic_run(); 335 if (ubasic_finished()) { 336 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); 337 action_pop(); 338 script_end(); 339 } 340 } 341 } 342 } 343 344 static int script_action_stack(long p) 345 { 346 // process stack operations 347 switch (p) { 348 case AS_SCRIPT_RUN: 349 if (state_kbd_script_run) 350 process_script(); 351 else 352 action_pop(); 353 break; 354 case AS_MOTION_DETECTOR: 355 if(md_detect_motion()==0) 356 { 357 action_pop(); 358 if (L) 359 { 360 // We need to recover the motion detector's 361 // result and push 362 // it onto the thread's stack. 363 lua_pushnumber( Lt, md_get_result() ); 364 } else 365 { 366 ubasic_set_md_ret(md_get_result()); 367 } 368 } 369 break; 370 default: 371 if (!action_stack_standard(p) && !state_kbd_script_run) 372 { 373 /*finished();*/ 374 action_pop(); 375 script_end(); 376 } 377 break; 378 } 379 380 return 1; 381 } 382 383 void ubasic_camera_press(const char *s) 109 void camera_press(const char *s) 384 110 { 385 111 long k = keyid_by_name(s); … … 391 117 } 392 118 393 void ubasic_camera_release(const char *s)119 void camera_release(const char *s) 394 120 { 395 121 long k = keyid_by_name(s); … … 401 127 } 402 128 403 void ubasic_camera_click(const char *s)129 void camera_click(const char *s) 404 130 { 405 131 long k = keyid_by_name(s); … … 411 137 } 412 138 413 void ubasic_camera_wait_click(int timeout)139 void camera_wait_click(int timeout) 414 140 { 415 141 action_push(timeout); … … 417 143 } 418 144 419 int ubasic_camera_is_pressed(const char *s)145 int camera_is_pressed(const char *s) 420 146 { 421 147 long k = keyid_by_name(s); … … 429 155 } 430 156 431 int ubasic_camera_is_clicked(const char *s)157 int camera_is_clicked(const char *s) 432 158 { 433 159 long k = keyid_by_name(s); … … 441 167 } 442 168 443 void ubasic_camera_sleep(long v)169 void camera_sleep(long v) 444 170 { 445 171 action_push_delay(v); 446 172 } 447 173 448 void ubasic_camera_shoot()174 void camera_shoot() 449 175 { 450 176 action_push(AS_SHOOT); … … 1324 1050 } 1325 1051 1052 void kbd_set_block(int bEnableBlock) { 1053 kbd_blocked = bEnableBlock ? 1 : 0; 1054 } 1055 1326 1056 long kbd_use_up_down_left_right_as_fast_switch() { 1327 1057 static long key_pressed = 0; // ??? static masking a global -
trunk/core/kbd.h
r1000 r1020 4 4 int keyid_by_name (const char *n); 5 5 int script_is_running(); 6 6 void kbd_set_block(int bEnableBlock); 7 7 extern long kbd_last_clicked; 8 8 -
trunk/core/luascript.c
r1014 r1020 7 7 #include "lualib.h" 8 8 #include "lauxlib.h" 9 #include " ../include/conf.h"9 #include "conf.h" 10 10 #include "shot_histogram.h" 11 11 #include "ubasic.h" … … 16 16 #include "console.h" 17 17 #include "action_stack.h" 18 19 #include "../lib/lua/lstate.h" // for L->nCcalls, baseCcalls 20 21 lua_State* L; 22 lua_State* Lt; 23 int lua_keep_result; 24 25 void *lua_consume_result() 26 { 27 lua_State* r = L; 28 L = 0; 29 return r; 30 } 31 32 void lua_script_reset() 33 { 34 if ( !lua_keep_result ) 35 { 36 lua_close( L ); 37 L = 0; 38 } 39 Lt = 0; 40 } 41 42 static void lua_count_hook(lua_State *L, lua_Debug *ar) 43 { 44 if( L->nCcalls <= L->baseCcalls ) 45 lua_yield( L, 0 ); 46 } 47 48 int lua_script_start( char const* script ) 49 { 50 lua_keep_result = 0; 51 L = lua_open(); 52 luaL_openlibs( L ); 53 register_lua_funcs( L ); 54 55 Lt = lua_newthread( L ); 56 lua_setfield( L, LUA_REGISTRYINDEX, "Lt" ); 57 if( luaL_loadstring( Lt, script ) != 0 ) { 58 script_console_add_line( lua_tostring( Lt, -1 ) ); 59 lua_script_reset(); 60 return 0; 61 } 62 lua_sethook(Lt, lua_count_hook, LUA_MASKCOUNT, 1000 ); 63 return 1; 64 } 18 65 19 66 #ifdef OPT_CURVES … … 452 499 { 453 500 int timeout = luaL_optnumber( L, 1, 0 ); 454 ubasic_camera_wait_click(timeout);501 camera_wait_click(timeout); 455 502 return lua_yield( L, 0 ); 456 503 } … … 458 505 static int luaCB_is_pressed( lua_State* L ) 459 506 { 460 lua_pushboolean( L, ubasic_camera_is_pressed(luaL_checkstring( L, 1 )));507 lua_pushboolean( L, camera_is_pressed(luaL_checkstring( L, 1 ))); 461 508 return 1; 462 509 } … … 464 511 static int luaCB_is_key( lua_State* L ) 465 512 { 466 lua_pushboolean( L, ubasic_camera_is_clicked(luaL_checkstring( L, 1 )));513 lua_pushboolean( L, camera_is_clicked(luaL_checkstring( L, 1 ))); 467 514 return 1; 468 515 } -
trunk/core/luascript.h
r515 r1020 4 4 #include "lua.h" 5 5 6 void *lua_consume_result(); 7 void lua_script_reset(); 8 int lua_script_start( char const* script ); 6 9 extern void register_lua_funcs( lua_State* L ); 7 10 11 extern lua_State* L; 12 extern lua_State* Lt; 13 extern int lua_keep_result; 14 8 15 #endif -
trunk/core/motion_detector.c
r1017 r1020 32 32 #include "action_stack.h" 33 33 #include "console.h" 34 #include "keyboard.h" 34 35 35 36 #include "gui.h" … … 38 39 39 40 #define MD_XY2IDX(x,y) ((y)*motion_detector->columns+x) 40 41 void md_kbd_sched_immediate_shoot(int no_release);42 43 41 44 42 enum { … … 115 113 static struct motion_detector_s *motion_detector=NULL; 116 114 117 118 //motion_detector->curr=NULL; 119 120 115 static void md_kbd_sched_immediate_shoot(int no_release) 116 { 117 action_pop();// REMOVE MD ITEM 118 119 // stack operations are reversed! 120 if (!no_release) // only release shutter if allowed 121 { 122 action_push_release(KEY_SHOOT_FULL); 123 action_push_delay(20); 124 } 125 action_push(AS_MOTION_DETECTOR); // it will removed right after exit from this function 126 kbd_key_press(KEY_SHOOT_FULL); // not a stack operation... pressing right now 127 } 121 128 122 129 static int clip(int v) { -
trunk/core/ptp.c
r1005 r1020 4 4 #include "stdlib.h" 5 5 #include "ptp.h" 6 #include "script.h"7 6 #include "action_stack.h" 8 7 #include "lua.h" … … 10 9 11 10 #define BUF_SIZE 0x20000 // XXX what's a good camera-independent value? 11 12 #include "script.h" 13 14 static lua_State *get_lua_thread(lua_State *L) 15 { 16 lua_State *Lt; 17 18 lua_getfield(L,LUA_REGISTRYINDEX,"Lt"); 19 Lt = lua_tothread(L,-1); 20 lua_pop(L,1); 21 22 return Lt; 23 } 12 24 13 25 static int handle_ptp( … … 76 88 77 89 return 1; 78 }79 80 static lua_State *get_lua_thread(lua_State *L)81 {82 lua_State *Lt;83 84 lua_getfield(L,LUA_REGISTRYINDEX,"Lt");85 Lt = lua_tothread(L,-1);86 lua_pop(L,1);87 88 return Lt;89 90 } 90 91 … … 401 402 { 402 403 lua_State *Lt; 403 temp_data.lua_state = lua_ get_result();404 temp_data.lua_state = lua_consume_result(); 404 405 Lt = get_lua_thread(temp_data.lua_state); 405 406 temp_data_kind = 2; -
trunk/core/script.c
r979 r1020 8 8 #include "script.h" 9 9 #include "console.h" 10 #include "action_stack.h" 11 #include "luascript.h" 12 #include "motion_detector.h" 13 #include "shot_histogram.h" 14 #include "lang.h" 15 #include "gui_lang.h" 16 #include "kbd.h" 10 17 11 18 //------------------------------------------------------------------- … … 71 78 static char script_params_update[SCRIPT_NUM_PARAMS]; 72 79 static int script_loaded_params[SCRIPT_NUM_PARAMS]; 80 static long running_script_stack_name = -1; 81 static int state_lua_kbd_first_call_to_resume; // AUJ 73 82 74 83 //------------------------------------------------------------------- … … 439 448 } 440 449 } 450 451 static int is_lua() 452 { 453 int len; 454 char const* s; 455 s = conf.script_file; 456 len = strlen( s ); 457 return len >= 4 && ( s[len-1] == 'a' || s[len-1] == 'A' ) 458 && ( s[len-2] == 'u' || s[len-2] == 'U' ) 459 && ( s[len-3] == 'l' || s[len-3] == 'L' ) 460 && s[len-4] == '.'; 461 } 462 463 static void wait_and_end(void) 464 { 465 script_console_add_line("PRESS SHUTTER TO CLOSE"); 466 467 // We're not running any more, but we have scheduled stuff that 468 // needs to finish. So keep the script marked as running, but don't 469 // call any more scripting functions. 470 state_kbd_script_run = 3; 471 } 472 473 static void process_script() 474 { // Note: This function is called from an action stack for AS_SCRIPT_RUN. 475 476 long t; 477 int Lres; 478 479 if (state_kbd_script_run != 3) { 480 if( L ) { 481 int top; 482 if (state_lua_kbd_first_call_to_resume) { 483 state_lua_kbd_first_call_to_resume = 0; 484 top = 0; 485 } else { 486 top = lua_gettop(Lt); 487 } 488 Lres = lua_resume( Lt, top ); 489 490 if (Lres != LUA_YIELD && Lres != 0) { 491 script_console_add_line( lua_tostring( Lt, -1 ) ); 492 if(conf.debug_lua_restart_on_error){ 493 lua_script_reset(); 494 script_start_gui(0); 495 } else { 496 wait_and_end(); 497 } 498 return; 499 } 500 501 if (Lres != LUA_YIELD) { 502 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); 503 action_pop(); 504 script_end(); 505 } 506 } else 507 { 508 ubasic_run(); 509 if (ubasic_finished()) { 510 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_FINISHED)); 511 action_pop(); 512 script_end(); 513 } 514 } 515 } 516 } 517 518 static int script_action_stack(long p) 519 { 520 // process stack operations 521 switch (p) { 522 case AS_SCRIPT_RUN: 523 if (state_kbd_script_run) 524 process_script(); 525 else 526 action_pop(); 527 break; 528 case AS_MOTION_DETECTOR: 529 if(md_detect_motion()==0) 530 { 531 action_pop(); 532 if (L) 533 { 534 // We need to recover the motion detector's 535 // result and push 536 // it onto the thread's stack. 537 lua_pushnumber( Lt, md_get_result() ); 538 } else 539 { 540 ubasic_set_md_ret(md_get_result()); 541 } 542 } 543 break; 544 default: 545 if (!action_stack_standard(p) && !state_kbd_script_run) 546 { 547 /*finished();*/ 548 action_pop(); 549 script_end(); 550 } 551 break; 552 } 553 554 return 1; 555 } 556 557 long script_stack_start() 558 { 559 running_script_stack_name = action_stack_create(&script_action_stack, AS_SCRIPT_RUN); 560 return running_script_stack_name; 561 } 562 563 int script_is_running() 564 { 565 return !action_stack_is_finished(running_script_stack_name); 566 } 567 568 void script_end() 569 { 570 script_print_screen_end(); 571 if( L ) { 572 lua_script_reset(); 573 } 574 else { 575 ubasic_end(); 576 } 577 md_close_motion_detector(); 578 shot_histogram_set(0); 579 kbd_key_release_all(); 580 state_kbd_script_run = 0; 581 582 conf_update_prevent_shutdown(); 583 584 vid_bitmap_refresh(); 585 } 586 587 long script_start_gui( int autostart ) 588 { 589 int i; 590 591 shot_histogram_set(0); 592 if (autostart) 593 auto_started = 1; 594 else 595 auto_started = 0; 596 597 kbd_last_clicked = 0; 598 599 /*if (!autostart)*/ kbd_key_release_all(); 600 601 console_clear(); 602 script_print_screen_init(); 603 604 if (conf.script_param_save) { 605 save_params_values(0); 606 } 607 if( autostart ) 608 script_console_add_line("***Autostart***"); 609 else 610 script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED)); 611 612 if( is_lua() ) { 613 if( !lua_script_start(script_source_str) ) { 614 script_print_screen_end(); 615 wait_and_end(); 616 return -1; 617 } 618 for (i=0; i<SCRIPT_NUM_PARAMS; ++i) { 619 if( script_params[i][0] ) { 620 char var = 'a'+i; 621 lua_pushlstring( L, &var, 1 ); 622 lua_pushnumber( L, conf.ubasic_vars[i] ); 623 lua_settable( L, LUA_GLOBALSINDEX ); 624 } 625 } 626 state_lua_kbd_first_call_to_resume = 1; 627 } else { // ubasic 628 ubasic_init(script_source_str); 629 630 for (i=0; i<SCRIPT_NUM_PARAMS; ++i) { 631 ubasic_set_variable(i, conf.ubasic_vars[i]); 632 } 633 } 634 635 state_kbd_script_run = 1; 636 637 conf_update_prevent_shutdown(); 638 639 return script_stack_start(); 640 } 641 642 long script_start_ptp( char *script , int keep_result ) 643 { 644 lua_script_start(script); 645 lua_keep_result = keep_result; 646 state_lua_kbd_first_call_to_resume = 1; 647 state_kbd_script_run = 1; 648 kbd_set_block(1); 649 auto_started = 0; 650 return script_stack_start(); 651 } 652 -
trunk/include/script.h
r1000 r1020 6 6 #define SCRIPT_NUM_PARAMS 26 7 7 #define SCRIPT_DATA_PATH "A/CHDK/DATA/" 8 9 #include "ubasic.h" 10 #include "../core/luascript.h" 11 #include "lualib.h" 12 #include "lauxlib.h" 8 13 9 14 //------------------------------------------------------------------- … … 25 30 26 31 extern long script_start_ptp(char *script, int keep_result); 27 extern void *lua_get_result(); 32 long script_stack_start(); 33 int script_is_running(); 34 void script_end(); 35 long script_start_gui( int autostart ); 36 long script_start_ptp( char *script , int keep_result ); 37 28 38 #endif -
trunk/lib/ubasic/camera_functions.c
r981 r1020 10 10 #define MODE_REC 0x0100 11 11 12 void ubasic_camera_press(const char *s)12 void camera_press(const char *s) 13 13 { 14 14 printf("*** button press '%s' ***\n",s); 15 15 } 16 16 17 void ubasic_camera_release(const char *s)17 void camera_release(const char *s) 18 18 { 19 19 printf("*** button release '%s' ***\n",s); 20 20 } 21 21 22 void ubasic_camera_click(const char *s)22 void camera_click(const char *s) 23 23 { 24 24 printf("*** button click '%s' ***\n",s); 25 25 } 26 26 27 void ubasic_camera_sleep(int v)27 void camera_sleep(int v) 28 28 { 29 29 printf("*** sleep %d ***\n",v); 30 30 } 31 31 32 void ubasic_camera_shoot()32 void camera_shoot() 33 33 { 34 34 printf("*** shoot ***\n"); 35 35 } 36 36 37 void ubasic_camera_wait_click(int t)37 void camera_wait_click(int t) 38 38 { 39 39 printf("*** wait_click %d ***\n", t); 40 40 } 41 41 42 int ubasic_camera_is_clicked(const char *s)42 int camera_is_clicked(const char *s) 43 43 { 44 44 printf("*** is_key '%s' ***\n", s); … … 441 441 442 442 443 int ubasic_camera_is_pressed(const char *v)444 { 445 printf("*** ubasic_camera_is_pressed %s ***\n", v);443 int camera_is_pressed(const char *v) 444 { 445 printf("*** camera_is_pressed %s ***\n", v); 446 446 return 0; 447 447 } -
trunk/lib/ubasic/camera_functions.h
r977 r1020 1 1 2 void ubasic_camera_press(const char *s);3 void ubasic_camera_release(const char *s);4 void ubasic_camera_wait_click(int timeout);5 int ubasic_camera_is_pressed(const char *s);6 int ubasic_camera_is_clicked(const char *s);7 void ubasic_camera_click(const char *s);8 void ubasic_camera_sleep(long v);9 void ubasic_camera_shoot();2 void camera_press(const char *s); 3 void camera_release(const char *s); 4 void camera_wait_click(int timeout); 5 int camera_is_pressed(const char *s); 6 int camera_is_clicked(const char *s); 7 void camera_click(const char *s); 8 void camera_sleep(long v); 9 void camera_shoot(); 10 10 int md_detect_motion(void); 11 11 int md_get_cell_diff(int column, int row); -
trunk/lib/ubasic/ubasic.c
r991 r1020 254 254 tokenizer_string(string, sizeof(string)); 255 255 tokenizer_next(); 256 r = ubasic_camera_is_clicked(string);256 r = camera_is_clicked(string); 257 257 break; 258 258 case TOKENIZER_SCRIPT_AUTOSTARTED: … … 280 280 tokenizer_string(string, sizeof(string)); 281 281 tokenizer_next(); 282 r = ubasic_camera_is_pressed(string);282 r = camera_is_pressed(string); 283 283 break; 284 284 case TOKENIZER_RANDOM: … … 287 287 int max = expr(); 288 288 srand((int)shooting_get_bv96()+(unsigned short)stat_get_vbatt()+get_tick_count()); 289 ubasic_camera_sleep(rand()%10);289 camera_sleep(rand()%10); 290 290 r = min + rand()%(max-min+1); 291 291 break; … … 1424 1424 accept(TOKENIZER_CLICK); 1425 1425 tokenizer_string(string, sizeof(string)); 1426 ubasic_camera_click(string);1426 camera_click(string); 1427 1427 tokenizer_next(); 1428 1428 DEBUG_PRINTF("End of click\n"); … … 1435 1435 accept(TOKENIZER_PRESS); 1436 1436 tokenizer_string(string, sizeof(string)); 1437 ubasic_camera_press(string);1437 camera_press(string); 1438 1438 tokenizer_next(); 1439 1439 DEBUG_PRINTF("End of press\n"); … … 1446 1446 accept(TOKENIZER_RELEASE); 1447 1447 tokenizer_string(string, sizeof(string)); 1448 ubasic_camera_release(string);1448 camera_release(string); 1449 1449 tokenizer_next(); 1450 1450 DEBUG_PRINTF("End of release\n"); … … 1458 1458 accept(TOKENIZER_SLEEP); 1459 1459 val = expr(); 1460 ubasic_camera_sleep(val);1460 camera_sleep(val); 1461 1461 DEBUG_PRINTF("End of sleep\n"); 1462 1462 accept_cr(); … … 1467 1467 { 1468 1468 accept(TOKENIZER_SHOOT); 1469 ubasic_camera_shoot();1469 camera_shoot(); 1470 1470 DEBUG_PRINTF("End of shoot\n"); 1471 1471 accept_cr(); … … 2115 2115 timeout = expr(); 2116 2116 } 2117 ubasic_camera_wait_click(timeout);2117 camera_wait_click(timeout); 2118 2118 accept_cr(); 2119 2119 } … … 2127 2127 tokenizer_string(string, sizeof(string)); 2128 2128 tokenizer_next(); 2129 ubasic_set_variable(var, ubasic_camera_is_clicked(string));2129 ubasic_set_variable(var, camera_is_clicked(string)); 2130 2130 DEBUG_PRINTF("End of is_key\n"); 2131 2131 accept_cr();
Note: See TracChangeset
for help on using the changeset viewer.