Homologation Cachan
Fork of TPixy-Interface by
Diff: Pixy.h
- Revision:
- 4:ee635fc62b6e
- Parent:
- 3:66df7d295245
--- a/Pixy.h Mon Mar 14 18:53:43 2016 +0000 +++ b/Pixy.h Sat Jun 09 03:56:25 2018 +0000 @@ -7,19 +7,6 @@ #define X_CENTER ((PIXY_MAX_X-PIXY_MIN_X)/2) #define Y_CENTER ((PIXY_MAX_Y-PIXY_MIN_Y)/2) -/** The SPI Pixy interface for the Pixy camera - * @code - * #include "Pixy.h" - * Serial serial(USBTX, USBRX); - * SPI spi(p5, p6, p7); - * PixySPI pixy(&spi, &serial); - * - * int main() { - * runPanTiltDemo(); - * } - * @endcode - */ - class PixySPI : public TPixy<PixyInterfaceSPI> { public: @@ -33,17 +20,6 @@ TPixy<PixyInterfaceSPI>((new PixyInterfaceSPI(spi)), serialOut, arg) {} }; - -/* Not Implemented */ -/* -class PixyI2C : TPixy<PixyInterfaceI2C> { - public: - PixyI2C(I2C* i2c, Serial* serialOut = NULL, uint16_t arg = PIXY_DEFAULT_ARGVAL) : i2cInterface(i2c), TPixy<PixyInterfaceI2C>(i2cInterface, serialOut, arg); - private: - TPixyInterface<I2C>* i2cInterface; - }; - */ - class ServoLoop { public: @@ -64,45 +40,4 @@ int32_t m_pgain; int32_t m_dgain; }; - -/** Basic Pan/Tilt Demo code - * Runs the Pan/Tilt demo code - * @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) -{ - ServoLoop panLoop(-150, -300); - ServoLoop tiltLoop(200, 250); - if (serial != NULL) { - serial->printf("Starting...\n"); - } - static int i = 0; - int j; - uint16_t blocks; - int32_t panError, tiltError; - pixy->init(); - 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); - //toPC.printf(buf); - for (j = 0; j < blocks; j++) { - serial->printf(" block %d: ", j); - pixy->printBlock(pixy->blocks[j]); - } - } - } - } -} #endif \ No newline at end of file