pixy Libari 2

Dependents:   PES PES1 PES4 PES3

Revision:
1:a57585d5e81b
Parent:
0:ed8dc4531ac1
Child:
2:b0a6783fb615
--- a/Pixy.cpp	Sun Nov 16 11:52:55 2014 +0000
+++ b/Pixy.cpp	Wed Mar 29 12:34:18 2017 +0000
@@ -1,23 +1,15 @@
 #include "Pixy.h"
 
-Pixy::Pixy(Pixy::LinkType linkType, PinName mosi_sda_tx, PinName miso_scl_rx, PinName sclk)
+
+Pixy::Pixy(PinName mosi_sda_tx, PinName miso_scl_rx)
 {
-    switch (linkType) {
-        case SPI:
-            m_link = new PixyLinkSPI(mosi_sda_tx, miso_scl_rx, sclk);
-            break;
-        case I2C:
-            m_link = new PixyLinkI2C(mosi_sda_tx, miso_scl_rx);
-            break;
-        case UART:
-            m_link = new PixyLinkUART(mosi_sda_tx, miso_scl_rx);
-            break;
-    };
+    m_link = new PixyLinkI2C(mosi_sda_tx, miso_scl_rx);
     pc = 0;
     skipStart = false;
     blockCount = 0;
     blockArraySize = PIXY_INITIAL_ARRAYSIZE;
     blocks = new Block[blockArraySize];
+
 }
 
 Pixy::~Pixy()
@@ -42,8 +34,8 @@
         checksum = m_link->getWord();
         if (checksum == PIXY_START_WORD) { // we've reached the beginning of the next frame
             skipStart = true;
-            //if (pc)
-            //  pc->printf("skip\n\r");
+        //  if (pc)
+        //  pc->printf("skip\n\r");
             return blockCount;
         } else if (checksum == 0)
             return blockCount;
@@ -59,8 +51,10 @@
             *((uint16_t *)block + i) = w;
         }
 
-        if (checksum == sum)
+        if (checksum == sum){
             blockCount++;
+            //w = m_link->getWord();
+            }
         else if (pc)
             pc->printf("cs error\n\r");
 
@@ -71,18 +65,6 @@
     return blockCount;
 }
 
-int8_t Pixy::setServos(uint16_t s0, uint16_t s1)
-{
-    uint8_t outBuf[6];
-
-    outBuf[0] = 0x00;
-    outBuf[1] = 0xff;
-    *(uint16_t *)(outBuf + 2) = s0;
-    *(uint16_t *)(outBuf + 4) = s1;
-
-    return m_link->send(outBuf, 6);
-}
-
 void Pixy::setAddress(uint8_t addr)
 {
     m_link->setAddress(addr);