Port of Arduino Pixy Cmucam5 library.

Dependents:   __cam1

Fork of pixy by Arcadie Cracan

Committer:
vermaelen
Date:
Fri Mar 23 15:47:32 2018 +0000
Revision:
1:6ab45d67f36d
Parent:
0:ed8dc4531ac1
good

Who changed what in which revision?

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