![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
j
Dependencies: mbed Grove_LCD_RGB_Backlight
main.cpp
- Committer:
- Saide
- Date:
- 2020-04-26
- Revision:
- 1:4501047958cb
- Parent:
- 0:821481a55d81
File content as of revision 1:4501047958cb:
#include "mbed.h" #include "Grove_LCD_RGB_Backlight.h" #include <string> #include <cstring> #include <stdio.h> #include <string.h> #define SIZE 4 DigitalOut myled(LED2); AnalogIn xAxis(p19); AnalogIn yAxis(p20); DigitalIn sw(p18); Grove_LCD_RGB_Backlight LCD(p9,p10); void lecture(void); void affMenu(char[][64], int); float xValue, yValue,xValue_AV,yValue_AV; int switchValue; int sel = 0; int etat=0; int main() { sw.mode(PullUp); while(1) { LCD.setRGB(255, 255, 255); lecture(); switch(etat) { case 0 : //Menu if(xValue==0 && xValue<xValue_AV) { etat=1; } if(xValue==1 && xValue>xValue_AV) { etat=5; } break; case 1 ://Capteurs LCD.setRGB(255, 0, 0); if(xValue==0 && xValue<xValue_AV) { etat=3; } else if (yValue==1 && yValue>yValue_AV) { etat=2; } if(xValue==1 && xValue>xValue_AV) { etat=0; } break; case 2 ://Valeurs capteurs LCD.setRGB(255, 0, 0); if(yValue==0 && yValue<yValue_AV) { etat=1; } break; case 3 ://Position Balle LCD.setRGB(0, 255, 0); if(xValue==0 && xValue<xValue_AV) { etat=5; } else if (yValue==1 && yValue>yValue_AV) { etat=4; } if(xValue==1 && xValue>xValue_AV) { etat=1; } break; case 4 : // coords LCD.setRGB(0, 255, 0); if(yValue==0 && yValue<yValue_AV) { etat=3; } break; case 5 : // ETAT ? LCD.setRGB(0, 0, 255); if(xValue==0 && xValue<xValue_AV) { etat=0; } if(xValue==1 && xValue>xValue_AV) { etat=3; } break; } switch(etat) { case 0 : LCD.locate(0, 0); LCD.print("Menu : "); break; case 1 : LCD.locate(0, 0); LCD.print("Capteurs -> "); break; case 2 : LCD.locate(0, 0); LCD.print("Valeurs capteurs "); break; case 3 : LCD.locate(0, 0); LCD.print("Position balle-> "); break; case 4 : LCD.locate(0, 0); LCD.print("Coordonees X Y "); break; case 5 : LCD.locate(0, 0); LCD.print("Valeurs ETATS "); break; } } } void lecture() { xValue_AV=xValue; yValue_AV=yValue; if(xAxis.read()<=0.4) { xValue =0; } else { if(xAxis.read()>=0.85) { xValue=1; } else { xValue=xAxis.read(); } } if(yAxis.read()<=0.4) { yValue =0; } else { if(yAxis.read()>=0.85) { yValue=1; } else { yValue=yAxis.read(); } } switchValue = sw.read(); } void affMenu(char cDisp[][64], int size){ for(int i = sel; i < sel + 2; i++){ if(i < size){ LCD.locate(0, i-sel); LCD.print(cDisp[i]); } } }