ok
Dependents: pixy2 pixy2_10_0042 0000Non_stop_code_v1 0000Non_stop_code_v3 ... more
Fork of pixy by
Pixy.h@1:e7cb59aaf759, 2017-06-08 (annotated)
- Committer:
- pirottealex
- Date:
- Thu Jun 08 20:04:08 2017 +0000
- Revision:
- 1:e7cb59aaf759
- Parent:
- 0:ed8dc4531ac1
ok
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); |
pirottealex | 1:e7cb59aaf759 | 25 | Pixy(PinName tx, PinName rx); |
acracan | 0:ed8dc4531ac1 | 26 | ~Pixy(); |
acracan | 0:ed8dc4531ac1 | 27 | uint16_t getBlocks(uint16_t maxBlocks=1000); |
acracan | 0:ed8dc4531ac1 | 28 | int8_t setServos(uint16_t s0, uint16_t s1); |
acracan | 0:ed8dc4531ac1 | 29 | void setAddress(uint8_t addr); |
acracan | 0:ed8dc4531ac1 | 30 | void setSerialOutput(Serial *pc); |
acracan | 0:ed8dc4531ac1 | 31 | |
acracan | 0:ed8dc4531ac1 | 32 | Block *blocks; |
acracan | 0:ed8dc4531ac1 | 33 | |
acracan | 0:ed8dc4531ac1 | 34 | private: |
acracan | 0:ed8dc4531ac1 | 35 | static const uint8_t PIXY_INITIAL_ARRAYSIZE = 30; |
acracan | 0:ed8dc4531ac1 | 36 | static const uint8_t PIXY_MAXIMUM_ARRAYSIZE = 130; |
acracan | 0:ed8dc4531ac1 | 37 | static const uint16_t PIXY_START_WORD = 0xaa55; |
acracan | 0:ed8dc4531ac1 | 38 | static const uint16_t PIXY_START_WORDX = 0x55aa; |
acracan | 0:ed8dc4531ac1 | 39 | static const uint8_t PIXY_DEFAULT_ADDR = 0x54; // I2C |
acracan | 0:ed8dc4531ac1 | 40 | |
acracan | 0:ed8dc4531ac1 | 41 | bool getStart(); |
acracan | 0:ed8dc4531ac1 | 42 | void resize(); |
acracan | 0:ed8dc4531ac1 | 43 | |
acracan | 0:ed8dc4531ac1 | 44 | bool skipStart; |
acracan | 0:ed8dc4531ac1 | 45 | uint16_t blockCount; |
acracan | 0:ed8dc4531ac1 | 46 | uint16_t blockArraySize; |
acracan | 0:ed8dc4531ac1 | 47 | |
acracan | 0:ed8dc4531ac1 | 48 | PixyLink *m_link; |
acracan | 0:ed8dc4531ac1 | 49 | Serial *pc; |
acracan | 0:ed8dc4531ac1 | 50 | }; |
acracan | 0:ed8dc4531ac1 | 51 | #endif //TUIASI_PIXY_H |