- Timestamp:
- 01/22/12 00:23:42 (4 months ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
core/gui.c (modified) (1 diff)
-
core/usb_input.c (modified) (3 diffs)
-
core/usb_module.c (modified) (7 diffs)
-
core/usb_remote.c (modified) (7 diffs)
-
core/usb_remote.h (modified) (5 diffs)
-
lib/ubasic/ubasic.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/gui.c
r1593 r1596 230 230 //------------------------------------------------------------------- 231 231 232 const char* gui_USB_switch_types[] = { "None","OnePush", "TwoPush", "CA-1" , "P Width", "P Count" };233 const char* gui_USB_control_modes[] = { "None", "Normal", "Quick", "Burst", "Bracket","Zoom", "Video" }; 232 const char* gui_USB_switch_types[] = { "None","OnePush", "TwoPush", "CA-1" }; // note : make sure # of entries less than NUM_USB_INPUT_DRV in usb_remote.c 233 const char* gui_USB_control_modes[] = { "None", "Normal", "Quick", "Burst", "Bracket","Zoom", "Video" }; // note : make sure # of entries less than NUM_USB_MODULES in usb_remote.c 234 234 235 235 -
trunk/core/usb_input.c
r1585 r1596 26 26 27 27 extern int usb_remote_active ; 28 extern int virtual_remote_pulse_count ;29 extern int virtual_remote_pulse_width ;30 28 extern int stime_stamp ; 31 29 extern int sync_counter; … … 343 341 } ; 344 342 345 /*---------------------------------------------------------------------------------------------------346 Device Driver : pulse width modulation device347 - gets the width of USB power pulses348 - does not set virtual switch states349 - hand shake mechanism with control modules is simply them clearing the report pulse width value350 - might be useful for gentles modules or some custom microcontroller device351 ---------------------------------------------------------------------------------------------------*/352 void usb_pwm_device(int usb_state)353 {354 int pw ;355 356 switch( driver_state )357 {358 case SW_RESET :359 virtual_remote_state = REMOTE_RESET ;360 driver_state = SW_IDLE ;361 break ;362 363 case SW_IDLE :364 pw = get_usb_power(2) ;365 if ( pw != 0) virtual_remote_pulse_width = pw ;366 break ;367 368 default :369 debug_error(INVALID_STATE) ;370 break ;371 }372 } ;373 374 /*---------------------------------------------------------------------------------------------------375 Device Driver : pulse counting device376 - counts USB pulses (off-on-off)377 - ignores short pulses less that 100 mSec ( CA-1 reset and half shoot pulses )378 - does not set virtual switch states379 - hand shake mechanism with control modules is simply them clearing the report pulse width value380 - might be useful for gentles modules or some custom microcontroller device381 ---------------------------------------------------------------------------------------------------*/382 void usb_pulse_count_device(int usb_state)383 {384 int pc ;385 386 switch( driver_state )387 {388 case SW_RESET :389 virtual_remote_state = REMOTE_RESET ;390 driver_state = SW_IDLE ;391 break ;392 393 case SW_IDLE :394 pc = get_usb_power(3) ;395 if ( pc != 0) virtual_remote_pulse_count = pc ;396 break ;397 398 default :399 debug_error(INVALID_STATE) ;400 break ;401 }402 403 } ;404 343 405 344 /*=================================================================================================== … … 418 357 usb_two_press_switch , 419 358 usb_ricoh_ca1_switch , 420 usb_pwm_device , 421 usb_pulse_count_device , 422 usb_null_driver , 423 usb_null_driver , 424 usb_null_driver , 425 usb_null_driver 359 usb_null_driver // <- insert new devices here - update NUM_USB_INPUT_DRV if necessary 426 360 }; -
trunk/core/usb_module.c
r1593 r1596 27 27 extern int usb_sync_wait ; 28 28 extern int usb_remote_active ; 29 extern int virtual_remote_pulse_count ;30 extern int virtual_remote_pulse_width ;31 29 extern int stime_stamp ; 32 30 extern int sync_counter; 33 31 extern int usb_sync_wait ; 32 33 extern int get_usb_power(int) ; 34 34 35 35 extern enum SWITCH_TYPE switch_type ; … … 78 78 79 79 case LM_RELEASE : 80 i = get_usb_power( 3) ;80 i = get_usb_power(PULSE_COUNT) ; 81 81 switch( i ) 82 82 { … … 469 469 470 470 case LM_RELEASE : 471 switch( virtual_remote_pulse_count)471 switch( get_usb_power(PULSE_COUNT) ) 472 472 { 473 473 case ZOOM_STEP_OUT : … … 507 507 break ; 508 508 } 509 510 virtual_remote_pulse_count = 0;511 512 509 }; 513 510 … … 737 734 usb_playback_module , // [ gWIRE] 738 735 usb_playback_module , // [ Script] 739 usb_null_module // --736 usb_null_module // <- insert new playback module here - update NUM_USB_MODULES if necessary 740 737 }; 741 738 … … 752 749 usb_shoot_module_zoom , // [ Zoom] 753 750 usb_null_module , // [ Video] 754 usb_null_module, // --751 usb_null_module, // <- insert new shoot module here - update NUM_USB_MODULES if necessary 755 752 usb_null_module, // -- 756 753 usb_null_module // -- … … 769 766 usb_null_module , // [ Zoom] 770 767 usb_video_module_normal , // [ Video] 771 usb_null_module , // --768 usb_null_module , // <- insert new video module here - update NUM_USB_MODULES if necessary 772 769 usb_null_module , // -- 773 770 usb_null_module // -- -
trunk/core/usb_remote.c
r1593 r1596 37 37 int usb_sync_wait = 0 ; 38 38 int usb_remote_active=0 ; 39 int virtual_remote_pulse_count = 0 ;40 int virtual_remote_pulse_width = 0 ;41 39 int stime_stamp = 0 ; 42 40 int usb_power=0; … … 228 226 remote_key = get_usb_bit() ; 229 227 230 if (remote_key) remote_count++ ; // track how long the USB power is on 231 else if(remote_space_count<3000) remote_space_count++ ; // track how long the USB power is off 232 233 if ( remote_space_count > 50 ) // pulse counting done if no activity for 500mSec 234 { 235 if( pulse_count > 0 ) 236 { 237 usb_count = pulse_count ; 238 pulse_count = 0 ; 239 } 240 } 241 242 if (( remote_key == 0) && (remote_count > 0) ) // 1 -> 0 transistion ? 243 { 244 if( remote_count > 10 ) pulse_count++ ; // count pulses longer than 100 msec 245 246 usb_power = remote_count; // transfer most recent pulse length to variable read by scripts 228 if(conf.remote_enable) 229 { 230 if (remote_key) remote_count++ ; // track how long the USB power is on 231 else if(remote_space_count<3000) remote_space_count++ ; // track how long the USB power is off 247 232 248 if ( ++usb_buffer_in > &usb_buffer[USB_BUFFER_SIZE-1] ) usb_buffer_in = usb_buffer ; // insert power pulse width into the buffer 249 if ( usb_buffer_in == usb_buffer_out ) 250 { 251 if ( ++usb_buffer_out > &usb_buffer[USB_BUFFER_SIZE-1] ) usb_buffer_out = usb_buffer ; 252 } 253 *usb_buffer_in = remote_count ; 254 remote_count = 0; 255 } 256 257 if (( remote_key == 1) && (remote_space_count > 0) ) // 0 -> 1 transistion ? 258 { 259 if ( ++usb_buffer_in > &usb_buffer[USB_BUFFER_SIZE-1] ) usb_buffer_in = usb_buffer ; // insert space pulse width into the buffer as a negative number 260 if ( usb_buffer_in == usb_buffer_out ) 261 { 262 if ( ++usb_buffer_out > &usb_buffer[USB_BUFFER_SIZE-1] ) usb_buffer_out = usb_buffer ; 263 } 264 *usb_buffer_in = 0-remote_space_count ; 265 remote_space_count = 0 ; 233 if ( remote_space_count > 50 ) // pulse counting done if no activity for 500mSec 234 { 235 if( pulse_count > 0 ) 236 { 237 usb_count = pulse_count ; 238 pulse_count = 0 ; 239 } 240 } 241 242 if (( remote_key == 0) && (remote_count > 0) ) // 1 -> 0 transistion ? 243 { 244 if( remote_count > 10 ) pulse_count++ ; // count pulses longer than 100 msec 245 246 usb_power = remote_count; // transfer most recent pulse length to variable read by scripts 247 248 if ( ++usb_buffer_in > &usb_buffer[USB_BUFFER_SIZE-1] ) usb_buffer_in = usb_buffer ; // insert power pulse width into the buffer 249 if ( usb_buffer_in == usb_buffer_out ) 250 { 251 if ( ++usb_buffer_out > &usb_buffer[USB_BUFFER_SIZE-1] ) usb_buffer_out = usb_buffer ; 252 } 253 *usb_buffer_in = remote_count ; 254 remote_count = 0; 255 } 256 257 if (( remote_key == 1) && (remote_space_count > 0) ) // 0 -> 1 transistion ? 258 { 259 if ( ++usb_buffer_in > &usb_buffer[USB_BUFFER_SIZE-1] ) usb_buffer_in = usb_buffer ; // insert space pulse width into the buffer as a negative number 260 if ( usb_buffer_in == usb_buffer_out ) 261 { 262 if ( ++usb_buffer_out > &usb_buffer[USB_BUFFER_SIZE-1] ) usb_buffer_out = usb_buffer ; 263 } 264 *usb_buffer_in = 0-remote_space_count ; 265 remote_space_count = 0 ; 266 } 266 267 } 267 268 } … … 280 281 switch( mode) 281 282 { 282 case 0:283 case SINGLE_PULSE : 283 284 x = usb_power; 284 285 usb_power = 0; 285 286 break ; 286 287 287 case 1:288 case USB_STATE : 288 289 x=remote_key; 289 290 break ; 290 291 291 case 2:292 case BUFFERED_PULSE : 292 293 if ( usb_buffer_out == usb_buffer_in ) 293 294 { … … 301 302 break ; 302 303 303 case 3:304 case PULSE_COUNT : 304 305 x = usb_count; 305 306 usb_count = 0; … … 346 347 else camera_mode = MODE_IS_VIDEO(m1&MODE_SHOOTING_MASK) ? CAMERA_MODE_VIDEO : CAMERA_MODE_SHOOTING ; 347 348 348 (*usb_driver[switch_type])(get_usb_power( 1)); // jump to driver state machine349 (*usb_driver[switch_type])(get_usb_power(USB_STATE)); // jump to driver state machine 349 350 350 351 switch( camera_mode ) … … 425 426 sprintf(buf,"switch=%s logic=%s sync=%s ", gui_USB_switch_types[switch_type], gui_USB_control_modes[control_module], conf.synch_enable?"yes":"no") ; 426 427 draw_string(2,32,buf,MAKE_COLOR(COLOR_YELLOW,COLOR_BLACK)); 427 sprintf(buf,"sync count=%d, pulse count=%d width=%d b=%d ", sync_counter, usb_count /*virtual_remote_pulse_count*/, virtual_remote_pulse_width,bracketing.shoot_counter);428 sprintf(buf,"sync count=%d, pulse count=%d width=%d b=%d ", sync_counter, usb_count, usb_power, bracketing.shoot_counter); 428 429 draw_string(2,64,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW)); 429 430 sprintf(buf,"physw=%d err=%d %d %d ", physw_status[0]&0x03, debug_errors[0], debug_errors[1], debug_errors[2] ); … … 447 448 if ( buff_ptr-- == usb_buffer ) buff_ptr = &usb_buffer[15] ; 448 449 } 449 draw_string(2, 112,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW));450 draw_string(2,96,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW)); 450 451 } 451 452 -
trunk/core/usb_remote.h
r1585 r1596 6 6 //#define USB_REMOTE_DEBUGGING 1 7 7 8 #define NUM_USB_INPUT_DRV 108 #define NUM_USB_INPUT_DRV 5 9 9 #define NUM_USB_MODULES 10 10 10 … … 20 20 SW_ONE_PRESS , 21 21 SW_TWO_PRESS , 22 SW_RICOH_CA1 , 23 SW_PWN 22 SW_RICOH_CA1 24 23 } ; 25 24 … … 31 30 RMT_CONTINUOUS , 32 31 RMT_ZOOM , 33 RMT_BRACKETING, 34 RMT_SCRIPT 32 RMT_BRACKETING 35 33 } ; 36 34 … … 70 68 } ; 71 69 72 enum USB_STATE { // values returned from get_usb_power( 1)70 enum USB_STATE { // values returned from get_usb_power(USB_STATE) 73 71 USB_POWER_OFF, 74 72 USB_POWER_ON … … 96 94 } ; 97 95 96 97 enum GET_USB_PWR { // input parameter for get_usb_power() 98 SINGLE_PULSE, 99 USB_STATE , 100 BUFFERED_PULSE , 101 PULSE_COUNT 102 } ; 103 98 104 // USB remote processing status 99 105 -
trunk/lib/ubasic/ubasic.c
r1593 r1596 298 298 case TOKENIZER_GET_USB_POWER: 299 299 accept(TOKENIZER_GET_USB_POWER); 300 r = get_usb_power( expr() ); 300 int usbpwr = 0 ; 301 if (tokenizer_token() != TOKENIZER_CR && 302 tokenizer_token() != TOKENIZER_ELSE ) { 303 usbpwr = expr(); 304 } 305 r = get_usb_power(usbpwr); 301 306 break; 302 307 case TOKENIZER_GET_EXP_COUNT: