<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:general_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
wiki:v2:general_api [2018/05/22 14:48]
pixycam [Error codes]
wiki:v2:general_api [2019/04/29 20:08]
pixycam
Line 1: Line 1:
 ===== Pixy2 General API ===== ===== Pixy2 General API =====
 +
 +Pixy2'​s general API can be called through the base Pixy2 object, for example:
 +
 +<​code>​
 +Pixy2 pixy;
 +
 +pixy.init();​ // call init() member function
 +</​code>​
 +
 +See also the [[wiki:​v2:​ccc_api|Color Connected Components API]], [[wiki:​v2:​line_api|Line tracking API]], and [[wiki:​v2:​video_api|Video API]] for other functionality.
 +
 +For a byte-level reference to the protocol, check out the new [[wiki:​v2:​protocol_reference|Pixy2 Serial Protocol - Packet Reference]]
 +
  
 ==== Member functions ==== ==== Member functions ====
   ​   ​
-=== int8_t init(uint32_t arg[optional]) ===+=== int8_t init(uint32_t arg [optional]) ===
  
 init() should be called before your program communicates with Pixy.  init() returns an [[wiki:​v2:​general_api#​Error codes|error value]] (<0) if it fails and 0 (PIXY\_RESULT\_OK) if it succeeds. ​ init() should be called before your program communicates with Pixy.  init() returns an [[wiki:​v2:​general_api#​Error codes|error value]] (<0) if it fails and 0 (PIXY\_RESULT\_OK) if it succeeds. ​
Line 20: Line 33:
 === int8_t setServos(uint16_t s0, uint16_t s1) === === int8_t setServos(uint16_t s0, uint16_t s1) ===
  
-setServos() sets the servo positions of servos plugged into Pixy2'​s two RC servo connectors. ​ It returns an [[wiki:​v2:​general_api#​Error codes|error value]] (<0) if it fails and 0 (PIXY\_RESULT\_OK) if it succeeds.+setServos() sets the servo positions of servos plugged into Pixy2'​s two RC servo connectors.  The servo values range between PIXY_RCS_MIN_POS (0) and PIXY_RCS_MAX_POS (1000).  It returns an [[wiki:​v2:​general_api#​Error codes|error value]] (<0) if it fails and 0 (PIXY\_RESULT\_OK) if it succeeds.
    
  
Line 36: Line 49:
  
 setLamp() turns on/off Pixy2'​s integrated light source. ​ The _upper_ argument controls the two white LEDs along the top edge of Pixy2'​s PCB.  The _lower_ argument sets the RGB LED, causing it to turn on all three color channels at full brightness, resulting in white light. Both arguments are binary, zero or non-zero. ​ It returns an [[wiki:​v2:​general_api#​Error codes|error value]] (<0) if it fails and 0 (PIXY\_RESULT\_OK) if it succeeds. ​ setLamp() turns on/off Pixy2'​s integrated light source. ​ The _upper_ argument controls the two white LEDs along the top edge of Pixy2'​s PCB.  The _lower_ argument sets the RGB LED, causing it to turn on all three color channels at full brightness, resulting in white light. Both arguments are binary, zero or non-zero. ​ It returns an [[wiki:​v2:​general_api#​Error codes|error value]] (<0) if it fails and 0 (PIXY\_RESULT\_OK) if it succeeds. ​
 +
 +
 +=== int8_t getResolution() ===
 +
 +getResolution() gets the width and height of the frames used by the current program. ​ After calling this function, the width and height can be found in the **frameWidth** and **frameHeight** member variables. ​ Note, calling changeProg() will call getResolution() automatically and update **frameWidth** and **frameHeight**.  ​
 +
 +
 +Pixy2 will automatically change programs if, for example, you call ccc.getBlocks() from the color connected components program followed by line.getMainFeatures() from the line tracking program. ​ These "​automatic program changes"​ will not update **frameWidth** and **frameHeight** member variables.
 +
 +
 +=== int8_t getFPS() ===
 +
 +getFPS() gets Pixy2'​s framerate. ​ The framerate can range between 2 and 62 frames per second depending on the amount of light in the environment and the **min frames per second** setting in the [[wiki:​v2:​pixymon_index#​camera-tab|Camera configuration tab]]. ​ This function can also serve as a simple indicator of the amount of light in the environment. ​ That is, low framerates necessarily imply lower lighting levels.  ​
 +
  
  
wiki/v2/general_api.txt ยท Last modified: 2019/04/29 20:08 by pixycam