SPI read Pixi Cam V1
Embed:
(wiki syntax)
Show/hide line numbers
pixyUART.h
00001 #pragma once 00002 #include "mbed.h" 00003 00004 #define INVALID_BLOCK 20 00005 #define CENTER_X 160 00006 #define CENTER_Y 100 00007 #define NUM_BLOCKS 10 00008 //a class to aid in SPI communication with the pixy camera 00009 00010 //this details the object block format of returned data as described in 00011 //http://www.cmucam.org/projects/cmucam5/wiki/Pixy_Serial_Protocol 00012 00013 //blatantly stole this from their code 00014 struct Block 00015 { 00016 uint16_t signature; 00017 uint16_t x; 00018 uint16_t y; 00019 uint16_t width; 00020 uint16_t height; 00021 }; 00022 00023 class pixyUART 00024 { 00025 private: 00026 BufferedSerial *uart; 00027 short sync; //the block signature. 16 bits 00028 int8_t readTwoBytesLSB(uint16_t *); 00029 void readNBytes(char* buf, int num); 00030 int numBlocks; //amt 00031 uint8_t buffer[200]; 00032 public: 00033 pixyUART(BufferedSerial * ); 00034 ~pixyUART(); 00035 void capture(); //fills in the blocks pointer 00036 Block* getBlocks(); 00037 int captured_blocks; 00038 Block blocks[NUM_BLOCKS]; //where the blocks are stored 00039 };
Generated on Fri Sep 16 2022 13:59:14 by
1.7.2