an SPI interface the cmu pixy camera
Dependents: robotic_fish_ver_4_9_pixy UMO
pixy.h
- Committer:
- sandwich
- Date:
- 2014-06-06
- Revision:
- 7:e57b18779bf1
- Parent:
- 6:4bf8d39fc5ce
- Child:
- 8:a915c5eff55a
File content as of revision 7:e57b18779bf1:
#pragma once #include "mbed.h" #include "rtos.h" #define INVALID_BLOCK 20 #define CENTER_X 320 #define CENTER_Y 100 #define NUM_BLOCKS 10 //a class to aid in SPI communication with the pixy camera //this details the object block format of returned data as described in //http://www.cmucam.org/projects/cmucam5/wiki/Pixy_Serial_Protocol //blatantly stole this from their code struct Block { uint16_t signature; uint16_t x; uint16_t y; uint16_t width; uint16_t height; }; class pixySPI { private: SPI spi; //SPI spi(p5, p6, p7); // mosi, miso, sclk short sync; //the block signature. 16 bits short readTwoBytesLSB(); void readNBytes(char* buf, int num); Block blocks[NUM_BLOCKS]; //where the blocks are stored int numBlocks; //amt int bestX; int bestY; public: pixySPI(PinName mosi,PinName miso,PinName sclk, int nBlocks); ~pixySPI(); void capture(Mutex* mutex); //fills in the blocks pointer char getRawData(); Block* getBlocks(); int getNumBlocks(); int getBestX(); int getBestY(); };