Prometheus / Pixy

Dependents:   PixyTest PixyTest

Committer:
ZHAW_Prometheus
Date:
Wed May 10 08:54:01 2017 +0000
Revision:
1:0683e3163119
Parent:
0:a2603d7fa0ac
Pixy_Lib_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 1:0683e3163119 7 #include "cstdlib"
ZHAW_Prometheus 0:a2603d7fa0ac 8 //#include "PixyLinkUART.h"
ZHAW_Prometheus 0:a2603d7fa0ac 9
ZHAW_Prometheus 0:a2603d7fa0ac 10 struct Block {
ZHAW_Prometheus 0:a2603d7fa0ac 11 void print(Serial &pc) {
ZHAW_Prometheus 0:a2603d7fa0ac 12 pc.printf("sig: %d x: %d y: %d width: %d height: %d\n", signature, x, y, width, height);
ZHAW_Prometheus 0:a2603d7fa0ac 13 };
ZHAW_Prometheus 0:a2603d7fa0ac 14 uint16_t signature;
ZHAW_Prometheus 0:a2603d7fa0ac 15 uint16_t x;
ZHAW_Prometheus 0:a2603d7fa0ac 16 uint16_t y;
ZHAW_Prometheus 0:a2603d7fa0ac 17 uint16_t width;
ZHAW_Prometheus 0:a2603d7fa0ac 18 uint16_t height;
ZHAW_Prometheus 0:a2603d7fa0ac 19 };
ZHAW_Prometheus 0:a2603d7fa0ac 20
ZHAW_Prometheus 0:a2603d7fa0ac 21 class Pixy
ZHAW_Prometheus 0:a2603d7fa0ac 22 {
ZHAW_Prometheus 0:a2603d7fa0ac 23 public:
ZHAW_Prometheus 0:a2603d7fa0ac 24 enum LinkType {SPI, I2C, UART};
ZHAW_Prometheus 0:a2603d7fa0ac 25 Pixy(LinkType linkType, PinName mosi_sda_tx, PinName miso_scl_rx, PinName sclk = NC);
ZHAW_Prometheus 0:a2603d7fa0ac 26 ~Pixy();
ZHAW_Prometheus 0:a2603d7fa0ac 27 uint16_t getBlocks(uint16_t maxBlocks=1000);
ZHAW_Prometheus 0:a2603d7fa0ac 28 int8_t setServos(uint16_t s0, uint16_t s1);
ZHAW_Prometheus 0:a2603d7fa0ac 29 void setAddress(uint8_t addr);
ZHAW_Prometheus 0:a2603d7fa0ac 30 void setSerialOutput(Serial *pc);
ZHAW_Prometheus 0:a2603d7fa0ac 31
ZHAW_Prometheus 0:a2603d7fa0ac 32 Block *blocks;
ZHAW_Prometheus 0:a2603d7fa0ac 33
ZHAW_Prometheus 0:a2603d7fa0ac 34 private:
ZHAW_Prometheus 0:a2603d7fa0ac 35 static const uint8_t PIXY_INITIAL_ARRAYSIZE = 30;
ZHAW_Prometheus 0:a2603d7fa0ac 36 static const uint8_t PIXY_MAXIMUM_ARRAYSIZE = 130;
ZHAW_Prometheus 0:a2603d7fa0ac 37 static const uint16_t PIXY_START_WORD = 0xaa55;
ZHAW_Prometheus 0:a2603d7fa0ac 38 static const uint16_t PIXY_START_WORDX = 0x55aa;
ZHAW_Prometheus 0:a2603d7fa0ac 39 static const uint8_t PIXY_DEFAULT_ADDR = 0x54; // I2C
ZHAW_Prometheus 0:a2603d7fa0ac 40
ZHAW_Prometheus 0:a2603d7fa0ac 41 bool getStart();
ZHAW_Prometheus 0:a2603d7fa0ac 42 void resize();
ZHAW_Prometheus 0:a2603d7fa0ac 43
ZHAW_Prometheus 0:a2603d7fa0ac 44 bool skipStart;
ZHAW_Prometheus 0:a2603d7fa0ac 45 uint16_t blockCount;
ZHAW_Prometheus 0:a2603d7fa0ac 46 uint16_t blockArraySize;
ZHAW_Prometheus 0:a2603d7fa0ac 47
ZHAW_Prometheus 0:a2603d7fa0ac 48 PixyLink *m_link;
ZHAW_Prometheus 0:a2603d7fa0ac 49 Serial *pc;
ZHAW_Prometheus 0:a2603d7fa0ac 50 };
ZHAW_Prometheus 0:a2603d7fa0ac 51 #endif //TUIASI_PIXY_H