Changeset 419

Show
Ignore:
Timestamp:
02/17/07 18:56:23 (2 years ago)
Author:
anthony_rowe
Message:

demo mode

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/projects/cmucam2/cmucam2.c

    r418 r419  
    8080  int32_t command; 
    8181  int32_t val, n; 
    82   uint32_t arg_list[MAX_ARGS]
    83   bool error, poll_mode, line_mode,auto_led
     82  uint32_t arg_list[MAX_ARGS],start_time
     83  bool error, poll_mode, line_mode,auto_led,demo_mode,auto_servo_mode
    8484  cc3_track_pkt_t t_pkt; 
    8585  cc3_color_info_pkt_t s_pkt; 
     
    8888  set_cmucam2_commands (); 
    8989 
     90 
     91  cc3_system_setup (); 
     92 
     93  cc3_filesystem_init(); 
     94 
     95  cc3_uart_init (0, 
     96                 SERIAL_BAUD_RATE, 
     97                 CC3_UART_MODE_8N1, CC3_UART_BINMODE_BINARY); 
     98  val = setvbuf (stdout, NULL, _IONBF, 0); 
     99 
     100  if (!cc3_camera_init ()) { 
     101    cc3_set_led(0); 
     102    exit(1); 
     103  } 
     104 
     105  demo_mode=false; 
     106  auto_servo_mode=false; 
     107  start_time = cc3_get_current_ms (); 
     108  do  
     109  { 
     110    if(cc3_read_button()==1) 
     111    { 
     112        // Demo Mode flag 
     113        demo_mode=true; 
     114        auto_servo_mode=true; 
     115        // Debounce Switch 
     116        cc3_clr_led(0); 
     117        cc3_wait_ms(500); 
     118        break; 
     119    } 
     120 
     121  }while(cc3_get_current_ms()<(start_time+2000)); 
     122   
     123   
    90124cmucam2_start: 
    91125  auto_led= true;  
     
    101135  t_pkt.lower_bound.channel[2] = 16; 
    102136  t_pkt.upper_bound.channel[2] = 240; 
    103   cc3_system_setup (); 
    104  
    105   cc3_filesystem_init(); 
    106  
    107   cc3_uart_init (0, 
    108                  SERIAL_BAUD_RATE, 
    109                  CC3_UART_MODE_8N1, CC3_UART_BINMODE_BINARY); 
    110   val = setvbuf (stdout, NULL, _IONBF, 0); 
    111  
    112   if (!cc3_camera_init ()) { 
    113     cc3_set_led(0); 
    114     exit(1); 
    115   } 
     137   
     138  
    116139  cc3_set_resolution(CC3_RES_LOW); 
    117140 
     
    123146  cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1); 
    124147 
     148  if(demo_mode) { 
     149        // Wait for second button press as target lock 
     150        while(1) 
     151        { 
     152                cc3_set_led(0); 
     153                cc3_wait_ms(100); 
     154                cc3_clr_led(0); 
     155                cc3_wait_ms(100); 
     156                if(cc3_read_button()==1) break; 
     157        } 
     158 
     159  } 
    125160  while (true) { 
    126161    cc3_channel_t old_coi; 
     
    128163    printf (":"); 
    129164    error = false; 
    130     n = cmucam2_get_command (&command, arg_list); 
     165    if(demo_mode==true) 
     166    { 
     167            n=0; 
     168            command=TRACK_WINDOW; 
     169    } 
     170    else 
     171            n = cmucam2_get_command (&command, arg_list); 
    131172    if (n != -1) { 
    132173      switch (command) { 
     
    386427        cmucam2_track_color (&t_pkt, poll_mode, line_mode,auto_led,0); 
    387428        } 
     429        demo_mode=false; 
    388430        break; 
    389431 
     
    519561  free(row); 
    520562} 
     563 
     564 
    521565 
    522566void cmucam2_get_histogram(cc3_histogram_pkt_t *h_pkt, bool poll_mode, bool quite)