Time is good

Dependencies:   RoboClaw mbed

Fork of Robot2016_2-0 by ARES

Committer:
IceTeam
Date:
Fri May 06 10:05:33 2016 +0200
Revision:
86:0c5e9ac3d8d8
Parent:
85:38cbf5fd22e1
Child:
88:e4de39dd3e2e
Gestion du Timeout pour la funny action

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IceTeam 81:e7b03e81b025 1 #include "entete.h"
IceTeam 85:38cbf5fd22e1 2 #include "AX12/AX12.h"
sype 41:b5a2fbc20beb 3
IceTeam 83:714fa414b2bf 4 DigitalIn CAMP(PA_15);
IceTeam 83:714fa414b2bf 5 DigitalIn START(PB_7);
IceTeam 83:714fa414b2bf 6 DigitalOut LEDR(PC_2);
IceTeam 83:714fa414b2bf 7 DigitalOut LEDV(PC_3);
IceTeam 84:b54822c913b0 8 DigitalIn button(USER_BUTTON);
IceTeam 83:714fa414b2bf 9 int SCouleur = VERT;
IceTeam 83:714fa414b2bf 10
IceTeam 80:cd4960dfa47e 11 BusOut drapeau (PC_8, PC_6, PC_5);
sype 46:5658af4e5149 12 RoboClaw roboclaw(ADR, 460800, PA_11, PA_12);
IceTeam 80:cd4960dfa47e 13 AnalogIn Rcapt1(PA_4);
IceTeam 80:cd4960dfa47e 14 int RvalRcapt1 = 0;
IceTeam 80:cd4960dfa47e 15 AnalogIn Rcapt2(PB_0);
IceTeam 80:cd4960dfa47e 16 int RvalRcapt2 = 0;
IceTeam 80:cd4960dfa47e 17 AnalogIn Rcapt3(PC_1);
IceTeam 80:cd4960dfa47e 18 int RvalRcapt3 = 0;
IceTeam 80:cd4960dfa47e 19 int Ravance = 1;
IceTeam 81:e7b03e81b025 20 DigitalIn start(PB_7);
IceTeam 85:38cbf5fd22e1 21 AX12 umbrella(PA_9, PA_10, 1, 250000);
IceTeam 80:cd4960dfa47e 22
sype 43:d5aaff7d2bec 23 /* Debut du programme */
sype 0:ad9600df4a70 24 int main(void)
sype 10:ae3178aa94e9 25 {
IceTeam 80:cd4960dfa47e 26 Ticker ticker;
IceTeam 86:0c5e9ac3d8d8 27 Timeout end;
IceTeam 80:cd4960dfa47e 28 ticker.attach(&Sharps, 0.01);
IceTeam 86:0c5e9ac3d8d8 29
IceTeam 85:38cbf5fd22e1 30 umbrella.setMode(0);
IceTeam 85:38cbf5fd22e1 31 umbrella.setMaxTorque(200);
IceTeam 86:0c5e9ac3d8d8 32 umbrella.setGoal(150);
IceTeam 86:0c5e9ac3d8d8 33
IceTeam 83:714fa414b2bf 34 depart();
IceTeam 83:714fa414b2bf 35 if (SCouleur == VERT) {
IceTeam 86:0c5e9ac3d8d8 36 end.attach(&endFonc, 10);
IceTeam 83:714fa414b2bf 37 GotoDist(5.5);
IceTeam 83:714fa414b2bf 38 }
IceTeam 86:0c5e9ac3d8d8 39 else if (SCouleur == VIOLET) {
IceTeam 86:0c5e9ac3d8d8 40 end.attach(&endFonc, 10);
IceTeam 83:714fa414b2bf 41 }
IceTeam 83:714fa414b2bf 42 else {
IceTeam 84:b54822c913b0 43 TestDist3(2,2);
IceTeam 84:b54822c913b0 44 TestThet3(1,1);
IceTeam 83:714fa414b2bf 45 }
IceTeam 83:714fa414b2bf 46
sype 77:f19cc7f81f2a 47 while(1);
sype 2:abdf8c6823a1 48 }
IceTeam 80:cd4960dfa47e 49
IceTeam 80:cd4960dfa47e 50 void Sharps() {
IceTeam 80:cd4960dfa47e 51 if (Rcapt1.read() > R_SEUIL_SHARP) RvalRcapt1++;
IceTeam 80:cd4960dfa47e 52 else RvalRcapt1--;
IceTeam 80:cd4960dfa47e 53 RvalRcapt1 = RvalRcapt1 > 10 ? 10 : RvalRcapt1;
IceTeam 80:cd4960dfa47e 54 RvalRcapt1 = RvalRcapt1 < 0 ? 0 : RvalRcapt1;
IceTeam 80:cd4960dfa47e 55
IceTeam 80:cd4960dfa47e 56 if (Rcapt2.read() > R_SEUIL_SHARP) RvalRcapt2++;
IceTeam 80:cd4960dfa47e 57 else RvalRcapt2--;
IceTeam 80:cd4960dfa47e 58 RvalRcapt2 = RvalRcapt2 > 10 ? 10 : RvalRcapt2;
IceTeam 80:cd4960dfa47e 59 RvalRcapt2 = RvalRcapt2 < 0 ? 0 : RvalRcapt2;
IceTeam 80:cd4960dfa47e 60
IceTeam 80:cd4960dfa47e 61 if (Rcapt3.read() > R_SEUIL_SHARP) RvalRcapt3++;
IceTeam 80:cd4960dfa47e 62 else RvalRcapt3--;
IceTeam 80:cd4960dfa47e 63 RvalRcapt3 = RvalRcapt3 > 10 ? 10 : RvalRcapt3;
IceTeam 80:cd4960dfa47e 64 RvalRcapt3 = RvalRcapt3 < 0 ? 0 : RvalRcapt3;
IceTeam 80:cd4960dfa47e 65
IceTeam 80:cd4960dfa47e 66 if (RvalRcapt1 >= 5 || RvalRcapt2 >= 5 || RvalRcapt3 >= 5)
IceTeam 80:cd4960dfa47e 67 Ravance = 0;
IceTeam 80:cd4960dfa47e 68 else
IceTeam 80:cd4960dfa47e 69 Ravance = 1;
IceTeam 80:cd4960dfa47e 70
IceTeam 80:cd4960dfa47e 71 if (Ravance == 0)
IceTeam 80:cd4960dfa47e 72 drapeau = 1;
IceTeam 80:cd4960dfa47e 73 else
IceTeam 80:cd4960dfa47e 74 drapeau = 2;
IceTeam 81:e7b03e81b025 75 }
IceTeam 81:e7b03e81b025 76
IceTeam 86:0c5e9ac3d8d8 77 void endFonc () {
IceTeam 86:0c5e9ac3d8d8 78 umbrella.setGoal(150);
IceTeam 86:0c5e9ac3d8d8 79 while (1);
IceTeam 81:e7b03e81b025 80 }