coucou

Dependencies:   RoboClaw mbed

Fork of Robot2016_2-0 by ARES

Committer:
sype
Date:
Mon Apr 25 12:38:58 2016 +0000
Revision:
47:5658af4e5149
Parent:
45:b53ae54062c6
Child:
48:03da1aead032
ajout de la carte boutons ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sype 41:b5a2fbc20beb 1 #include "func.h"
sype 41:b5a2fbc20beb 2
sype 41:b5a2fbc20beb 3 void pressed(void)
sype 41:b5a2fbc20beb 4 {
sype 47:5658af4e5149 5 if(SIMON_i==0) {
sype 47:5658af4e5149 6 roboclaw.ForwardM1(0);
sype 47:5658af4e5149 7 roboclaw.ForwardM2(0);
sype 47:5658af4e5149 8 SIMON_i++;
sype 41:b5a2fbc20beb 9 }
sype 41:b5a2fbc20beb 10 }
sype 41:b5a2fbc20beb 11
sype 41:b5a2fbc20beb 12 void unpressed(void)
sype 41:b5a2fbc20beb 13 {
sype 47:5658af4e5149 14 if(SIMON_i==1) {
sype 47:5658af4e5149 15 SIMON_i--;
sype 41:b5a2fbc20beb 16 }
sype 41:b5a2fbc20beb 17 }
sype 41:b5a2fbc20beb 18
sype 41:b5a2fbc20beb 19 void ELpressed(void)
sype 41:b5a2fbc20beb 20 {
sype 47:5658af4e5149 21 bleu = 1;
sype 47:5658af4e5149 22 SIMON_EL = true;
sype 41:b5a2fbc20beb 23 }
sype 41:b5a2fbc20beb 24 void ELunpressed(void)
sype 41:b5a2fbc20beb 25 {
sype 47:5658af4e5149 26 bleu = 0;
sype 47:5658af4e5149 27 SIMON_EL = false;
sype 41:b5a2fbc20beb 28 }
sype 41:b5a2fbc20beb 29
sype 41:b5a2fbc20beb 30 void EZpressed(void)
sype 41:b5a2fbc20beb 31 {
sype 47:5658af4e5149 32 blanc = 1;
sype 47:5658af4e5149 33 SIMON_EZ = true;
sype 41:b5a2fbc20beb 34 }
sype 41:b5a2fbc20beb 35 void EZunpressed(void)
sype 41:b5a2fbc20beb 36 {
sype 47:5658af4e5149 37 blanc = 0;
sype 47:5658af4e5149 38 SIMON_EZ = false;
sype 41:b5a2fbc20beb 39 }
sype 41:b5a2fbc20beb 40
sype 41:b5a2fbc20beb 41 void ERpressed(void)
sype 41:b5a2fbc20beb 42 {
sype 47:5658af4e5149 43 rouge = 1;
sype 47:5658af4e5149 44 SIMON_ER = true;
sype 41:b5a2fbc20beb 45 }
sype 41:b5a2fbc20beb 46 void ERunpressed(void)
sype 41:b5a2fbc20beb 47 {
sype 47:5658af4e5149 48 rouge = 0;
sype 47:5658af4e5149 49 SIMON_ER = 0;
sype 41:b5a2fbc20beb 50 }
sype 41:b5a2fbc20beb 51
sype 41:b5a2fbc20beb 52 void JPO(void)
sype 41:b5a2fbc20beb 53 {
sype 41:b5a2fbc20beb 54 char c = logger.getc();
sype 41:b5a2fbc20beb 55 if(c=='z') {
sype 47:5658af4e5149 56 if (SIMON_state != 1) {
sype 47:5658af4e5149 57 SIMON_state = 1;
sype 41:b5a2fbc20beb 58 logger.printf("Avant (Z) \r\n");
sype 47:5658af4e5149 59 roboclaw.SpeedAccelM1(accel_angle, vitesse_angle);
sype 47:5658af4e5149 60 roboclaw.SpeedAccelM2(accel_angle, vitesse_angle);
sype 41:b5a2fbc20beb 61 }
sype 41:b5a2fbc20beb 62 } else if(c == 's') {
sype 47:5658af4e5149 63 if (SIMON_state != 2) {
sype 47:5658af4e5149 64 SIMON_state = 2;
sype 41:b5a2fbc20beb 65 logger.printf("Stop (S) \r\n");
sype 47:5658af4e5149 66 roboclaw.SpeedAccelM1(accel_angle, 0);
sype 47:5658af4e5149 67 roboclaw.SpeedAccelM2(accel_angle, 0);
sype 41:b5a2fbc20beb 68 }
sype 41:b5a2fbc20beb 69 } else if(c == 'd') {
sype 47:5658af4e5149 70 if (SIMON_state != 3) {
sype 47:5658af4e5149 71 SIMON_state = 3;
sype 41:b5a2fbc20beb 72 logger.printf("Droite (D) \r\n");
sype 47:5658af4e5149 73 roboclaw.SpeedAccelM1(accel_angle, -vitesse_angle);
sype 47:5658af4e5149 74 roboclaw.SpeedAccelM2(accel_angle, vitesse_angle);
sype 41:b5a2fbc20beb 75 }
sype 41:b5a2fbc20beb 76 } else if(c == 'q') {
sype 47:5658af4e5149 77 if (SIMON_state != 4) {
sype 47:5658af4e5149 78 SIMON_state = 4;
sype 41:b5a2fbc20beb 79 logger.printf("Gauche (Q)\r\n");
sype 47:5658af4e5149 80 roboclaw.SpeedAccelM1(accel_angle, vitesse_angle);
sype 47:5658af4e5149 81 roboclaw.SpeedAccelM2(accel_angle, -vitesse_angle);
sype 41:b5a2fbc20beb 82 }
sype 41:b5a2fbc20beb 83 } else if(c == 'x') {
sype 47:5658af4e5149 84 if (SIMON_state != 5) {
sype 47:5658af4e5149 85 SIMON_state = 5;
sype 47:5658af4e5149 86 roboclaw.SpeedAccelM1(accel_angle, -vitesse_angle);
sype 47:5658af4e5149 87 roboclaw.SpeedAccelM2(accel_angle, -vitesse_angle);
sype 41:b5a2fbc20beb 88 }
sype 41:b5a2fbc20beb 89 } else {
sype 47:5658af4e5149 90 if (SIMON_state != 0) {
sype 47:5658af4e5149 91 roboclaw.SpeedAccelM1M2(accel_angle, 0, accel_angle, 0);
sype 47:5658af4e5149 92 SIMON_state = 0;
sype 41:b5a2fbc20beb 93 }
sype 41:b5a2fbc20beb 94 }
sype 41:b5a2fbc20beb 95 }
sype 41:b5a2fbc20beb 96
sype 41:b5a2fbc20beb 97 void goHome(void)
sype 41:b5a2fbc20beb 98 {
sype 47:5658af4e5149 99 //while(EZ==false) ZMot.step(1, 0, DELAY);
sype 47:5658af4e5149 100 while(SIMON_ER==false) RMot.step(1, 0, DELAY);
sype 47:5658af4e5149 101 RMot.step(10, 1, DELAY+0.01);
sype 41:b5a2fbc20beb 102 RMot.step(5, 0, DELAY);
sype 47:5658af4e5149 103 while(SIMON_EL==false) LMot.step(1, 0, DELAY);
sype 47:5658af4e5149 104 LMot.step(10, 1, DELAY+0.01);
sype 41:b5a2fbc20beb 105 LMot.step(5, 0, DELAY);
sype 41:b5a2fbc20beb 106 }
sype 41:b5a2fbc20beb 107
sype 41:b5a2fbc20beb 108 void checkAround(void)
sype 41:b5a2fbc20beb 109 {
sype 41:b5a2fbc20beb 110 if(capt1 > SEUIL+0.1) bleu = 1;
sype 41:b5a2fbc20beb 111 else bleu = 0;
sype 41:b5a2fbc20beb 112 if(capt2 > SEUIL) blanc = 1;
sype 41:b5a2fbc20beb 113 else blanc = 0;
sype 41:b5a2fbc20beb 114 if(capt3 > SEUIL+0.1) rouge = 1;
sype 41:b5a2fbc20beb 115 else rouge = 0;
sype 41:b5a2fbc20beb 116 }
sype 41:b5a2fbc20beb 117
sype 41:b5a2fbc20beb 118 void init_ax12(void)
sype 41:b5a2fbc20beb 119 {
sype 41:b5a2fbc20beb 120 left_hand.setMode(0);
sype 41:b5a2fbc20beb 121 wait_ms(10);
sype 41:b5a2fbc20beb 122 right_hand.setMode(0);
sype 41:b5a2fbc20beb 123 wait_ms(50);
sype 41:b5a2fbc20beb 124 left_hand.setMode(0);
sype 41:b5a2fbc20beb 125 wait_ms(10);
sype 41:b5a2fbc20beb 126 right_hand.setMode(0);
sype 41:b5a2fbc20beb 127 wait_ms(50);
sype 41:b5a2fbc20beb 128 right_hand.setGoal(0);
sype 41:b5a2fbc20beb 129 left_hand.setGoal(0);
sype 41:b5a2fbc20beb 130 wait(2);
sype 41:b5a2fbc20beb 131 right_hand.setGoal(180);
sype 41:b5a2fbc20beb 132 left_hand.setGoal(180);
sype 41:b5a2fbc20beb 133 wait(2);
sype 44:b1fd7489369f 134 }
sype 44:b1fd7489369f 135
sype 44:b1fd7489369f 136 void init_interrupt(void)
sype 44:b1fd7489369f 137 {
sype 47:5658af4e5149 138 CAMP.fall(&changeCamp);
sype 47:5658af4e5149 139 CAMP.rise(&changeCampoff);
sype 47:5658af4e5149 140 START.rise(&letsgo);
sype 47:5658af4e5149 141 START.fall(&letsgooff);
sype 44:b1fd7489369f 142 mybutton.fall(&pressed);
sype 44:b1fd7489369f 143 mybutton.rise(&unpressed);
sype 44:b1fd7489369f 144 EndL.fall(&ELpressed);
sype 44:b1fd7489369f 145 EndL.rise(&ELunpressed);
sype 44:b1fd7489369f 146 EndZ.fall(&EZpressed);
sype 44:b1fd7489369f 147 EndZ.rise(&EZunpressed);
sype 44:b1fd7489369f 148 EndR.fall(&ERpressed);
sype 44:b1fd7489369f 149 EndR.rise(&ERunpressed);
sype 47:5658af4e5149 150 }
sype 47:5658af4e5149 151
sype 47:5658af4e5149 152 void changeCamp(void)
sype 47:5658af4e5149 153 {
sype 47:5658af4e5149 154 LEDV = 1;
sype 45:b53ae54062c6 155 }
sype 45:b53ae54062c6 156
sype 47:5658af4e5149 157 void changeCampoff(void)
sype 47:5658af4e5149 158 {
sype 47:5658af4e5149 159 LEDV = 0;
sype 47:5658af4e5149 160 }
sype 47:5658af4e5149 161
sype 47:5658af4e5149 162 void letsgo(void)
sype 45:b53ae54062c6 163 {
sype 47:5658af4e5149 164 LEDR = 0;
sype 47:5658af4e5149 165 }
sype 47:5658af4e5149 166
sype 47:5658af4e5149 167 void letsgooff(void)
sype 47:5658af4e5149 168 {
sype 47:5658af4e5149 169 LEDR = 1;
sype 41:b5a2fbc20beb 170 }