Romain Ame
/
Stressed
coucou
Fork of Robot2016_2-0 by
Diff: main.cpp
- Revision:
- 47:5658af4e5149
- Parent:
- 45:b53ae54062c6
- Child:
- 48:03da1aead032
diff -r b53ae54062c6 -r 5658af4e5149 main.cpp --- a/main.cpp Wed Apr 13 12:47:47 2016 +0000 +++ b/main.cpp Mon Apr 25 12:38:58 2016 +0000 @@ -3,18 +3,32 @@ #define ATTENTE 0 #define GO 1 #define STOP 2 +#define ADR 0x80 +#define dt 10000 /* Déclaration des différents éléments de l'IHM */ + +/* Carte boutons, la NUCLEO n'arrive pas à récupérer les signaux CAMP et START */ +InterruptIn CAMP(PH_0); +InterruptIn START(PH_1); +DigitalOut LEDR(PC_2); +DigitalOut LEDV(PC_3); + InterruptIn mybutton(USER_BUTTON); DigitalIn button(USER_BUTTON); -DigitalOut led(LED1); + +DigitalIn ChannelA1(PA_1); +DigitalIn ChannelB1(PA_0); +DigitalIn ChannelA2(PA_5); +DigitalIn ChannelB2(PA_6); + DigitalOut bleu(PC_5); DigitalOut blanc(PC_6); DigitalOut rouge(PC_8); -/* AX12 */ -AX12 left_hand(PA_15, PB_7, 4, 250000); -AX12 right_hand(PA_15, PB_7, 1, 250000); +/* AX12 - non fonctionnels, je pense que le souci vient de la bibliothèque car la trame n'est pas correcte (analyseur logique) */ +AX12 left_hand(PA_9, PA_10, 4, 250000); +AX12 right_hand(PA_9, PA_10, 1, 250000); /* Sharp */ AnalogIn capt1(PA_4); @@ -23,9 +37,9 @@ AnalogIn capt4(PC_0); /* Moteurs pas à pas */ -Stepper RMot(NC, PB_10, PA_8); -Stepper ZMot(NC, PB_5, PB_4); -Stepper LMot(NC, PB_3, PA_10); +Stepper RMot(NC, PA_8, PC_7); +Stepper ZMot(NC, PB_4, PB_10); +Stepper LMot(NC, PB_5, PB_3); /* Fins de course */ InterruptIn EndR(PB_15); InterruptIn EndZ(PB_14); @@ -34,14 +48,15 @@ Ticker ticker; Serial logger(USBTX, USBRX); -//Serial logger(PA_9, PA_10); -RoboClaw roboclaw(460800, PA_11, PA_12); +//Serial logger(PA_2, PA_3); +RoboClaw roboclaw(ADR, 460800, PA_11, PA_12); Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw); -int i = 0, state = 0; -bool EL = false, EZ = false, ER = false; +int SIMON_i = 0, SIMON_state = 0; +bool SIMON_EL = false, SIMON_EZ = false, SIMON_ER = false; void init(void); +void update_main(void); /* Debut du programme */ int main(void) @@ -52,20 +67,22 @@ void init(void) { - roboclaw.ForwardM1(ADR, 0); - roboclaw.ForwardM2(ADR, 0); logger.baud(9600); logger.printf("Hello from main !\n\r"); - wait_ms(500); - bleu = 1, blanc = 1, rouge = 1; - wait_ms(1000); - bleu = 0, blanc = 0, rouge = 0; - + roboclaw.ForwardM1(0); + roboclaw.ForwardM2(0); + LEDV = 1; while(button); - wait(1); - - init_ax12(); + LEDV = 0; + roboclaw.ResetEnc(); init_interrupt(); + ticker.attach_us(&update_main, dt); // 100 Hz wait_ms(100); logger.printf("End init\n\r"); } + +void update_main(void) +{ + odo.update_odo(); + //checkAround(); +} \ No newline at end of file