j

Dependencies:   mbed Grove_LCD_RGB_Backlight

Files at this revision

API Documentation at this revision

Comitter:
Saide
Date:
Sun Apr 26 08:08:56 2020 +0000
Parent:
0:821481a55d81
Commit message:
LCD_Cachan

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 821481a55d81 -r 4501047958cb main.cpp
--- a/main.cpp	Mon Feb 03 16:34:19 2020 +0000
+++ b/main.cpp	Sun Apr 26 08:08:56 2020 +0000
@@ -16,32 +16,166 @@
 void lecture(void);
 void affMenu(char[][64], int);
 
-float xValue, yValue;
+float xValue, yValue,xValue_AV,yValue_AV;
 int switchValue;
 int sel = 0;
-
+int etat=0;
 int main() {
     sw.mode(PullUp);
-    char cDisp[SIZE][64] = {"Capteurs", "Balle", "Batterie", "Voir plus"};
+
     while(1) {
-        wait(0.5);
+      
         LCD.setRGB(255, 255, 255);
-        LCD.clear();
-        LCD.locate(0, 0);
-        //printf("Choisir menu:");
-        //scanf("%d", &sel);
         lecture();
-        //printf("x=%g\t y=%g\t switch=%d\n\r", xValue, yValue, switchValue);
-        //LCD.print("Bonjour");
-        affMenu(cDisp, SIZE);
+        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 = xAxis.read();
-    yValue = yAxis.read();
+}
+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){