ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
main.cpp@88:e4de39dd3e2e, 2016-05-06 (annotated)
- Committer:
- IceTeam
- Date:
- Fri May 06 11:25:05 2016 +0000
- Revision:
- 88:e4de39dd3e2e
- Parent:
- 86:0c5e9ac3d8d8
- Child:
- 89:46730de0d013
Programme super ? 51points !;
Who changed what in which revision?
User | Revision | Line number | New 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 | 88:e4de39dd3e2e | 21 | AX12 umbrella(PA_9, PA_10, 2, 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 | 88:e4de39dd3e2e | 33 | wait(1); |
IceTeam | 88:e4de39dd3e2e | 34 | umbrella.setGoal(200); |
IceTeam | 88:e4de39dd3e2e | 35 | wait(1); |
IceTeam | 88:e4de39dd3e2e | 36 | umbrella.setGoal(160); |
IceTeam | 88:e4de39dd3e2e | 37 | |
IceTeam | 83:714fa414b2bf | 38 | depart(); |
IceTeam | 83:714fa414b2bf | 39 | if (SCouleur == VERT) { |
IceTeam | 88:e4de39dd3e2e | 40 | end.attach(&endFonc, 90); |
IceTeam | 88:e4de39dd3e2e | 41 | GotoDist(8); |
IceTeam | 88:e4de39dd3e2e | 42 | GotoArr(8.2); |
IceTeam | 83:714fa414b2bf | 43 | } |
IceTeam | 86:0c5e9ac3d8d8 | 44 | else if (SCouleur == VIOLET) { |
IceTeam | 88:e4de39dd3e2e | 45 | end.attach(&endFonc, 30); |
IceTeam | 88:e4de39dd3e2e | 46 | //GotoDist(8.2); |
IceTeam | 88:e4de39dd3e2e | 47 | //GotoArr(8.2); |
IceTeam | 88:e4de39dd3e2e | 48 | GotoDist(2); |
IceTeam | 88:e4de39dd3e2e | 49 | GotoThet(1, GAUCHE); |
IceTeam | 83:714fa414b2bf | 50 | } |
IceTeam | 88:e4de39dd3e2e | 51 | else if (SCouleur == NOIR) { |
IceTeam | 84:b54822c913b0 | 52 | TestDist3(2,2); |
IceTeam | 84:b54822c913b0 | 53 | TestThet3(1,1); |
IceTeam | 83:714fa414b2bf | 54 | } |
IceTeam | 83:714fa414b2bf | 55 | |
sype | 77:f19cc7f81f2a | 56 | while(1); |
sype | 2:abdf8c6823a1 | 57 | } |
IceTeam | 80:cd4960dfa47e | 58 | |
IceTeam | 80:cd4960dfa47e | 59 | void Sharps() { |
IceTeam | 80:cd4960dfa47e | 60 | if (Rcapt1.read() > R_SEUIL_SHARP) RvalRcapt1++; |
IceTeam | 80:cd4960dfa47e | 61 | else RvalRcapt1--; |
IceTeam | 80:cd4960dfa47e | 62 | RvalRcapt1 = RvalRcapt1 > 10 ? 10 : RvalRcapt1; |
IceTeam | 80:cd4960dfa47e | 63 | RvalRcapt1 = RvalRcapt1 < 0 ? 0 : RvalRcapt1; |
IceTeam | 80:cd4960dfa47e | 64 | |
IceTeam | 80:cd4960dfa47e | 65 | if (Rcapt2.read() > R_SEUIL_SHARP) RvalRcapt2++; |
IceTeam | 80:cd4960dfa47e | 66 | else RvalRcapt2--; |
IceTeam | 80:cd4960dfa47e | 67 | RvalRcapt2 = RvalRcapt2 > 10 ? 10 : RvalRcapt2; |
IceTeam | 80:cd4960dfa47e | 68 | RvalRcapt2 = RvalRcapt2 < 0 ? 0 : RvalRcapt2; |
IceTeam | 80:cd4960dfa47e | 69 | |
IceTeam | 80:cd4960dfa47e | 70 | if (Rcapt3.read() > R_SEUIL_SHARP) RvalRcapt3++; |
IceTeam | 80:cd4960dfa47e | 71 | else RvalRcapt3--; |
IceTeam | 80:cd4960dfa47e | 72 | RvalRcapt3 = RvalRcapt3 > 10 ? 10 : RvalRcapt3; |
IceTeam | 80:cd4960dfa47e | 73 | RvalRcapt3 = RvalRcapt3 < 0 ? 0 : RvalRcapt3; |
IceTeam | 80:cd4960dfa47e | 74 | |
IceTeam | 80:cd4960dfa47e | 75 | if (RvalRcapt1 >= 5 || RvalRcapt2 >= 5 || RvalRcapt3 >= 5) |
IceTeam | 80:cd4960dfa47e | 76 | Ravance = 0; |
IceTeam | 80:cd4960dfa47e | 77 | else |
IceTeam | 80:cd4960dfa47e | 78 | Ravance = 1; |
IceTeam | 80:cd4960dfa47e | 79 | |
IceTeam | 80:cd4960dfa47e | 80 | if (Ravance == 0) |
IceTeam | 80:cd4960dfa47e | 81 | drapeau = 1; |
IceTeam | 80:cd4960dfa47e | 82 | else |
IceTeam | 80:cd4960dfa47e | 83 | drapeau = 2; |
IceTeam | 81:e7b03e81b025 | 84 | } |
IceTeam | 81:e7b03e81b025 | 85 | |
IceTeam | 86:0c5e9ac3d8d8 | 86 | void endFonc () { |
IceTeam | 88:e4de39dd3e2e | 87 | roboclaw.ForwardM1(0); |
IceTeam | 88:e4de39dd3e2e | 88 | roboclaw.ForwardM2(0); |
IceTeam | 88:e4de39dd3e2e | 89 | wait(1); |
IceTeam | 88:e4de39dd3e2e | 90 | umbrella.setGoal(300); |
IceTeam | 88:e4de39dd3e2e | 91 | while(1); |
IceTeam | 81:e7b03e81b025 | 92 | } |