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
PixyLinkUART.h@2:a58a6a71ae7b, 2015-07-01 (annotated)
- Committer:
- LucasUIUC
- Date:
- Wed Jul 01 19:43:36 2015 +0000
- Revision:
- 2:a58a6a71ae7b
- Parent:
- 0:ed8dc4531ac1
Code with servo position in pixy.h
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 |