Mattéo
Dependencies: mbed Pixy2_Library2
Diff: main.cpp
- Revision:
- 0:fc353d12d2b1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 15 16:50:51 2020 +0000 @@ -0,0 +1,111 @@ +#include "mbed.h" +#include "Pixy2_Library.h" +#define ADRESSE 0xa8 + +Serial pc(USBTX,USBRX); + +int state = 3; +int X,X2,X3; +int Y,Y2,Y3; +int W,W2,W3; +int H,H2,H3; +int S,S2,S3; +int I,I2,I3; + + +int main() +{ + int A,A2,A3; + pc.printf("Bienvenue sur Pixy2\n\r"); + + Pixy2_Library Cam1(p28,p27,ADRESSE); + + //Cam1.Pixy2_WhiteLED(true); + + while(1) { + + switch(state) { + case 0 : + /*Cam1.Pixy2_SetServo(0,0); + wait(0.5); + Cam1.Pixy2_SetServo(500,0); + wait(0.5);*/ + break; + case 1 : + pc.printf("_______________X positions____________________\n\r"); + X = Cam1.Pixy2_GetBlock('x',1); + X2 = Cam1.Pixy2_GetBlock('x',2); + X3 = Cam1.Pixy2_GetBlock('x',3); + pc.printf("Position X = %d\n\r", X); + pc.printf("Position X2 = %d\n\r", X2); + pc.printf("Position X3 = %d\n\r", X3); + break; + case 2 : + pc.printf("_______________Y positions____________________\n\r"); + Y = Cam1.Pixy2_GetBlock('y',1); + Y2 = Cam1.Pixy2_GetBlock('y',2); + Y3 = Cam1.Pixy2_GetBlock('y',3); + pc.printf("Position Y = %d\n\r", Y); + pc.printf("Position Y2 = %d\n\r", Y2); + pc.printf("Position Y3 = %d\n\r", Y3); + break; + case 3 : + pc.printf("__________________ALL___________________________\n\r"); + X = Cam1.Pixy2_GetBlock('x',1); + Y = Cam1.Pixy2_GetBlock('y',1); + W = Cam1.Pixy2_GetBlock('w',1); + H = Cam1.Pixy2_GetBlock('h',1); + S = Cam1.Pixy2_GetBlock('s',1); + //A = Cam1.Pixy2_GetBlock('a',1); + //I = Cam1.Pixy2_GetBlock('i',1); + + /*X2 = Cam1.Pixy2_GetBlock('x',2); + Y2 = Cam1.Pixy2_GetBlock('y',2); + W2 = Cam1.Pixy2_GetBlock('w',2); + H2 = Cam1.Pixy2_GetBlock('h',2); + S2 = Cam1.Pixy2_GetBlock('s',2); + A2 = Cam1.Pixy2_GetBlock('a',2); + I2 = Cam1.Pixy2_GetBlock('i',2); + + X3 = Cam1.Pixy2_GetBlock('x',3); + Y3 = Cam1.Pixy2_GetBlock('y',3); + W3 = Cam1.Pixy2_GetBlock('w',3); + H3 = Cam1.Pixy2_GetBlock('h',3); + S3 = Cam1.Pixy2_GetBlock('s',3); + A3 = Cam1.Pixy2_GetBlock('a',3); + I3 = Cam1.Pixy2_GetBlock('i',3);*/ + + pc.printf("Signature du block = %d\n\r", S); + pc.printf("Position X = %d\n\r", X); + pc.printf("Position Y = %d\n\r", Y); + pc.printf("Largeur = %d\n\r", W); + pc.printf("Hauteur = %d\n\r", H); + //pc.printf("Angle code-couleur = %d\n\r", A); + //pc.printf("Indice de suivi du block = %d\n\r", I); + + + /* pc.printf("______________________________\n\r"); + pc.printf("Signature du block 2 = %d\n\r", S2); + pc.printf("Position X2 = %d\n\r", X2); + pc.printf("Position Y2 = %d\n\r", Y2); + pc.printf("Largeur 2 = %d\n\r", W2); + pc.printf("Hauteur 2 = %d\n\r", H2); + pc.printf("Angle code-couleur 2 = %d\n\r", A2); + pc.printf("Indice de suivi du block 2 = %d\n\r", I2); + + + pc.printf("______________________________\n\r"); + pc.printf("Signature du block 3 = %d\n\r", S3); + pc.printf("Position X3 = %d\n\r", X3); + pc.printf("Position Y3 = %d\n\r", Y3); + pc.printf("Largeur 3 = %d\n\r", W3); + pc.printf("Hauteur 3 = %d\n\r", H3); + pc.printf("Angle code-couleur 3 = %d\n\r", A3); + pc.printf("Indice de suivi du block 3 = %d\n\r", I3);*/ + break; + } + + wait(0.3); + } +} +