Port of Arduino Pixy Cmucam5 library.
Fork of pixy by
PixyLinkUART.h@0:ed8dc4531ac1, 2014-11-16 (annotated)
- Committer:
- acracan
- Date:
- Sun Nov 16 11:52:55 2014 +0000
- Revision:
- 0:ed8dc4531ac1
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_PIXYLINKUART_H |
acracan | 0:ed8dc4531ac1 | 2 | #define TUIASI_PIXYLINKUART_H |
acracan | 0:ed8dc4531ac1 | 3 | |
acracan | 0:ed8dc4531ac1 | 4 | #include "Serial.h" |
acracan | 0:ed8dc4531ac1 | 5 | #include "PixyLink.h" |
acracan | 0:ed8dc4531ac1 | 6 | |
acracan | 0:ed8dc4531ac1 | 7 | class PixyLinkUART : public PixyLink, private Serial |
acracan | 0:ed8dc4531ac1 | 8 | { |
acracan | 0:ed8dc4531ac1 | 9 | public: |
acracan | 0:ed8dc4531ac1 | 10 | PixyLinkUART(PinName tx, PinName rx) : |
acracan | 0:ed8dc4531ac1 | 11 | Serial(tx, rx) { |
acracan | 0:ed8dc4531ac1 | 12 | baud(19200); |
acracan | 0:ed8dc4531ac1 | 13 | }; |
acracan | 0:ed8dc4531ac1 | 14 | |
acracan | 0:ed8dc4531ac1 | 15 | virtual uint16_t getWord() { |
acracan | 0:ed8dc4531ac1 | 16 | uint8_t data[2] = {0, 0}; |
acracan | 0:ed8dc4531ac1 | 17 | read(data, 2); |
acracan | 0:ed8dc4531ac1 | 18 | return ((uint16_t)data[1] << 8) | data[0]; |
acracan | 0:ed8dc4531ac1 | 19 | }; |
acracan | 0:ed8dc4531ac1 | 20 | |
acracan | 0:ed8dc4531ac1 | 21 | virtual uint8_t getByte() { |
acracan | 0:ed8dc4531ac1 | 22 | uint8_t data = 0; |
acracan | 0:ed8dc4531ac1 | 23 | read(&data, 1); |
acracan | 0:ed8dc4531ac1 | 24 | return data; |
acracan | 0:ed8dc4531ac1 | 25 | }; |
acracan | 0:ed8dc4531ac1 | 26 | |
acracan | 0:ed8dc4531ac1 | 27 | virtual int8_t send(uint8_t *data, uint8_t len) { |
acracan | 0:ed8dc4531ac1 | 28 | return write(data, len); |
acracan | 0:ed8dc4531ac1 | 29 | }; |
acracan | 0:ed8dc4531ac1 | 30 | |
acracan | 0:ed8dc4531ac1 | 31 | |
acracan | 0:ed8dc4531ac1 | 32 | private: |
acracan | 0:ed8dc4531ac1 | 33 | }; |
acracan | 0:ed8dc4531ac1 | 34 | #endif //TUIASI_PIXYLINKUART_H |