This code just added an algorithm to calculate angle form the pixy center
Dependents: pixyHelloWorld2_copy_servoTest pixy_pan_tilt Servo_camera_pan Camera_Gimbal_Tracking
Fork of pixy by
Diff: Pixy.h
- Revision:
- 0:ed8dc4531ac1
- Child:
- 1:f8b6497870d3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Pixy.h Sun Nov 16 11:52:55 2014 +0000 @@ -0,0 +1,50 @@ +#ifndef TUIASI_PIXY_H +#define TUIASI_PIXY_H + +#include "mbed.h" +#include "PixyLinkSPI.h" +#include "PixyLinkI2C.h" +#include "PixyLinkUART.h" + +struct Block { + void print(Serial &pc) { + pc.printf("sig: %d x: %d y: %d width: %d height: %d\n", signature, x, y, width, height); + }; + uint16_t signature; + uint16_t x; + uint16_t y; + uint16_t width; + uint16_t height; +}; + +class Pixy +{ +public: + enum LinkType {SPI, I2C, UART}; + Pixy(LinkType linkType, PinName mosi_sda_tx, PinName miso_scl_rx, PinName sclk = NC); + ~Pixy(); + uint16_t getBlocks(uint16_t maxBlocks=1000); + int8_t setServos(uint16_t s0, uint16_t s1); + void setAddress(uint8_t addr); + void setSerialOutput(Serial *pc); + + Block *blocks; + +private: + static const uint8_t PIXY_INITIAL_ARRAYSIZE = 30; + static const uint8_t PIXY_MAXIMUM_ARRAYSIZE = 130; + static const uint16_t PIXY_START_WORD = 0xaa55; + static const uint16_t PIXY_START_WORDX = 0x55aa; + static const uint8_t PIXY_DEFAULT_ADDR = 0x54; // I2C + + bool getStart(); + void resize(); + + bool skipStart; + uint16_t blockCount; + uint16_t blockArraySize; + + PixyLink *m_link; + Serial *pc; +}; +#endif //TUIASI_PIXY_H \ No newline at end of file