Mattéo
Dependencies: mbed Pixy2_Library2
main.cpp@1:b91387b1d393, 2020-05-15 (annotated)
- Committer:
- benbrou06
- Date:
- Fri May 15 16:52:41 2020 +0000
- Revision:
- 1:b91387b1d393
- Parent:
- 0:fc353d12d2b1
Test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
benbrou06 | 0:fc353d12d2b1 | 1 | #include "mbed.h" |
benbrou06 | 0:fc353d12d2b1 | 2 | #include "Pixy2_Library.h" |
benbrou06 | 0:fc353d12d2b1 | 3 | #define ADRESSE 0xa8 |
benbrou06 | 0:fc353d12d2b1 | 4 | |
benbrou06 | 0:fc353d12d2b1 | 5 | Serial pc(USBTX,USBRX); |
benbrou06 | 0:fc353d12d2b1 | 6 | |
benbrou06 | 0:fc353d12d2b1 | 7 | int state = 3; |
benbrou06 | 0:fc353d12d2b1 | 8 | int X,X2,X3; |
benbrou06 | 0:fc353d12d2b1 | 9 | int Y,Y2,Y3; |
benbrou06 | 0:fc353d12d2b1 | 10 | int W,W2,W3; |
benbrou06 | 0:fc353d12d2b1 | 11 | int H,H2,H3; |
benbrou06 | 0:fc353d12d2b1 | 12 | int S,S2,S3; |
benbrou06 | 0:fc353d12d2b1 | 13 | int I,I2,I3; |
benbrou06 | 0:fc353d12d2b1 | 14 | |
benbrou06 | 0:fc353d12d2b1 | 15 | |
benbrou06 | 0:fc353d12d2b1 | 16 | int main() |
benbrou06 | 0:fc353d12d2b1 | 17 | { |
benbrou06 | 0:fc353d12d2b1 | 18 | int A,A2,A3; |
benbrou06 | 0:fc353d12d2b1 | 19 | pc.printf("Bienvenue sur Pixy2\n\r"); |
benbrou06 | 0:fc353d12d2b1 | 20 | |
benbrou06 | 0:fc353d12d2b1 | 21 | Pixy2_Library Cam1(p28,p27,ADRESSE); |
benbrou06 | 0:fc353d12d2b1 | 22 | |
benbrou06 | 0:fc353d12d2b1 | 23 | //Cam1.Pixy2_WhiteLED(true); |
benbrou06 | 0:fc353d12d2b1 | 24 | |
benbrou06 | 0:fc353d12d2b1 | 25 | while(1) { |
benbrou06 | 0:fc353d12d2b1 | 26 | |
benbrou06 | 0:fc353d12d2b1 | 27 | switch(state) { |
benbrou06 | 0:fc353d12d2b1 | 28 | case 0 : |
benbrou06 | 0:fc353d12d2b1 | 29 | /*Cam1.Pixy2_SetServo(0,0); |
benbrou06 | 0:fc353d12d2b1 | 30 | wait(0.5); |
benbrou06 | 0:fc353d12d2b1 | 31 | Cam1.Pixy2_SetServo(500,0); |
benbrou06 | 0:fc353d12d2b1 | 32 | wait(0.5);*/ |
benbrou06 | 0:fc353d12d2b1 | 33 | break; |
benbrou06 | 0:fc353d12d2b1 | 34 | case 1 : |
benbrou06 | 0:fc353d12d2b1 | 35 | pc.printf("_______________X positions____________________\n\r"); |
benbrou06 | 0:fc353d12d2b1 | 36 | X = Cam1.Pixy2_GetBlock('x',1); |
benbrou06 | 0:fc353d12d2b1 | 37 | X2 = Cam1.Pixy2_GetBlock('x',2); |
benbrou06 | 0:fc353d12d2b1 | 38 | X3 = Cam1.Pixy2_GetBlock('x',3); |
benbrou06 | 0:fc353d12d2b1 | 39 | pc.printf("Position X = %d\n\r", X); |
benbrou06 | 0:fc353d12d2b1 | 40 | pc.printf("Position X2 = %d\n\r", X2); |
benbrou06 | 0:fc353d12d2b1 | 41 | pc.printf("Position X3 = %d\n\r", X3); |
benbrou06 | 0:fc353d12d2b1 | 42 | break; |
benbrou06 | 0:fc353d12d2b1 | 43 | case 2 : |
benbrou06 | 0:fc353d12d2b1 | 44 | pc.printf("_______________Y positions____________________\n\r"); |
benbrou06 | 0:fc353d12d2b1 | 45 | Y = Cam1.Pixy2_GetBlock('y',1); |
benbrou06 | 0:fc353d12d2b1 | 46 | Y2 = Cam1.Pixy2_GetBlock('y',2); |
benbrou06 | 0:fc353d12d2b1 | 47 | Y3 = Cam1.Pixy2_GetBlock('y',3); |
benbrou06 | 0:fc353d12d2b1 | 48 | pc.printf("Position Y = %d\n\r", Y); |
benbrou06 | 0:fc353d12d2b1 | 49 | pc.printf("Position Y2 = %d\n\r", Y2); |
benbrou06 | 0:fc353d12d2b1 | 50 | pc.printf("Position Y3 = %d\n\r", Y3); |
benbrou06 | 0:fc353d12d2b1 | 51 | break; |
benbrou06 | 0:fc353d12d2b1 | 52 | case 3 : |
benbrou06 | 0:fc353d12d2b1 | 53 | pc.printf("__________________ALL___________________________\n\r"); |
benbrou06 | 0:fc353d12d2b1 | 54 | X = Cam1.Pixy2_GetBlock('x',1); |
benbrou06 | 0:fc353d12d2b1 | 55 | Y = Cam1.Pixy2_GetBlock('y',1); |
benbrou06 | 0:fc353d12d2b1 | 56 | W = Cam1.Pixy2_GetBlock('w',1); |
benbrou06 | 0:fc353d12d2b1 | 57 | H = Cam1.Pixy2_GetBlock('h',1); |
benbrou06 | 0:fc353d12d2b1 | 58 | S = Cam1.Pixy2_GetBlock('s',1); |
benbrou06 | 0:fc353d12d2b1 | 59 | //A = Cam1.Pixy2_GetBlock('a',1); |
benbrou06 | 0:fc353d12d2b1 | 60 | //I = Cam1.Pixy2_GetBlock('i',1); |
benbrou06 | 0:fc353d12d2b1 | 61 | |
benbrou06 | 0:fc353d12d2b1 | 62 | /*X2 = Cam1.Pixy2_GetBlock('x',2); |
benbrou06 | 0:fc353d12d2b1 | 63 | Y2 = Cam1.Pixy2_GetBlock('y',2); |
benbrou06 | 0:fc353d12d2b1 | 64 | W2 = Cam1.Pixy2_GetBlock('w',2); |
benbrou06 | 0:fc353d12d2b1 | 65 | H2 = Cam1.Pixy2_GetBlock('h',2); |
benbrou06 | 0:fc353d12d2b1 | 66 | S2 = Cam1.Pixy2_GetBlock('s',2); |
benbrou06 | 0:fc353d12d2b1 | 67 | A2 = Cam1.Pixy2_GetBlock('a',2); |
benbrou06 | 0:fc353d12d2b1 | 68 | I2 = Cam1.Pixy2_GetBlock('i',2); |
benbrou06 | 0:fc353d12d2b1 | 69 | |
benbrou06 | 0:fc353d12d2b1 | 70 | X3 = Cam1.Pixy2_GetBlock('x',3); |
benbrou06 | 0:fc353d12d2b1 | 71 | Y3 = Cam1.Pixy2_GetBlock('y',3); |
benbrou06 | 0:fc353d12d2b1 | 72 | W3 = Cam1.Pixy2_GetBlock('w',3); |
benbrou06 | 0:fc353d12d2b1 | 73 | H3 = Cam1.Pixy2_GetBlock('h',3); |
benbrou06 | 0:fc353d12d2b1 | 74 | S3 = Cam1.Pixy2_GetBlock('s',3); |
benbrou06 | 0:fc353d12d2b1 | 75 | A3 = Cam1.Pixy2_GetBlock('a',3); |
benbrou06 | 0:fc353d12d2b1 | 76 | I3 = Cam1.Pixy2_GetBlock('i',3);*/ |
benbrou06 | 0:fc353d12d2b1 | 77 | |
benbrou06 | 0:fc353d12d2b1 | 78 | pc.printf("Signature du block = %d\n\r", S); |
benbrou06 | 0:fc353d12d2b1 | 79 | pc.printf("Position X = %d\n\r", X); |
benbrou06 | 0:fc353d12d2b1 | 80 | pc.printf("Position Y = %d\n\r", Y); |
benbrou06 | 0:fc353d12d2b1 | 81 | pc.printf("Largeur = %d\n\r", W); |
benbrou06 | 0:fc353d12d2b1 | 82 | pc.printf("Hauteur = %d\n\r", H); |
benbrou06 | 0:fc353d12d2b1 | 83 | //pc.printf("Angle code-couleur = %d\n\r", A); |
benbrou06 | 0:fc353d12d2b1 | 84 | //pc.printf("Indice de suivi du block = %d\n\r", I); |
benbrou06 | 0:fc353d12d2b1 | 85 | |
benbrou06 | 0:fc353d12d2b1 | 86 | |
benbrou06 | 0:fc353d12d2b1 | 87 | /* pc.printf("______________________________\n\r"); |
benbrou06 | 0:fc353d12d2b1 | 88 | pc.printf("Signature du block 2 = %d\n\r", S2); |
benbrou06 | 0:fc353d12d2b1 | 89 | pc.printf("Position X2 = %d\n\r", X2); |
benbrou06 | 0:fc353d12d2b1 | 90 | pc.printf("Position Y2 = %d\n\r", Y2); |
benbrou06 | 0:fc353d12d2b1 | 91 | pc.printf("Largeur 2 = %d\n\r", W2); |
benbrou06 | 0:fc353d12d2b1 | 92 | pc.printf("Hauteur 2 = %d\n\r", H2); |
benbrou06 | 0:fc353d12d2b1 | 93 | pc.printf("Angle code-couleur 2 = %d\n\r", A2); |
benbrou06 | 0:fc353d12d2b1 | 94 | pc.printf("Indice de suivi du block 2 = %d\n\r", I2); |
benbrou06 | 0:fc353d12d2b1 | 95 | |
benbrou06 | 0:fc353d12d2b1 | 96 | |
benbrou06 | 0:fc353d12d2b1 | 97 | pc.printf("______________________________\n\r"); |
benbrou06 | 0:fc353d12d2b1 | 98 | pc.printf("Signature du block 3 = %d\n\r", S3); |
benbrou06 | 0:fc353d12d2b1 | 99 | pc.printf("Position X3 = %d\n\r", X3); |
benbrou06 | 0:fc353d12d2b1 | 100 | pc.printf("Position Y3 = %d\n\r", Y3); |
benbrou06 | 0:fc353d12d2b1 | 101 | pc.printf("Largeur 3 = %d\n\r", W3); |
benbrou06 | 0:fc353d12d2b1 | 102 | pc.printf("Hauteur 3 = %d\n\r", H3); |
benbrou06 | 0:fc353d12d2b1 | 103 | pc.printf("Angle code-couleur 3 = %d\n\r", A3); |
benbrou06 | 0:fc353d12d2b1 | 104 | pc.printf("Indice de suivi du block 3 = %d\n\r", I3);*/ |
benbrou06 | 0:fc353d12d2b1 | 105 | break; |
benbrou06 | 0:fc353d12d2b1 | 106 | } |
benbrou06 | 0:fc353d12d2b1 | 107 | |
benbrou06 | 0:fc353d12d2b1 | 108 | wait(0.3); |
benbrou06 | 0:fc353d12d2b1 | 109 | } |
benbrou06 | 0:fc353d12d2b1 | 110 | } |
benbrou06 | 0:fc353d12d2b1 | 111 |