SPI read Pixi Cam V1

Revision:
5:d109b094d4bb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pixyUART.h	Sat Aug 28 13:03:58 2021 +0000
@@ -0,0 +1,39 @@
+#pragma once
+#include "mbed.h"
+ 
+#define INVALID_BLOCK 20
+#define CENTER_X 160
+#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 pixyUART
+{
+private:
+    BufferedSerial *uart;
+    short sync; //the block signature. 16 bits
+    int8_t readTwoBytesLSB(uint16_t *);
+    void readNBytes(char* buf, int num);
+    int numBlocks; //amt
+    uint8_t buffer[200];
+public:
+    pixyUART(BufferedSerial * );
+    ~pixyUART();
+    void capture(); //fills in the blocks pointer
+    Block* getBlocks();
+    int captured_blocks;
+    Block blocks[NUM_BLOCKS]; //where the blocks are stored
+};
\ No newline at end of file