This one
Dependencies: C12832
Diff: main.cpp
- Revision:
- 6:e9cdd72adb62
- Parent:
- 5:47721be170f9
--- a/main.cpp Tue Sep 19 16:59:28 2017 +0000 +++ b/main.cpp Sat May 02 12:07:50 2020 +0000 @@ -1,59 +1,63 @@ -#include "mbed.h" -#include "C12832.h" + #include "mbed.h" + #include "C12832.h" + #include "moteur.h" + #include "emissionIR.h" -// Max X value of LCD screen -#define MAX_X 124 -// Max Y value of LCD screen -#define MAX_Y 28 +/* Déclaration des objets glogaux ***************************/ -struct ball_t { - int y; - int x; -}; -ball_t ball; // Keep track of ball's x and y C12832 lcd(D11, D13, D12, D7, D10); -// Joystick Pins +AnalogIn pot1(A0); +AnalogIn pot2(A1); + +DigitalOut LED_rouge(D5,1); +DigitalOut LED_verte(D9,1); +//DigitalOut LED_bleue(D8,1); // NE PAS UTILISER LA LED BLEUE + DigitalIn up(A2); DigitalIn down(A3); DigitalIn left(A4); DigitalIn right(A5); DigitalIn fire(D4); -void draw_ball() { - // Clear LCD - lcd.cls(); - // Calculate ball's position based on joystick movement - if(left){ - ball.x = ball.x > 0 ? ball.x-1 : MAX_X; - } - if(right) { - ball.x = ball.x < MAX_X ? ball.x+1 : 0; - } - if(up) { - ball.y = ball.y > 0 ? ball.y-1 : MAX_Y; - } - if(down) { - ball.y = ball.y < MAX_Y ? ball.y+1 : 0; - } - if(fire){ - // Increment ball's x position by 10 - ball.x = ball.x < MAX_X-10 ? ball.x+10 : 10-(MAX_X-ball.x); + +// Détecteurs d'obstacles +AnalogIn IR_G(PB_1);AnalogIn IR_D(PC_2); + +DigitalIn jack(PD_2); +DigitalIn bumpers(PB_7); +DigitalOut LED(PA_13); + +// Détecteur de zone blanche +BusIn Arrivee(PC_9,PC_10,PC_11,PC_12,PA_12,PA_14); + +Serial uartWifi(SERIAL_TX, SERIAL_RX); +//Serial uartWifi(PA_9, PA_10); + +/* Déclaration des variables globales ****************************************/ + + +/* Définition des fonctions gérant la machine à états ************************/ + +// définition des fonctions +void gestionEtat(){ } - lcd.fillcircle(ball.x, ball.y, 3, 1); -} +void gestionAction(){ + } -int main() -{ - // Put the ball in the middle of the screen initially - ball.x = MAX_X/2; - ball.y = MAX_Y/2; - - EventQueue queue; - // Update the ball's position every 50 ms - queue.call_every(50, draw_ball); - queue.dispatch(); -} +/******************************************************************************/ +int main() { + lcd.cls(); + lcd.locate(32,16); + lcd.printf("Module ER2 : template"); + while(true){ + wait(.5); + switch(rand()%2){ + case 0 : LED_rouge.write(!LED_rouge.read()); break; + default : LED_verte.write(!LED_verte.read()); + }//switch + }//while + }