SPI read Pixi Cam V1

Revision:
4:478d4d9193a1
Parent:
3:66df7d295245
diff -r 66df7d295245 -r 478d4d9193a1 Pixy.h
--- a/Pixy.h	Mon Mar 14 18:53:43 2016 +0000
+++ b/Pixy.h	Mon Aug 23 11:26:37 2021 +0000
@@ -29,7 +29,7 @@
       * @param Serial* serialOut the optional serial output pointer to print out Pixy camera data
       * @param int arg an optional integer argument used for custom implementations of the Pixy library
       */
-    PixySPI(SPI* spi, Serial* serialOut = NULL, uint16_t arg = PIXY_DEFAULT_ARGVAL) :
+    PixySPI(SPI* spi, BufferedSerial* serialOut = NULL, uint16_t arg = PIXY_DEFAULT_ARGVAL) :
         TPixy<PixyInterfaceSPI>((new PixyInterfaceSPI(spi)), serialOut, arg) {}
 };
 
@@ -70,12 +70,12 @@
   * @param pixy the pointer to the pixy object to run the demo on
   * @param serial the optional serial pointer to display output to
   */
-template <class TPixyInterface> void runPanTiltDemo(TPixy<TPixyInterface>* pixy, Serial* serial = NULL)
+template <class TPixyInterface> void runPanTiltDemo(TPixy<TPixyInterface>* pixy, BufferedSerial* serial = NULL)
 {
     ServoLoop panLoop(-150, -300);
     ServoLoop tiltLoop(200, 250);
-    if (serial != NULL) {
-        serial->printf("Starting...\n");
+   {
+        printf("Starting...\n");
     }   
     static int i = 0;
     int j;
@@ -85,20 +85,12 @@
     while(true) {
         blocks = pixy->getBlocks();
         if (blocks) {
-            panError = X_CENTER - pixy->blocks[0].x;
-            tiltError = pixy->blocks[0].y - Y_CENTER;
-
-            panLoop.update(panError);
-            tiltLoop.update(tiltError);
-
-            pixy->setServos(panLoop.m_pos, tiltLoop.m_pos);
             i++;
-
-            if (i % 50 == 0 && serial != NULL) {
-                serial->printf("Detected %d:\n", blocks);
+            if (i % 5 == 0 ) {
+                printf("Detected %d:\n", blocks);
                 //toPC.printf(buf);
                 for (j = 0; j < blocks; j++) {
-                    serial->printf("  block %d: ", j);
+                    printf("  block %d: ", j);
                     pixy->printBlock(pixy->blocks[j]);
                 }
             }