Prometheus / Pixy

Dependents:   PixyTest PixyTest

Committer:
ZHAW_Prometheus
Date:
Wed May 17 07:37:43 2017 +0000
Revision:
2:c3a866b20784
Parent:
0:a2603d7fa0ac
Vers. 17.05.2017

Who changed what in which revision?

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