
Time is good
Fork of Robot2016_2-0 by
Diff: Functions/func.cpp
- Revision:
- 80:cd4960dfa47e
- Parent:
- 79:b11b50108ae5
- Child:
- 81:e7b03e81b025
diff -r b11b50108ae5 -r cd4960dfa47e Functions/func.cpp --- a/Functions/func.cpp Thu May 05 15:11:06 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -#include <cmath> - -#include "func.h" - -int max(int a, int b) -{ - return (a>b)?a:b; -} - -int max(int a, int b, int c) -{ - return max(a,max(b,c)); -} - -int min(int a, int b) -{ - return (a<b)?a:b; -} - -void init_interrupt(void) -{ - ticker.attach_us(&update_main, dt); // 100 Hz -} - -void pressed(void) -{ - if(SIMON_i==0) { - roboclaw.ForwardM1(0); - roboclaw.ForwardM2(0); - SIMON_i++; - } -} - -void unpressed(void) -{ - if(SIMON_i==1) { - SIMON_i--; - } -} - -void checkAround(void) -{ - SDroite += (capt1.read() > seuils[0]?1:-1); - SDroite = min(SDroite, 5); - SDroite = max(SDroite, -5); - - SDevant += (capt2.read() > seuils[1]?1:-1); - SDevant = min(SDevant, 5); - SDevant = max(SDevant, -5); - - SGauche += (capt3.read() > seuils[2]?1:-1); - SGauche = min(SGauche, 5); - SGauche = max(SGauche, -5); - - drapeau[0] = SGauche>0; - drapeau[1] = SDevant>0; - drapeau[2] = SDroite>0; - - logger.printf("Sharps : %d %d %d\r\n", SGauche, SDevant, SDroite); -} - -/*void init_ax12(void) -{ - left_hand.setMode(0); - wait_ms(10); - right_hand.setMode(0); - wait_ms(50); - left_hand.setMode(0); - wait_ms(10); - right_hand.setMode(0); - wait_ms(50); - right_hand.setGoal(0); - left_hand.setGoal(0); - wait(2); - right_hand.setGoal(180); - left_hand.setGoal(180); - wait(2); -}*/ - -void changeCamp(void) -{ - if(SCouleur==VERT) { - SCouleur = VIOLET; - LEDR = 1; - LEDV = 0; - } else { - SCouleur = VERT; - LEDV = 1; - LEDR = 0; - } -} - -void depart(void) -{ - while(button==1) { - if(CAMP==0) { - changeCamp(); - } - wait_ms(100); - } - - if(SCouleur == VERT)logger.printf("Couleur VERT !\n\r"); - else logger.printf("Couleur ROUGE !\n\r"); - - while(START==0) { - drapeau = SSchema; - if(CAMP==0) { - SSchema++; - if(SSchema == 6) SSchema = 1; - drapeau = SSchema; - } - wait_ms(100); - } - logger.printf("Schema numero : %d !\n\r", SSchema); -}