
Time is good
Fork of Robot2016_2-0 by
Revision 83:714fa414b2bf, committed 2016-05-06
- Comitter:
- IceTeam
- Date:
- Fri May 06 09:20:49 2016 +0200
- Parent:
- 82:07e13071dd7b
- Child:
- 84:b54822c913b0
- Commit message:
- Rajout gestion des couleurs
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/couleur.cpp Fri May 06 09:20:49 2016 +0200 @@ -0,0 +1,29 @@ +#include "entete.h" + +void changeCamp(void) +{ + if(SCouleur==VERT) { + SCouleur = VIOLET; + LEDR = 1; + LEDV = 0; + } if (SCouleur == VIOLET) { + SCouleur = NOIR; + LEDV = 0; + LEDR = 0; + } + else { + SCouleur = NOIR; + LEDV = 1; + LEDR = 0; + } +} + +void depart(void) +{ + while(button==1) { + if(CAMP==0) { + changeCamp(); + } + wait_ms(100); + } +}
--- a/entete.h Fri May 06 07:08:44 2016 +0000 +++ b/entete.h Fri May 06 09:20:49 2016 +0200 @@ -15,6 +15,12 @@ extern int Ravance; extern DigitalIn start; +extern DigitalIn CAMP; +extern DigitalIn START; +extern DigitalOut LEDR; +extern DigitalOut LEDV; +extern int SCouleur; + // Fonctions main.cpp void Sharps(); void GotoThet (float timer, int signe); @@ -26,6 +32,10 @@ void TestThet3(float start, float pas); void compareThet(float start); +// Fonctions couleur.cpp +void depart(void); +void changeCamp(void); + #define ADR 0x80 #define accel_angle 12000 #define vitesse_angle 10000 @@ -40,4 +50,8 @@ #define GAUCHE 1 #define DROITE -1 +#define VERT 1 +#define VIOLET 2 +#define NOIR 3 + #endif \ No newline at end of file
--- a/main.cpp Fri May 06 07:08:44 2016 +0000 +++ b/main.cpp Fri May 06 09:20:49 2016 +0200 @@ -1,5 +1,11 @@ #include "entete.h" +DigitalIn CAMP(PA_15); +DigitalIn START(PB_7); +DigitalOut LEDR(PC_2); +DigitalOut LEDV(PC_3); +int SCouleur = VERT; + BusOut drapeau (PC_8, PC_6, PC_5); RoboClaw roboclaw(ADR, 460800, PA_11, PA_12); AnalogIn Rcapt1(PA_4); @@ -16,9 +22,17 @@ { Ticker ticker; ticker.attach(&Sharps, 0.01); - while (start == 0) ; - GotoDist(5.5); - + depart(); + if (SCouleur == VERT) { + GotoDist(5.5); + } + else if (SCouleur == VIOLET) { + ; + } + else { + ; + } + while(1); }