CHDK_DE Vorschauversion  Trunk Rev. 5707
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
usb_remote.c-Dateireferenz
#include "camera_info.h"
#include "clock.h"
#include "modes.h"
#include "shooting.h"
#include "conf.h"
#include "action_stack.h"
#include "gui_draw.h"
#include "usb_remote.h"
#include "debug_led.h"
+ Include-Abhängigkeitsdiagramm für usb_remote.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define USB_BUFFER_SIZE   16
 
#define CALIBRATE_SYNCH_DELAY   1
 
#define KBD_CALIBRATE_TIME   100
 

Funktionen

void debug_error (__attribute__((unused)) int err_num)
 
void kbd_synch_delay (int delay_value)
 
void kbd_calibrate_synch_delay ()
 
void usb_remote_status_led (int state)
 
void usb_buffer_insert (int value)
 
void usb_remote_key (void)
 
int usb_HPtimer_good (__attribute__((unused)) int time, int interval)
 
int usb_HPtimer_bad (int time, int interval)
 
void clear_usb_power ()
 
int get_usb_power (int mode)
 
void set_usb_remote_state ()
 
int handle_usb_remote ()
 

Variablen

int usb_sync_wait_flag =0
 
int usb_remote_active =0
 
int bracketing_timeout = 0
 
int usb_power =0
 
static int usb_count =0
 
static int logic_module_usb_count = 0
 
int remote_mark_count
 
int remote_space_count
 
static int usb_buffer [USB_BUFFER_SIZE]
 
static int * usb_buffer_in = usb_buffer
 
static int * usb_buffer_out = usb_buffer
 
enum SWITCH_TYPE switch_type = SW_NONE
 
enum CONTROL_MODULE control_module = RMT_NONE
 
enum VIRTUAL_REMOTE_STATE virtual_remote_state = REMOTE_RESET
 
enum DRIVER_STATE driver_state = SW_RESET
 
enum LOGIC_MODULE_STATE logic_module_state = LM_RESET
 
enum USB_POWER_STATE usb_state = USB_POWER_OFF
 
enum CAMERA_MODE camera_mode = CAMERA_MODE_PLAYBACK
 
static int synch_delay_tick = 2800
 
static int synch_delay_calib = 0
 
int usb_HPtimer_error_count
 
void(* usb_driver [])()
 
void(* usb_module_play [])()
 
void(* usb_module_shoot [])()
 
void(* usb_module_video [])()
 
static int rmt_state = RMT_DISABLED
 

Makro-Dokumentation

#define CALIBRATE_SYNCH_DELAY   1

Definiert in Zeile 177 der Datei usb_remote.c.

#define KBD_CALIBRATE_TIME   100

Definiert in Zeile 182 der Datei usb_remote.c.

#define USB_BUFFER_SIZE   16

Definiert in Zeile 39 der Datei usb_remote.c.

Dokumentation der Funktionen

void clear_usb_power ( )

Definiert in Zeile 316 der Datei usb_remote.c.

317 {
318  usb_power = 0 ;
319  usb_count = 0 ;
322 }
void debug_error ( __attribute__((unused)) int  err_num)

Definiert in Zeile 75 der Datei usb_remote.c.

76 {
77 }
int get_usb_power ( int  mode)

Definiert in Zeile 331 der Datei usb_remote.c.

332 {
333  int x = 0;
334 
335  switch( mode)
336  {
337  case SINGLE_PULSE :
338  x = usb_power;
339  usb_power = 0;
340  break ;
341  case USB_STATE :
342  x=usb_state;
343  break ;
344  case BUFFERED_PULSE :
345  if ( usb_buffer_out != usb_buffer_in )
346  {
348  x = *usb_buffer_out ;
349  }
350  break ;
351  case PULSE_COUNT :
352  x = usb_count;
353  usb_count = 0;
354  break ;
355  case LM_PULSE_COUNT :
358  break ;
359  case HPTIMER_ERROR_COUNT :
362  break ;
363  }
364  return x;
365 }
int handle_usb_remote ( )

Definiert in Zeile 399 der Datei usb_remote.c.

400 {
401  if (conf.remote_enable)
402  {
405  else
407 
408  (*usb_driver[switch_type])(get_usb_power(USB_STATE)); // jump to driver state machine
409 
410  switch( camera_mode )
411  {
412  case CAMERA_MODE_PLAYBACK :
413  (*usb_module_play[switch_type])(); // jump to control module state machine
414  break ;
415  case CAMERA_MODE_SHOOTING :
416  (*usb_module_shoot[control_module])(); // jump to control module state machine
417  break ;
418  case CAMERA_MODE_VIDEO :
419  (*usb_module_video[control_module])(); // jump to control module state machine
420  break ;
421  default :
422  conf.remote_enable = 0 ;
423  break ;
424  }
425 
426  usb_remote_active = ((logic_module_state > 1) || (driver_state > 1) || (virtual_remote_state > 1) ) ? 1 : 0 ;
427 
428  #ifdef USB_REMOTE_RECORD
429  debug_add_rec();
430  #endif
431 
432  #ifdef USB_REMOTE_DEBUGGING
433  extern int sync_counter ;
434  extern long physw_status[3] ;
435  extern int usb_buffer[] ;
436  extern int * usb_buffer_in ;
437  extern int * usb_buffer_out ;
438  extern const char* gui_USB_switch_types[] ;
439  extern const char* gui_USB_control_modes[];
441  char buf[64] ;
442  static int debug_print = 0 ;
443  static int startup_delay = 0 ;
444  int i, buff_pos, *buff_ptr ;
445 
446  if ( startup_delay < 100 ) startup_delay++ ; // need to give things time to settle before using draw_string()
447  else
448  {
449  if ( debug_print++ > 10000 ) debug_print = 0 ;
450 
451  if ((debug_print%2) == 0)
452  {
453  switch( virtual_remote_state )
454  {
455  case REMOTE_RESET :
456  sprintf(buf,"RESET ") ;
457  break;
458  case REMOTE_RELEASE :
459  sprintf(buf,"RELEASED ") ;
460  break;
461  case REMOTE_HALF_PRESS :
462  sprintf(buf,"HALF PRESS ") ;
463  break;
464  case REMOTE_FULL_PRESS :
465  sprintf(buf,"FULL PRESS ") ;
466  break;
467  default :
468  sprintf(buf,"ERROR ") ;
469  break;
470  }
472  }
473  else
474  {
477  }
478 
479  if (((debug_print+25)%100) ==0 )
480  {
481  sprintf(buf,"switch=%d logic=%d sync=%s mode=%d ", switch_type, control_module, conf.synch_enable?"yes":"no", camera_mode) ;
483  sprintf(buf,"sync count=%d, pulse count=%d width=%d b=%d ", sync_counter, usb_count, usb_power, bracketing.shoot_counter);
485  sprintf(buf,"physw=%d err=%d %d %d ", physw_status[0]&0x03, debug_errors[0], debug_errors[1], debug_errors[2] );
487  }
488 
489  if (((debug_print+75)%100) == 0 )
490  {
491  buff_ptr = usb_buffer_in ;
492  buff_pos = 0 ;
493 
494  for ( i=0 ; i<16 ; i++ )
495  {
496  sprintf(&buf[buff_pos],"%d ", *buff_ptr) ;
497  buff_pos = strlen(buf) ;
498  if ( buff_pos > 45 )
499  {
500  buf[45] = 0 ;
501  i=17 ;
502  }
503  if ( buff_ptr-- == usb_buffer ) buff_ptr = &usb_buffer[15] ;
504  }
506  }
507  }
508  #endif
509  }
510 
511  return usb_remote_active ;
512 }
void kbd_calibrate_synch_delay ( )

Definiert in Zeile 186 der Datei usb_remote.c.

187 {
188  if (synch_delay_calib) return;
189  int t0 = get_tick_count();
191  int t = get_tick_count() - t0;
192 
194 
195  if (synch_delay_tick < 100) synch_delay_tick = 2800; /*something went wrong */
196  if (synch_delay_tick > 100000) synch_delay_tick = 2800;
197 
198  int fd;
199  char buf[64];
200  sprintf(buf, "%d %d ", synch_delay_tick, t);
201  fd = open("A/CALIB.TXT", O_WRONLY|O_CREAT, 0777);
202  if (fd>=0) {
203  write(fd, buf, strlen(buf));
204  close(fd);
205  }
206  synch_delay_calib = 1;
207 }
void kbd_synch_delay ( int  delay_value)

Definiert in Zeile 157 der Datei usb_remote.c.

158 {
159  int count1;
160 
161  for (count1=0;count1<delay_value;count1++) //wait delay_value * 0.1ms
162  {
163  asm volatile (
164  "mov r1, #0\n"
165  ".loop: \n\t"
166  "add r1, r1, #1\n\t"
167  "cmp r1, %0\n\t"
168  "blt .loop"
169  :
170  : "r" (synch_delay_tick)
171  : "r1" );
172 
173  }
174 }
void set_usb_remote_state ( )

Definiert in Zeile 381 der Datei usb_remote.c.

382 {
383  if (conf.remote_enable)
384  {
388  }
389  else
390  {
392  usb_remote_active = 0 ;
393  }
397 }
void usb_buffer_insert ( int  value)

Definiert in Zeile 239 der Datei usb_remote.c.

240 {
242  if ( usb_buffer_in == usb_buffer_out )
243  {
245  }
246  *usb_buffer_in = value ;
247 }
int usb_HPtimer_bad ( int  time,
int  interval 
)

Definiert in Zeile 304 der Datei usb_remote.c.

305 {
307  return (usb_HPtimer_good(time, interval));
308 }
int usb_HPtimer_good ( __attribute__((unused)) int  time,
int  interval 
)

Definiert in Zeile 296 der Datei usb_remote.c.

297 {
300  usb_remote_key() ;
301  return 0;
302 }
void usb_remote_key ( void  )

Definiert in Zeile 249 der Datei usb_remote.c.

250 {
251  static int pulse_count=0 ;
252 
254 
255  if(conf.remote_enable)
256  {
257  if (usb_state)
258  { // USB power is ON
259  if (remote_mark_count<30000) remote_mark_count++ ; // track how long the USB power is ON
260  if (remote_space_count != 0) // is this the 0 -> 1 transistion?
261  { //
262  usb_buffer_insert(remote_space_count); // insert space length into buffer
263  remote_space_count = 0 ; // reset the counter
264  }
265  }
266  else
267  { // USB power if OFF
268  if(remote_space_count>-30000) remote_space_count-- ; // track how long the USB power is OFF (note space counts are negative)
269  if (remote_mark_count != 0) // is this the 1 -> 0 transistion?
270  { //
271  pulse_count++ ; // count pulses transistions
272  usb_power = remote_mark_count; // transfer most recent pulse length to variable read by scripts
273  usb_buffer_insert(remote_mark_count); // insert pulse length into buffer
274  remote_mark_count = 0; // reset the counter
275  camera_info.state.kbd_last_clicked = 0xFF; // flag the remote key as the last one pressed (for scripts)
276  camera_info.state.kbd_last_clicked_time = get_tick_count(); // store key release time too
277  } //
278  if ((remote_space_count < -50) && (pulse_count > 0)) // pulse counting done if no activity for 50 timer periods
279  {
280  usb_count = pulse_count ;
281  logic_module_usb_count = pulse_count ;
282  pulse_count = 0 ;
283  }
284  }
285  }
286 }
void usb_remote_status_led ( int  state)

Definiert in Zeile 217 der Datei usb_remote.c.

218 {
220  {
222  debug_led(state);
223  else
224  *(int*)camera_info.cam_remote_sync_status_led=state ? 0x46 : 0x44;
225  }
226 }

Variablen-Dokumentation

int bracketing_timeout = 0

Definiert in Zeile 33 der Datei usb_remote.c.

enum CAMERA_MODE camera_mode = CAMERA_MODE_PLAYBACK

Definiert in Zeile 51 der Datei usb_remote.c.

enum CONTROL_MODULE control_module = RMT_NONE

Definiert in Zeile 46 der Datei usb_remote.c.

enum DRIVER_STATE driver_state = SW_RESET

Definiert in Zeile 48 der Datei usb_remote.c.

enum LOGIC_MODULE_STATE logic_module_state = LM_RESET

Definiert in Zeile 49 der Datei usb_remote.c.

int logic_module_usb_count = 0
static

Definiert in Zeile 36 der Datei usb_remote.c.

int remote_mark_count

Definiert in Zeile 37 der Datei usb_remote.c.

int remote_space_count

Definiert in Zeile 37 der Datei usb_remote.c.

int rmt_state = RMT_DISABLED
static

Definiert in Zeile 379 der Datei usb_remote.c.

enum SWITCH_TYPE switch_type = SW_NONE

Definiert in Zeile 45 der Datei usb_remote.c.

int synch_delay_calib = 0
static

Definiert in Zeile 184 der Datei usb_remote.c.

int synch_delay_tick = 2800
static

Definiert in Zeile 154 der Datei usb_remote.c.

int usb_buffer[USB_BUFFER_SIZE]
static

Definiert in Zeile 40 der Datei usb_remote.c.

int* usb_buffer_in = usb_buffer
static

Definiert in Zeile 41 der Datei usb_remote.c.

int* usb_buffer_out = usb_buffer
static

Definiert in Zeile 42 der Datei usb_remote.c.

int usb_count =0
static

Definiert in Zeile 35 der Datei usb_remote.c.

void(* usb_driver[])()

Definiert in Zeile 281 der Datei usb_input.c.

int usb_HPtimer_error_count

Definiert in Zeile 294 der Datei usb_remote.c.

void(* usb_module_play[])()

Definiert in Zeile 674 der Datei usb_module.c.

void(* usb_module_shoot[])()

Definiert in Zeile 691 der Datei usb_module.c.

void(* usb_module_video[])()

Definiert in Zeile 708 der Datei usb_module.c.

int usb_power =0

Definiert in Zeile 34 der Datei usb_remote.c.

int usb_remote_active =0

Definiert in Zeile 32 der Datei usb_remote.c.

enum USB_POWER_STATE usb_state = USB_POWER_OFF

Definiert in Zeile 50 der Datei usb_remote.c.

int usb_sync_wait_flag =0

Definiert in Zeile 31 der Datei usb_remote.c.

enum VIRTUAL_REMOTE_STATE virtual_remote_state = REMOTE_RESET

Definiert in Zeile 47 der Datei usb_remote.c.