Prometheus / Pixy

Dependents:   PixyTest PixyTest

Committer:
ZHAW_Prometheus
Date:
Fri May 05 12:03:13 2017 +0000
Revision:
0:a2603d7fa0ac
Child:
1:0683e3163119
Child:
2:c3a866b20784
Vers-0.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ZHAW_Prometheus 0:a2603d7fa0ac 1 #ifndef TUIASI_PIXY_H
ZHAW_Prometheus 0:a2603d7fa0ac 2 #define TUIASI_PIXY_H
ZHAW_Prometheus 0:a2603d7fa0ac 3
ZHAW_Prometheus 0:a2603d7fa0ac 4 #include "mbed.h"
ZHAW_Prometheus 0:a2603d7fa0ac 5 //#include "PixyLinkSPI.h"
ZHAW_Prometheus 0:a2603d7fa0ac 6 #include "PixyLinkI2C.h"
ZHAW_Prometheus 0:a2603d7fa0ac 7 //#include "PixyLinkUART.h"
ZHAW_Prometheus 0:a2603d7fa0ac 8
ZHAW_Prometheus 0:a2603d7fa0ac 9 struct Block {
ZHAW_Prometheus 0:a2603d7fa0ac 10 void print(Serial &pc) {
ZHAW_Prometheus 0:a2603d7fa0ac 11 pc.printf("sig: %d x: %d y: %d width: %d height: %d\n", signature, x, y, width, height);
ZHAW_Prometheus 0:a2603d7fa0ac 12 };
ZHAW_Prometheus 0:a2603d7fa0ac 13 uint16_t signature;
ZHAW_Prometheus 0:a2603d7fa0ac 14 uint16_t x;
ZHAW_Prometheus 0:a2603d7fa0ac 15 uint16_t y;
ZHAW_Prometheus 0:a2603d7fa0ac 16 uint16_t width;
ZHAW_Prometheus 0:a2603d7fa0ac 17 uint16_t height;
ZHAW_Prometheus 0:a2603d7fa0ac 18 };
ZHAW_Prometheus 0:a2603d7fa0ac 19
ZHAW_Prometheus 0:a2603d7fa0ac 20 class Pixy
ZHAW_Prometheus 0:a2603d7fa0ac 21 {
ZHAW_Prometheus 0:a2603d7fa0ac 22 public:
ZHAW_Prometheus 0:a2603d7fa0ac 23 enum LinkType {SPI, I2C, UART};
ZHAW_Prometheus 0:a2603d7fa0ac 24 Pixy(LinkType linkType, PinName mosi_sda_tx, PinName miso_scl_rx, PinName sclk = NC);
ZHAW_Prometheus 0:a2603d7fa0ac 25 ~Pixy();
ZHAW_Prometheus 0:a2603d7fa0ac 26 uint16_t getBlocks(uint16_t maxBlocks=1000);
ZHAW_Prometheus 0:a2603d7fa0ac 27 int8_t setServos(uint16_t s0, uint16_t s1);
ZHAW_Prometheus 0:a2603d7fa0ac 28 void setAddress(uint8_t addr);
ZHAW_Prometheus 0:a2603d7fa0ac 29 void setSerialOutput(Serial *pc);
ZHAW_Prometheus 0:a2603d7fa0ac 30
ZHAW_Prometheus 0:a2603d7fa0ac 31 Block *blocks;
ZHAW_Prometheus 0:a2603d7fa0ac 32
ZHAW_Prometheus 0:a2603d7fa0ac 33 private:
ZHAW_Prometheus 0:a2603d7fa0ac 34 static const uint8_t PIXY_INITIAL_ARRAYSIZE = 30;
ZHAW_Prometheus 0:a2603d7fa0ac 35 static const uint8_t PIXY_MAXIMUM_ARRAYSIZE = 130;
ZHAW_Prometheus 0:a2603d7fa0ac 36 static const uint16_t PIXY_START_WORD = 0xaa55;
ZHAW_Prometheus 0:a2603d7fa0ac 37 static const uint16_t PIXY_START_WORDX = 0x55aa;
ZHAW_Prometheus 0:a2603d7fa0ac 38 static const uint8_t PIXY_DEFAULT_ADDR = 0x54; // I2C
ZHAW_Prometheus 0:a2603d7fa0ac 39
ZHAW_Prometheus 0:a2603d7fa0ac 40 bool getStart();
ZHAW_Prometheus 0:a2603d7fa0ac 41 void resize();
ZHAW_Prometheus 0:a2603d7fa0ac 42
ZHAW_Prometheus 0:a2603d7fa0ac 43 bool skipStart;
ZHAW_Prometheus 0:a2603d7fa0ac 44 uint16_t blockCount;
ZHAW_Prometheus 0:a2603d7fa0ac 45 uint16_t blockArraySize;
ZHAW_Prometheus 0:a2603d7fa0ac 46
ZHAW_Prometheus 0:a2603d7fa0ac 47 PixyLink *m_link;
ZHAW_Prometheus 0:a2603d7fa0ac 48 Serial *pc;
ZHAW_Prometheus 0:a2603d7fa0ac 49 };
ZHAW_Prometheus 0:a2603d7fa0ac 50 #endif //TUIASI_PIXY_H