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
Pixy.h@0:ed8dc4531ac1, 2014-11-16 (annotated)
- Committer:
- acracan
- Date:
- Sun Nov 16 11:52:55 2014 +0000
- Revision:
- 0:ed8dc4531ac1
- Child:
- 1:f8b6497870d3
Initial commit of ported version of the Arduino Pixy Cmucam5 library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
acracan | 0:ed8dc4531ac1 | 1 | #ifndef TUIASI_PIXY_H |
acracan | 0:ed8dc4531ac1 | 2 | #define TUIASI_PIXY_H |
acracan | 0:ed8dc4531ac1 | 3 | |
acracan | 0:ed8dc4531ac1 | 4 | #include "mbed.h" |
acracan | 0:ed8dc4531ac1 | 5 | #include "PixyLinkSPI.h" |
acracan | 0:ed8dc4531ac1 | 6 | #include "PixyLinkI2C.h" |
acracan | 0:ed8dc4531ac1 | 7 | #include "PixyLinkUART.h" |
acracan | 0:ed8dc4531ac1 | 8 | |
acracan | 0:ed8dc4531ac1 | 9 | struct Block { |
acracan | 0:ed8dc4531ac1 | 10 | void print(Serial &pc) { |
acracan | 0:ed8dc4531ac1 | 11 | pc.printf("sig: %d x: %d y: %d width: %d height: %d\n", signature, x, y, width, height); |
acracan | 0:ed8dc4531ac1 | 12 | }; |
acracan | 0:ed8dc4531ac1 | 13 | uint16_t signature; |
acracan | 0:ed8dc4531ac1 | 14 | uint16_t x; |
acracan | 0:ed8dc4531ac1 | 15 | uint16_t y; |
acracan | 0:ed8dc4531ac1 | 16 | uint16_t width; |
acracan | 0:ed8dc4531ac1 | 17 | uint16_t height; |
acracan | 0:ed8dc4531ac1 | 18 | }; |
acracan | 0:ed8dc4531ac1 | 19 | |
acracan | 0:ed8dc4531ac1 | 20 | class Pixy |
acracan | 0:ed8dc4531ac1 | 21 | { |
acracan | 0:ed8dc4531ac1 | 22 | public: |
acracan | 0:ed8dc4531ac1 | 23 | enum LinkType {SPI, I2C, UART}; |
acracan | 0:ed8dc4531ac1 | 24 | Pixy(LinkType linkType, PinName mosi_sda_tx, PinName miso_scl_rx, PinName sclk = NC); |
acracan | 0:ed8dc4531ac1 | 25 | ~Pixy(); |
acracan | 0:ed8dc4531ac1 | 26 | uint16_t getBlocks(uint16_t maxBlocks=1000); |
acracan | 0:ed8dc4531ac1 | 27 | int8_t setServos(uint16_t s0, uint16_t s1); |
acracan | 0:ed8dc4531ac1 | 28 | void setAddress(uint8_t addr); |
acracan | 0:ed8dc4531ac1 | 29 | void setSerialOutput(Serial *pc); |
acracan | 0:ed8dc4531ac1 | 30 | |
acracan | 0:ed8dc4531ac1 | 31 | Block *blocks; |
acracan | 0:ed8dc4531ac1 | 32 | |
acracan | 0:ed8dc4531ac1 | 33 | private: |
acracan | 0:ed8dc4531ac1 | 34 | static const uint8_t PIXY_INITIAL_ARRAYSIZE = 30; |
acracan | 0:ed8dc4531ac1 | 35 | static const uint8_t PIXY_MAXIMUM_ARRAYSIZE = 130; |
acracan | 0:ed8dc4531ac1 | 36 | static const uint16_t PIXY_START_WORD = 0xaa55; |
acracan | 0:ed8dc4531ac1 | 37 | static const uint16_t PIXY_START_WORDX = 0x55aa; |
acracan | 0:ed8dc4531ac1 | 38 | static const uint8_t PIXY_DEFAULT_ADDR = 0x54; // I2C |
acracan | 0:ed8dc4531ac1 | 39 | |
acracan | 0:ed8dc4531ac1 | 40 | bool getStart(); |
acracan | 0:ed8dc4531ac1 | 41 | void resize(); |
acracan | 0:ed8dc4531ac1 | 42 | |
acracan | 0:ed8dc4531ac1 | 43 | bool skipStart; |
acracan | 0:ed8dc4531ac1 | 44 | uint16_t blockCount; |
acracan | 0:ed8dc4531ac1 | 45 | uint16_t blockArraySize; |
acracan | 0:ed8dc4531ac1 | 46 | |
acracan | 0:ed8dc4531ac1 | 47 | PixyLink *m_link; |
acracan | 0:ed8dc4531ac1 | 48 | Serial *pc; |
acracan | 0:ed8dc4531ac1 | 49 | }; |
acracan | 0:ed8dc4531ac1 | 50 | #endif //TUIASI_PIXY_H |