ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
main.cpp@45:b53ae54062c6, 2016-04-13 (annotated)
- Committer:
- sype
- Date:
- Wed Apr 13 12:47:47 2016 +0000
- Revision:
- 45:b53ae54062c6
- Parent:
- 44:b1fd7489369f
- Child:
- 46:5658af4e5149
- Child:
- 47:be4eebf40568
Impl?mentation des dispositifs finie
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sype | 41:b5a2fbc20beb | 1 | #include "func.h" |
sype | 0:ad9600df4a70 | 2 | |
sype | 10:ae3178aa94e9 | 3 | #define ATTENTE 0 |
sype | 10:ae3178aa94e9 | 4 | #define GO 1 |
sype | 10:ae3178aa94e9 | 5 | #define STOP 2 |
sype | 0:ad9600df4a70 | 6 | |
sype | 41:b5a2fbc20beb | 7 | /* Déclaration des différents éléments de l'IHM */ |
sype | 10:ae3178aa94e9 | 8 | InterruptIn mybutton(USER_BUTTON); |
sype | 10:ae3178aa94e9 | 9 | DigitalIn button(USER_BUTTON); |
sype | 2:abdf8c6823a1 | 10 | DigitalOut led(LED1); |
sype | 41:b5a2fbc20beb | 11 | DigitalOut bleu(PC_5); |
sype | 41:b5a2fbc20beb | 12 | DigitalOut blanc(PC_6); |
sype | 41:b5a2fbc20beb | 13 | DigitalOut rouge(PC_8); |
sype | 41:b5a2fbc20beb | 14 | |
sype | 41:b5a2fbc20beb | 15 | /* AX12 */ |
sype | 41:b5a2fbc20beb | 16 | AX12 left_hand(PA_15, PB_7, 4, 250000); |
sype | 41:b5a2fbc20beb | 17 | AX12 right_hand(PA_15, PB_7, 1, 250000); |
sype | 41:b5a2fbc20beb | 18 | |
sype | 41:b5a2fbc20beb | 19 | /* Sharp */ |
sype | 41:b5a2fbc20beb | 20 | AnalogIn capt1(PA_4); |
sype | 41:b5a2fbc20beb | 21 | AnalogIn capt2(PB_0); |
sype | 41:b5a2fbc20beb | 22 | AnalogIn capt3(PC_1); |
sype | 41:b5a2fbc20beb | 23 | AnalogIn capt4(PC_0); |
sype | 41:b5a2fbc20beb | 24 | |
sype | 41:b5a2fbc20beb | 25 | /* Moteurs pas à pas */ |
sype | 41:b5a2fbc20beb | 26 | Stepper RMot(NC, PB_10, PA_8); |
sype | 41:b5a2fbc20beb | 27 | Stepper ZMot(NC, PB_5, PB_4); |
sype | 41:b5a2fbc20beb | 28 | Stepper LMot(NC, PB_3, PA_10); |
sype | 41:b5a2fbc20beb | 29 | /* Fins de course */ |
sype | 41:b5a2fbc20beb | 30 | InterruptIn EndR(PB_15); |
sype | 41:b5a2fbc20beb | 31 | InterruptIn EndZ(PB_14); |
sype | 41:b5a2fbc20beb | 32 | InterruptIn EndL(PB_13); |
sype | 41:b5a2fbc20beb | 33 | |
sype | 0:ad9600df4a70 | 34 | Ticker ticker; |
sype | 41:b5a2fbc20beb | 35 | |
sype | 41:b5a2fbc20beb | 36 | Serial logger(USBTX, USBRX); |
sype | 41:b5a2fbc20beb | 37 | //Serial logger(PA_9, PA_10); |
sype | 10:ae3178aa94e9 | 38 | RoboClaw roboclaw(460800, PA_11, PA_12); |
IceTeam | 39:309f38d1e49c | 39 | Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw); |
sype | 10:ae3178aa94e9 | 40 | |
sype | 41:b5a2fbc20beb | 41 | int i = 0, state = 0; |
sype | 41:b5a2fbc20beb | 42 | bool EL = false, EZ = false, ER = false; |
sype | 0:ad9600df4a70 | 43 | |
sype | 2:abdf8c6823a1 | 44 | void init(void); |
sype | 0:ad9600df4a70 | 45 | |
sype | 43:d5aaff7d2bec | 46 | /* Debut du programme */ |
sype | 0:ad9600df4a70 | 47 | int main(void) |
sype | 10:ae3178aa94e9 | 48 | { |
sype | 37:da3a2c781672 | 49 | init(); |
sype | 44:b1fd7489369f | 50 | while(1) JPO(); |
sype | 2:abdf8c6823a1 | 51 | } |
sype | 2:abdf8c6823a1 | 52 | |
sype | 2:abdf8c6823a1 | 53 | void init(void) |
sype | 0:ad9600df4a70 | 54 | { |
sype | 37:da3a2c781672 | 55 | roboclaw.ForwardM1(ADR, 0); |
sype | 37:da3a2c781672 | 56 | roboclaw.ForwardM2(ADR, 0); |
sype | 37:da3a2c781672 | 57 | logger.baud(9600); |
sype | 37:da3a2c781672 | 58 | logger.printf("Hello from main !\n\r"); |
sype | 10:ae3178aa94e9 | 59 | wait_ms(500); |
sype | 44:b1fd7489369f | 60 | bleu = 1, blanc = 1, rouge = 1; |
sype | 41:b5a2fbc20beb | 61 | wait_ms(1000); |
sype | 44:b1fd7489369f | 62 | bleu = 0, blanc = 0, rouge = 0; |
sype | 10:ae3178aa94e9 | 63 | |
sype | 10:ae3178aa94e9 | 64 | while(button); |
sype | 10:ae3178aa94e9 | 65 | wait(1); |
sype | 44:b1fd7489369f | 66 | |
sype | 44:b1fd7489369f | 67 | init_ax12(); |
sype | 44:b1fd7489369f | 68 | init_interrupt(); |
sype | 41:b5a2fbc20beb | 69 | wait_ms(100); |
IceTeam | 39:309f38d1e49c | 70 | logger.printf("End init\n\r"); |
sype | 0:ad9600df4a70 | 71 | } |