CHDK_DE Vorschauversion  Trunk Rev. 5272
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
usb_remote.c-Dateireferenz
#include "camera_info.h"
#include "stdlib.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 (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 (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 178 der Datei usb_remote.c.

#define KBD_CALIBRATE_TIME   100

Definiert in Zeile 183 der Datei usb_remote.c.

#define USB_BUFFER_SIZE   16

Definiert in Zeile 40 der Datei usb_remote.c.

Dokumentation der Funktionen

void clear_usb_power ( )

Definiert in Zeile 317 der Datei usb_remote.c.

318 {
319  usb_power = 0 ;
320  usb_count = 0 ;
323 }
void debug_error ( int  err_num)

Definiert in Zeile 76 der Datei usb_remote.c.

77 {
78 }
int get_usb_power ( int  mode)

Definiert in Zeile 332 der Datei usb_remote.c.

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

Definiert in Zeile 398 der Datei usb_remote.c.

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

Definiert in Zeile 187 der Datei usb_remote.c.

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

Definiert in Zeile 158 der Datei usb_remote.c.

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

Definiert in Zeile 382 der Datei usb_remote.c.

383 {
384  if (conf.remote_enable)
385  {
389  }
390  else
391  {
393  usb_remote_active = 0 ;
394  }
396 }
void usb_buffer_insert ( int  value)

Definiert in Zeile 240 der Datei usb_remote.c.

241 {
243  if ( usb_buffer_in == usb_buffer_out )
244  {
246  }
247  *usb_buffer_in = value ;
248 }
int usb_HPtimer_bad ( int  time,
int  interval 
)

Definiert in Zeile 305 der Datei usb_remote.c.

306 {
308  return (usb_HPtimer_good(time, interval));
309 }
int usb_HPtimer_good ( int  time,
int  interval 
)

Definiert in Zeile 297 der Datei usb_remote.c.

298 {
301  usb_remote_key() ;
302  return 0;
303 }
void usb_remote_key ( void  )

Definiert in Zeile 250 der Datei usb_remote.c.

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

Definiert in Zeile 218 der Datei usb_remote.c.

219 {
221  {
223  debug_led(state);
224  else
225  *(int*)camera_info.cam_remote_sync_status_led=state ? 0x46 : 0x44;
226  }
227 }

Variablen-Dokumentation

int bracketing_timeout = 0

Definiert in Zeile 34 der Datei usb_remote.c.

enum CAMERA_MODE camera_mode = CAMERA_MODE_PLAYBACK

Definiert in Zeile 52 der Datei usb_remote.c.

enum CONTROL_MODULE control_module = RMT_NONE

Definiert in Zeile 47 der Datei usb_remote.c.

enum DRIVER_STATE driver_state = SW_RESET

Definiert in Zeile 49 der Datei usb_remote.c.

enum LOGIC_MODULE_STATE logic_module_state = LM_RESET

Definiert in Zeile 50 der Datei usb_remote.c.

int logic_module_usb_count = 0
static

Definiert in Zeile 37 der Datei usb_remote.c.

int remote_mark_count

Definiert in Zeile 38 der Datei usb_remote.c.

int remote_space_count

Definiert in Zeile 38 der Datei usb_remote.c.

int rmt_state = RMT_DISABLED
static

Definiert in Zeile 380 der Datei usb_remote.c.

enum SWITCH_TYPE switch_type = SW_NONE

Definiert in Zeile 46 der Datei usb_remote.c.

int synch_delay_calib = 0
static

Definiert in Zeile 185 der Datei usb_remote.c.

int synch_delay_tick = 2800
static

Definiert in Zeile 155 der Datei usb_remote.c.

int usb_buffer[USB_BUFFER_SIZE]
static

Definiert in Zeile 41 der Datei usb_remote.c.

int* usb_buffer_in = usb_buffer
static

Definiert in Zeile 42 der Datei usb_remote.c.

int* usb_buffer_out = usb_buffer
static

Definiert in Zeile 43 der Datei usb_remote.c.

int usb_count =0
static

Definiert in Zeile 36 der Datei usb_remote.c.

void(* usb_driver[])()

Definiert in Zeile 282 der Datei usb_input.c.

int usb_HPtimer_error_count

Definiert in Zeile 295 der Datei usb_remote.c.

void(* usb_module_play[])()

Definiert in Zeile 675 der Datei usb_module.c.

void(* usb_module_shoot[])()

Definiert in Zeile 692 der Datei usb_module.c.

void(* usb_module_video[])()

Definiert in Zeile 709 der Datei usb_module.c.

int usb_power =0

Definiert in Zeile 35 der Datei usb_remote.c.

int usb_remote_active =0

Definiert in Zeile 33 der Datei usb_remote.c.

enum USB_POWER_STATE usb_state = USB_POWER_OFF

Definiert in Zeile 51 der Datei usb_remote.c.

int usb_sync_wait_flag =0

Definiert in Zeile 32 der Datei usb_remote.c.

enum VIRTUAL_REMOTE_STATE virtual_remote_state = REMOTE_RESET

Definiert in Zeile 48 der Datei usb_remote.c.