Changeset 455

Show
Ignore:
Timestamp:
02/18/07 21:52:39 (2 years ago)
Author:
goodea
Message:

rename pixbuf_set things to pixbuf_frame_set
make camera_set reset pixbuf_frame
fix send_direct

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/hal/lpc2106-cmucam3/cc3.c

    r444 r455  
    11/* 
    2  * Copyright 2006  Anthony Rowe and Adam Goode 
     2 * Copyright 2006-2007  Anthony Rowe and Adam Goode 
    33 * 
    44 * Licensed under the Apache License, Version 2.0 (the "License"); 
     
    3838 
    3939 
     40static _cc3_camera_state_t _cc3_g_current_camera_state; 
     41 
    4042static inline void _cc3_seek_left (void); 
    4143static inline void _cc3_seek_top (void); 
     
    6163static void _cc3_update_frame_bounds (cc3_frame_t *); 
    6264 
    63 static void _cc3_pixbuf_resize (void); 
     65static bool _cc3_set_register_state (void); 
     66 
    6467 
    6568void cc3_pixbuf_load () 
     
    7174  if (!_cc3_g_current_camera_state.power_state) { 
    7275    return; 
    73   } 
    74  
    75   if (cc3_g_pixbuf_frame.reset_on_next_load) { 
    76     _cc3_pixbuf_resize(); 
    7776  } 
    7877 
     
    185184    *(pixel + off2) = _cc3_pixbuf_read_subpixel (); 
    186185  } 
    187 } 
    188  
    189 void _cc3_pixbuf_resize () 
    190 { 
    191   cc3_g_pixbuf_frame.raw_width = _cc3_g_current_camera_state.raw_width; 
    192   cc3_g_pixbuf_frame.raw_height = _cc3_g_current_camera_state.raw_height; 
    193   cc3_pixbuf_frame_reset(); 
    194186} 
    195187 
     
    409401 
    410402/** 
    411  * cc3_pixbuf_set_roi(): 
     403 * cc3_pixbuf_frame_set_roi(): 
    412404 * Sets the region of interest in cc3_frame_t for virtual windowing. 
    413405 * This function changes the way data is read from the FIFO. 
    414406 */ 
    415 bool cc3_pixbuf_set_roi (int16_t x0, int16_t y0, int16_t x1, int16_t y1) 
     407bool cc3_pixbuf_frame_set_roi (int16_t x0, int16_t y0, int16_t x1, int16_t y1) 
    416408{ 
    417409  int w = cc3_g_pixbuf_frame.raw_width; 
     
    465457 
    466458/** 
    467  * cc3_pixbuf_set_subsample(): 
     459 * cc3_pixbuf_frame_set_subsample(): 
    468460 * Sets the subsampling step and mode in cc3_frame_t. 
    469461 * This function changes the way data is read from the FIFO. 
    470462 */ 
    471 bool cc3_pixbuf_set_subsample (cc3_subsample_mode_t mode, uint8_t x_step, 
     463bool cc3_pixbuf_frame_set_subsample (cc3_subsample_mode_t mode, uint8_t x_step, 
    472464                               uint8_t y_step) 
    473465{ 
     
    503495 
    504496/** 
    505  * cc3_pixbuf_set_coi(): 
     497 * cc3_pixbuf_frame_set_coi(): 
    506498 * Sets the channel of interest 1 or all. 
    507499 * This function changes the way data is read from the FIFO. 
    508500 */ 
    509 bool cc3_pixbuf_set_coi (cc3_channel_t chan) 
     501bool cc3_pixbuf_frame_set_coi (cc3_channel_t chan) 
    510502{ 
    511503  if (chan > 4) 
     
    549541  result = _cc3_set_register_state (); 
    550542 
    551   _cc3_pixbuf_resize(); 
    552  
    553543  return result; 
    554544} 
     
    564554  cc3_g_pixbuf_frame.y_loc = 0; 
    565555  cc3_g_pixbuf_frame.subsample_mode = CC3_SUBSAMPLE_NEAREST; 
    566   cc3_g_pixbuf_frame.reset_on_next_load = false; 
    567  
    568   cc3_pixbuf_set_coi(CC3_CHANNEL_ALL); 
     556 
     557  cc3_pixbuf_frame_set_coi(CC3_CHANNEL_ALL); 
    569558 
    570559  _cc3_update_frame_bounds (&cc3_g_pixbuf_frame); 
     
    699688  _cc3_g_current_camera_state.resolution = cam_res; 
    700689  _cc3_set_register_state ();   // XXX Don't reset all of them, this is just quick and dirty... 
    701   cc3_g_pixbuf_frame.reset_on_next_load = true; 
    702690} 
    703691 
     
    757745  return result; 
    758746} 
     747 
     748 
     749/* 
     750 * This function goes through the register state structures and sets the corresponding camera registers. 
     751 * It also updates any internal camera structures such as resolution that may change. 
     752 */ 
     753bool _cc3_set_register_state () 
     754{ 
     755  bool result = true; 
     756 
     757  switch (_cc3_g_current_camera_state.camera_type) { 
     758  case _CC3_OV6620: 
     759    // Set the right data bus mode 
     760    result &= cc3_camera_set_raw_register (0x14, 0x20); 
     761 
     762    // set the power state 
     763    if (_cc3_g_current_camera_state.power_state) { 
     764      // wake up the camera 
     765      result &= cc3_camera_set_raw_register (0x3F, 0x02); 
     766    } else { 
     767      // sleep the camera 
     768      result &= cc3_camera_set_raw_register (0x3F, 0x12); 
     769    } 
     770 
     771    // Set the resolution and update the size flags 
     772    if (_cc3_g_current_camera_state.resolution == CC3_CAMERA_RESOLUTION_LOW) { 
     773      cc3_g_pixbuf_frame.raw_width = CC3_LO_RES_WIDTH; // 88 * 2; 
     774      cc3_g_pixbuf_frame.raw_height = CC3_LO_RES_HEIGHT;       // 144; 
     775      result &= cc3_camera_set_raw_register (0x14, 0x20); 
     776    } 
     777    else { 
     778      cc3_g_pixbuf_frame.raw_width = CC3_HI_RES_WIDTH; // 176 * 2; 
     779      cc3_g_pixbuf_frame.raw_height = CC3_HI_RES_HEIGHT;       //288; 
     780      result &= cc3_camera_set_raw_register (0x14, 0x00); 
     781    } 
     782 
     783    if (_cc3_g_current_camera_state.auto_exposure) { 
     784      result &= cc3_camera_set_raw_register (0x13, 0x21); 
     785    } 
     786    else { 
     787      // No auto gain, so lets set brightness and contrast if need be 
     788      result &= cc3_camera_set_raw_register (0x13, 0x20); 
     789      if (_cc3_g_current_camera_state.brightness != -1) 
     790        result &= cc3_camera_set_raw_register (0x06, 
     791                                               (_cc3_g_current_camera_state. 
     792                                                brightness & 0xFF)); 
     793 
     794      if (_cc3_g_current_camera_state.contrast != -1) 
     795        result &= cc3_camera_set_raw_register (0x05, 
     796                                               (_cc3_g_current_camera_state. 
     797                                                contrast & 0xFF)); 
     798    } 
     799    // Set Colorspace and Auto White Balance 
     800    result &= cc3_camera_set_raw_register (0x12, 
     801                                           0x20 | 
     802                                           (_cc3_g_current_camera_state. 
     803                                            auto_white_balance << 2) 
     804                                           | (_cc3_g_current_camera_state. 
     805                                              colorspace << 3)); 
     806    // Set Frame Clock rate divider 
     807    result &= 
     808      cc3_camera_set_raw_register (0x11, 
     809                                   _cc3_g_current_camera_state.clock_divider); 
     810 
     811    break; 
     812 
     813  case _CC3_OV7620: 
     814    // XXX I need code.  The CMUcam2 is kind of wrong, so lets fix it... 
     815    result = false; 
     816    break; 
     817  } 
     818 
     819  cc3_pixbuf_frame_reset(); 
     820  return result; 
     821} 
  • trunk/hal/lpc2106-cmucam3/cc3_hal.c

    r444 r455  
    2121#include "serial.h" 
    2222#include <stdio.h> 
    23  
    24  
    25 _cc3_camera_state_t _cc3_g_current_camera_state; 
    2623 
    2724 
     
    146143 
    147144 
    148 /* 
    149  * This function goes through the register state structures and sets the corresponding camera registers. 
    150  * It also updates any internal camera structures such as resolution that may change. 
    151  */ 
    152 bool _cc3_set_register_state () 
    153 { 
    154   bool result = true; 
    155  
    156   switch (_cc3_g_current_camera_state.camera_type) { 
    157   case _CC3_OV6620: 
    158     // Set the right data bus mode 
    159     result &= cc3_camera_set_raw_register (0x14, 0x20); 
    160  
    161     // set the power state 
    162     if (_cc3_g_current_camera_state.power_state) { 
    163       // wake up the camera 
    164       result &= cc3_camera_set_raw_register (0x3F, 0x02); 
    165     } else { 
    166       // sleep the camera 
    167       result &= cc3_camera_set_raw_register (0x3F, 0x12); 
    168     } 
    169  
    170     // Set the resolution and update the size flags 
    171     if (_cc3_g_current_camera_state.resolution == CC3_CAMERA_RESOLUTION_LOW) { 
    172       _cc3_g_current_camera_state.raw_width = CC3_LO_RES_WIDTH; // 88 * 2; 
    173       _cc3_g_current_camera_state.raw_height = CC3_LO_RES_HEIGHT;       // 144; 
    174       result &= cc3_camera_set_raw_register (0x14, 0x20); 
    175     } 
    176     else { 
    177       _cc3_g_current_camera_state.raw_width = CC3_HI_RES_WIDTH; // 176 * 2; 
    178       _cc3_g_current_camera_state.raw_height = CC3_HI_RES_HEIGHT;       //288; 
    179       result &= cc3_camera_set_raw_register (0x14, 0x00); 
    180     } 
    181  
    182     if (_cc3_g_current_camera_state.auto_exposure) { 
    183       result &= cc3_camera_set_raw_register (0x13, 0x21); 
    184     } 
    185     else { 
    186       // No auto gain, so lets set brightness and contrast if need be 
    187       result &= cc3_camera_set_raw_register (0x13, 0x20); 
    188       if (_cc3_g_current_camera_state.brightness != -1) 
    189         result &= cc3_camera_set_raw_register (0x06, 
    190                                                (_cc3_g_current_camera_state. 
    191                                                 brightness & 0xFF)); 
    192  
    193       if (_cc3_g_current_camera_state.contrast != -1) 
    194         result &= cc3_camera_set_raw_register (0x05, 
    195                                                (_cc3_g_current_camera_state. 
    196                                                 contrast & 0xFF)); 
    197     } 
    198     // Set Colorspace and Auto White Balance 
    199     result &= cc3_camera_set_raw_register (0x12, 
    200                                            0x20 | 
    201                                            (_cc3_g_current_camera_state. 
    202                                             auto_white_balance << 2) 
    203                                            | (_cc3_g_current_camera_state. 
    204                                               colorspace << 3)); 
    205     // Set Frame Clock rate divider 
    206     result &= 
    207       cc3_camera_set_raw_register (0x11, 
    208                                    _cc3_g_current_camera_state.clock_divider); 
    209  
    210     break; 
    211  
    212   case _CC3_OV7620: 
    213     // XXX I need code.  The CMUcam2 is kind of wrong, so lets fix it... 
    214     result = false; 
    215     break; 
    216   } 
    217  
    218   return result; 
    219 } 
  • trunk/hal/lpc2106-cmucam3/cc3_hal.h

    r444 r455  
    5050typedef struct { 
    5151    _cc3_camera_type_t camera_type; 
    52     uint16_t raw_width; 
    53     uint16_t raw_height; 
    5452    int16_t brightness; 
    5553    int16_t contrast; 
     
    6260} _cc3_camera_state_t; 
    6361 
    64 /** 
    65  * This is the global structure that the different cc3_set_xxxx() functions use in order to maintain consistency 
    66  * if an attribute is changed that shares the same register as others. 
    67  */ 
    68 extern _cc3_camera_state_t _cc3_g_current_camera_state; 
    69  
    7062// called only from startup.s 
    7163void _cc3_system_setup (void); 
    7264 
    73 bool _cc3_set_register_state (void); 
    7465void _cc3_camera_reset (void); 
    7566void _cc3_fifo_reset (void); 
  • trunk/hal/virtual-cam/cc3.c

    r446 r455  
    11/* 
    2  * Copyright 2006  Anthony Rowe and Adam Goode 
     2 * Copyright 2006-2007  Anthony Rowe and Adam Goode 
    33 * 
    44 * Licensed under the Apache License, Version 2.0 (the "License"); 
     
    6060 
    6161static void _cc3_update_frame_bounds (cc3_frame_t *); 
    62 static void _cc3_resize_pixbuf (void); 
    6362 
    6463void cc3_pixbuf_load () 
     
    7170  static int img_cnt=0; 
    7271 
    73   if (cc3_g_pixbuf_frame.reset_on_next_load) { 
    74     _cc3_resize_pixbuf(); 
    75   } 
    7672   
    7773  if( _cc3_virtual_cam_path_prefix==NULL ) 
     
    306302} 
    307303 
    308 void _cc3_resize_pixbuf () 
    309 { 
    310   cc3_g_pixbuf_frame.raw_width = _cc3_g_current_camera_state.raw_width; 
    311   cc3_g_pixbuf_frame.raw_height = _cc3_g_current_camera_state.raw_height; 
    312  
    313 } 
    314  
    315304uint8_t *cc3_malloc_rows (uint32_t rows) 
    316305{ 
     
    480469 
    481470/** 
    482  * cc3_pixbuf_set_roi(): 
     471 * cc3_pixbuf_frame_set_roi(): 
    483472 * Sets the region of interest in cc3_frame_t for virtual windowing. 
    484473 * This function changes the way data is read from the FIFO. 
    485474 * Returns 1 upon success and 0 on an out of bounds failure. 
    486475 */ 
    487 bool cc3_pixbuf_set_roi (int16_t x0, int16_t y0, int16_t x1, int16_t y1) 
     476bool cc3_pixbuf_frame_set_roi (int16_t x0, int16_t y0, int16_t x1, int16_t y1) 
    488477{ 
    489478  int w = cc3_g_pixbuf_frame.raw_width; 
     
    537526 
    538527/** 
    539  * cc3_pixbuf_set_subsample(): 
     528 * cc3_pixbuf_frame_set_subsample(): 
    540529 * Sets the subsampling step and mode in cc3_frame_t. 
    541530 * This function changes the way data is read from the FIFO. 
    542531 */ 
    543 bool cc3_pixbuf_set_subsample (cc3_subsample_mode_t mode, uint8_t x_step, 
     532bool cc3_pixbuf_frame_set_subsample (cc3_subsample_mode_t mode, uint8_t x_step, 
    544533                              uint8_t y_step) 
    545534{ 
     
    575564 
    576565/** 
    577  * cc3_pixbuf_set_coi(): 
     566 * cc3_pixbuf_frame_set_coi(): 
    578567 * Sets the channel of interest 1 or all. 
    579568 * This function changes the way data is read from the FIFO. 
    580569 * Returns 1 upon success and 0 on failure. 
    581570 */ 
    582 bool cc3_pixbuf_set_coi (cc3_channel_t chan) 
     571bool cc3_pixbuf_frame_set_coi (cc3_channel_t chan) 
    583572{ 
    584573  if (chan > 4) 
     
    616605  _cc3_set_register_state (); 
    617606 
    618   _cc3_resize_pixbuf (); 
    619607  printf( "cc3_camera_init()\n" ); 
    620608  _cc3_virtual_cam_path_prefix = getenv("CC3_VCAM_PATH");  
     
    638626  cc3_g_pixbuf_frame.y_loc = 0; 
    639627  cc3_g_pixbuf_frame.subsample_mode = CC3_SUBSAMPLE_NEAREST; 
    640   cc3_g_pixbuf_frame.reset_on_next_load = false; 
    641  
    642   cc3_pixbuf_set_coi(CC3_CHANNEL_ALL); 
     628 
     629  cc3_pixbuf_frame_set_coi(CC3_CHANNEL_ALL); 
    643630 
    644631  _cc3_update_frame_bounds (&cc3_g_pixbuf_frame); 
     
    715702  _cc3_g_current_camera_state.resolution = cam_res; 
    716703  _cc3_set_register_state ();   // XXX Don't reset all of them, this is just quick and dirty... 
    717   cc3_g_pixbuf_frame.reset_on_next_load = true; 
    718704} 
    719705 
  • trunk/hal/virtual-cam/cc3_hal.c

    r420 r455  
    105105        // Set the resolution and update the cc3_g_current_frame size flags 
    106106        if (_cc3_g_current_camera_state.resolution == CC3_CAMERA_RESOLUTION_LOW) { 
    107             _cc3_g_current_camera_state.raw_width = CC3_LO_RES_WIDTH; 
    108             _cc3_g_current_camera_state.raw_height = CC3_LO_RES_HEIGHT; 
     107            cc3_g_pixbuf_frame.raw_width = CC3_LO_RES_WIDTH; 
     108            cc3_g_pixbuf_frame.raw_height = CC3_LO_RES_HEIGHT; 
    109109         //   cc3_set_raw_register (0x14, 0x20); 
    110110        } 
    111111        else { 
    112             _cc3_g_current_camera_state.raw_width = CC3_HI_RES_WIDTH; 
    113             _cc3_g_current_camera_state.raw_height = CC3_HI_RES_HEIGHT; 
     112            cc3_g_pixbuf_frame.raw_width = CC3_HI_RES_WIDTH; 
     113            cc3_g_pixbuf_frame.raw_height = CC3_HI_RES_HEIGHT; 
    114114           // cc3_set_raw_register (0x14, 0x00); 
    115115        } 
     
    149149        break; 
    150150    } 
    151  
    152  
     151    cc3_pixbuf_frame_reset(); 
    153152} 
  • trunk/hal/virtual-cam/cc3_hal.h

    r387 r455  
    6060    bool auto_white_balance; 
    6161    uint8_t resolution; 
    62     uint16_t raw_width; 
    63     uint16_t raw_height; 
    6462    _cc3_camera_type_t camera_type; 
    6563} _cc3_camera_state_t; 
  • trunk/include/cc3.h

    r454 r455  
    160160  uint16_t height;             /**< Height of clipping region */ 
    161161  uint8_t channels;            /**< Number of channels */ 
    162  
    163   bool reset_on_next_load;     /**< \a true if the camera parameters have 
    164                                   changed */ 
    165162} cc3_frame_t; 
    166163 
     
    175172 * Current parameters for the internal pixbuf, should be 
    176173 * considered read only. 
    177  * @sa cc3_pixbuf_frame_reset() 
    178174 */ 
    179175extern cc3_frame_t cc3_g_pixbuf_frame; 
    180176 
    181177/** 
    182  * Initialize camera hardware. 
     178 * Initialize camera hardware. This resets all camera and pixbuf parameters. 
    183179 * 
    184180 * @return \a true if successful. 
     
    194190/** 
    195191 * Take a picture with the camera and load it into the internal pixbuf. 
    196  * If #cc3_g_pixbuf_frame has cc3_frame_t.reset_on_next_load set, 
    197  * then #cc3_g_pixbuf_frame is completely reset with new values. 
    198192 */ 
    199193void cc3_pixbuf_load (void); 
     
    204198 * to deallocate this memory when you are done. 
    205199 * 
    206  * \warning If you have changed resolution using cc3_set_resolution(), 
    207  * but have not yet called cc3_pixbuf_load(), this function will return 
    208  * the amount of memory corresponding to the old row size. 
    209  * 
    210200 * @sa cc3_pixbuf_read_rows() 
    211201 * 
     
    217207/** 
    218208 * Do a row-by-row copy from the pixbuf into a block of memory. 
    219  * This function takes into account all the parameters listed in 
     209 * This function takes into account all of the parameters listed in 
    220210 * #cc3_g_pixbuf_frame. 
    221211 * 
     
    242232 * @return \a true if successful. 
    243233 */ 
    244 bool cc3_pixbuf_set_roi (int16_t x_0, int16_t y_0, int16_t x_1, int16_t y_1); 
     234bool cc3_pixbuf_frame_set_roi (int16_t x_0, 
     235                               int16_t y_0, 
     236                               int16_t x_1, 
     237                               int16_t y_1); 
    245238 
    246239/** 
     
    253246 *         applied even if \a false. 
    254247 */ 
    255 bool cc3_pixbuf_set_subsample (cc3_subsample_mode_t mode, 
    256                               uint8_t x_step, 
    257                               uint8_t y_step); 
     248bool cc3_pixbuf_frame_set_subsample (cc3_subsample_mode_t mode, 
     249                                     uint8_t x_step, 
     250                                     uint8_t y_step); 
    258251 
    259252/** 
     
    264257 * @return \a true on success. 
    265258 */ 
    266 bool cc3_pixbuf_set_coi (cc3_channel_t chan); 
     259bool cc3_pixbuf_frame_set_coi (cc3_channel_t chan); 
    267260 
    268261/** 
     
    290283 
    291284/** 
    292  * Set the power state of the camera and (possibly) pixbuf. Used to 
     285 * Set the power state of the camera and reset #cc3_g_pixbuf_frame. Used to 
    293286 * conserve power when the camera is not being used. 
    294287 * 
     
    301294 
    302295/** 
    303  * Set the resolution of the camera hardware. This does not have any 
    304  * effect on the pixbuf or #cc3_g_pixbuf_frame until cc3_pixbuf_load() 
    305  * is called again. 
     296 * Set the resolution of the camera hardware and reset #cc3_g_pixbuf_frame. 
    306297 * 
    307298 * @param[in] res Resolution to set. 
     
    310301 
    311302/** 
    312  * Set the colorspace of the camera
     303 * Set the colorspace of the camera and reset #cc3_g_pixbuf_frame
    313304 * 
    314305 * @param[in] colorspace The colorspace. 
     
    317308 
    318309/** 
    319  * Set the framerate divider
     310 * Set the framerate divider and reset #cc3_g_pixbuf_frame
    320311 * 
    321312 * @param[in] rate_divider Desired framerate divider. 
     
    324315 
    325316/** 
    326  * Set auto exposure
     317 * Set auto exposure and reset #cc3_g_pixbuf_frame
    327318 * 
    328319 * @param[in] ae Auto exposure value. 
     
    331322 
    332323/** 
    333  * Set auto white balance
     324 * Set auto white balance and reset #cc3_g_pixbuf_frame
    334325 * 
    335326 * @param[in] wb Auto white balance value. 
     
    338329 
    339330/** 
    340  * Set the brightness
     331 * Set the brightness and reset #cc3_g_pixbuf_frame
    341332 * 
    342333 * @param[in] level The level. 
     
    345336 
    346337/** 
    347  * Set contrast
     338 * Set contrast and reset #cc3_g_pixbuf_frame
    348339 * 
    349340 * @param[in] level The level. 
     
    357348 * manipulation of the camera modes.  Currently, this will not set the 
    358349 * corresponding cc3 internal data structure that keeps record of the camera 
    359  * mode
     350 * mode, nor will it change #cc3_g_pixbuf_frame
    360351 * \warning Use with CAUTION. 
    361352 * 
  • trunk/projects/cmucam2/cmucam2.c

    r451 r455  
    3636static const int MAX_LINE = 128; 
    3737 
    38 static const char *VERSION_BANNER = "CMUcam2 v1.00 c6"; 
     38static const char VERSION_BANNER[] = "CMUcam2 v1.00 c6"; 
    3939 
    4040typedef enum { 
     
    224224  servo_settings.y_report=false; 
    225225  demo_mode = false; 
    226   
     226 
    227227  start_time = cc3_timer_get_current_ms (); 
    228    
     228 
    229229  do { 
    230230    if (cc3_button_get_state () == 1) { 
     
    261261  t_pkt.lower_bound.channel[2] = 16; 
    262262  t_pkt.upper_bound.channel[2] = 240; 
    263   
    264    
     263 
     264 
    265265  servo_settings.x=SERVO_MID; 
    266266  servo_settings.y=SERVO_MID; 
     
    276276  cc3_camera_set_resolution (CC3_CAMERA_RESOLUTION_LOW); 
    277277 
    278   cc3_pixbuf_load (); 
    279  
    280278  printf ("%s\r", VERSION_BANNER); 
    281279 
     
    284282  cc3_gpio_set_mode (2, CC3_GPIO_MODE_SERVO); 
    285283  cc3_gpio_set_mode (3, CC3_GPIO_MODE_SERVO); 
    286    
     284 
    287285  cc3_gpio_set_servo_position (0, SERVO_MID); 
    288286  cc3_gpio_set_servo_position (1, SERVO_MID); 
     
    290288  cc3_gpio_set_servo_position (3, SERVO_MID); 
    291289 
    292   cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1); 
     290  cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1); 
    293291 
    294292  if (demo_mode) { 
     
    414412        break; 
    415413 
    416        case SERVO_PARAMETERS: 
     414      case SERVO_PARAMETERS: 
    417415        if (n != 6) { 
    418416          error = true; 
     
    428426        servo_settings.tilt_step=arg_list[5]; 
    429427        break; 
    430          
    431        case SERVO_MASK: 
     428 
     429      case SERVO_MASK: 
    432430        if (n != 1) { 
    433431          error = true; 
     
    442440        break; 
    443441 
    444        case HI_RES: 
     442      case HI_RES: 
    445443        if (n != 1) { 
    446444          error = true; 
     
    454452          cc3_camera_set_resolution (CC3_CAMERA_RESOLUTION_LOW); 
    455453 
    456         // re-init fifo 
    457         cc3_pixbuf_load (); 
    458         cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1); 
     454        cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1); 
    459455        break; 
    460456 
     
    467463        h_pkt.bins = arg_list[0]; 
    468464        print_ACK (); 
    469          
    470         break;  
    471  
    472          
     465 
     466        break; 
     467 
     468 
    473469      case TRACK_INVERT: 
    474470        if (n != 1 || arg_list[0] > 1) { 
     
    520516        //init_jpeg(); 
    521517        // cc3_set_resolution(CC3_RES_HIGH); 
    522         //cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, 1, 1); 
     518        //cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 1, 1); 
    523519 
    524520        cc3_jpeg_send_simple (); 
     
    534530            break; 
    535531          } 
    536           cc3_pixbuf_set_coi (arg_list[0]); 
     532          cc3_pixbuf_frame_set_coi (arg_list[0]); 
    537533        } 
    538534        else if (n > 1) { 
     
    543539        print_ACK (); 
    544540        cmucam2_send_image_direct (auto_led); 
    545         cc3_pixbuf_set_coi (old_coi); 
     541        cc3_pixbuf_frame_set_coi (old_coi); 
    546542        break; 
    547543 
     
    565561 
    566562        print_ACK (); 
    567         cc3_camera_set_power_state(arg_list[0]); 
     563        { 
     564          // save 
     565          uint16_t x_0 = cc3_g_pixbuf_frame.x0; 
     566          uint16_t y_0 = cc3_g_pixbuf_frame.y0; 
     567          uint16_t x_1 = cc3_g_pixbuf_frame.x1; 
     568          uint16_t y_1 = cc3_g_pixbuf_frame.y1; 
     569          uint8_t x_step = cc3_g_pixbuf_frame.x_step; 
     570          uint8_t y_step = cc3_g_pixbuf_frame.y_step; 
     571          cc3_subsample_mode_t ss_mode = cc3_g_pixbuf_frame.subsample_mode; 
     572 
     573          cc3_camera_set_power_state(arg_list[0]); 
     574 
     575          // restore 
     576          cc3_pixbuf_frame_set_roi(x_0, y_0, x_1, y_1); 
     577          cc3_pixbuf_frame_set_subsample (ss_mode, x_step, y_step); 
     578        } 
    568579        break; 
    569580 
     
    575586 
    576587        print_ACK (); 
    577         cc3_pixbuf_set_roi (arg_list[0] * 2, 
    578                             arg_list[1], arg_list[2] * 2, arg_list[3]); 
     588        cc3_pixbuf_frame_set_roi (arg_list[0] * 2, 
     589                                  arg_list[1], arg_list[2] * 2, arg_list[3]); 
    579590        break; 
    580591 
     
    611622 
    612623        print_ACK (); 
    613         cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, arg_list[0] * 2, 
    614                                   arg_list[1]); 
     624        cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, arg_list[0] * 2, 
     625                                        arg_list[1]); 
    615626        break; 
    616627 
     
    666677          y0 = cc3_g_pixbuf_frame.y0 + cc3_g_pixbuf_frame.width / 4; 
    667678          y1 = cc3_g_pixbuf_frame.y1 - cc3_g_pixbuf_frame.width / 4; 
    668           cc3_pixbuf_set_roi (x0, y0, x1, y1); 
     679          cc3_pixbuf_frame_set_roi (x0, y0, x1, y1); 
    669680          // call get mean 
    670681          cmucam2_get_mean (&s_pkt, 1, line_mode,buf_mode, 1); 
     
    674685          y0 = 0; 
    675686          y1 = cc3_g_pixbuf_frame.raw_height; 
    676           cc3_pixbuf_set_roi (x0, y0, x1, y1); 
     687          cc3_pixbuf_frame_set_roi (x0, y0, x1, y1); 
    677688          // fill in parameters and call track color 
    678689          tmp = s_pkt.mean.channel[0] - threshold; 
     
    845856    for (x = 0; x < size_x * num_channels; x++) { 
    846857      uint8_t p = row[x]; 
     858 
     859      // avoid confusion from FIFO corruptions 
     860      if (p < 16) { 
     861        p = 16; 
     862      } else if (p > 240) { 
     863        p = 240; 
     864      } 
    847865      putchar (p); 
    848866    } 
  • trunk/projects/edge-follow/main.c

    r449 r455  
    4444  cc3_camera_set_auto_white_balance (false); 
    4545  cc3_camera_set_auto_exposure (true); 
    46   cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 
    47   //cc3_pixbuf_set_coi (CC3_CHANNEL_GREEN); 
    48   cc3_pixbuf_set_coi (CC3_CHANNEL_ALL); 
     46  cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 
     47  //cc3_pixbuf_frame_set_coi (CC3_CHANNEL_GREEN); 
     48  cc3_pixbuf_frame_set_coi (CC3_CHANNEL_ALL); 
    4949 
    5050  cc3_led_set_off (1); 
  • trunk/projects/edge-follow/polly.c

    r449 r455  
    7272 
    7373#ifdef MMC_DEBUG 
    74     cc3_pixbuf_set_coi (CC3_ALL); 
     74    cc3_pixbuf_frame_set_coi (CC3_ALL); 
    7575    write_raw_fifo_ppm(); 
    76     cc3_pixbuf_set_coi (CC3_GREEN); 
     76    cc3_pixbuf_frame_set_coi (CC3_GREEN); 
    7777    cc3_pixbuf_rewind(); 
    7878#endif 
  • trunk/projects/hello-world/main.c

    r431 r455  
    113113    // This tells the camera to grab a new frame into the fifo and reset 
    114114    // any internal location information. 
    115     cc3_pixbuf_set_coi(CC3_CHANNEL_ALL); 
     115    cc3_pixbuf_frame_set_coi(CC3_CHANNEL_ALL); 
    116116    cc3_pixbuf_load (); 
    117117 
     
    172172    // *** even faster method for red search 
    173173    cc3_pixbuf_rewind();  // use exactly the same pixbuf contents 
    174     cc3_pixbuf_set_coi(CC3_CHANNEL_RED); 
     174    cc3_pixbuf_frame_set_coi(CC3_CHANNEL_RED); 
    175175    start_time = cc3_timer_get_current_ms(); 
    176176    max_red = 0; 
  • trunk/projects/polly/main.c

    r431 r455  
    4040 
    4141 
    42   cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 
    43   cc3_pixbuf_set_coi (CC3_CHANNEL_GREEN); 
     42  cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 
     43  cc3_pixbuf_frame_set_coi (CC3_CHANNEL_GREEN); 
    4444 
    4545  cc3_led_set_off (0); 
  • trunk/projects/polly/polly.c

    r420 r455  
    5353  cc3_pixbuf_load(); 
    5454 
    55   cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 
    56   cc3_pixbuf_set_coi (CC3_CHANNEL_GREEN); 
     55  cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 
     56  cc3_pixbuf_frame_set_coi (CC3_CHANNEL_GREEN); 
    5757 
    5858 
     
    9595 
    9696#ifdef MMC_DEBUG 
    97   cc3_pixbuf_set_coi (CC3_CHANNEL_ALL); 
     97  cc3_pixbuf_frame_set_coi (CC3_CHANNEL_ALL); 
    9898  write_raw_fifo_ppm (); 
    99   cc3_pixbuf_set_coi (CC3_CHANNEL_GREEN); 
     99  cc3_pixbuf_frame_set_coi (CC3_CHANNEL_GREEN); 
    100100  cc3_pixbuf_rewind (); 
    101101#endif 
  • trunk/projects/polly/polly_no_cc3.c

    r431 r455  
    5555     
    5656 
    57     cc3_pixbuf_set_subsample( CC3_NEAREST, 2, 2 );  
    58     cc3_pixbuf_set_coi(CC3_RED); 
     57    cc3_pixbuf_frame_set_subsample( CC3_NEAREST, 2, 2 );  
     58    cc3_pixbuf_frame_set_coi(CC3_RED); 
    5959     
    6060    cc3_led_set_off (0);