edfds

Dependencies:   C12832 mbed

Fork of TP3_app-shield-joystick by Robert Tomczak

Files at this revision

API Documentation at this revision

Comitter:
NoSense
Date:
Wed Sep 28 15:52:04 2016 +0000
Parent:
4:dd6d3b44dcb9
Commit message:
coucou version 1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 06 15:46:06 2015 +0000
+++ b/main.cpp	Wed Sep 28 15:52:04 2016 +0000
@@ -2,15 +2,250 @@
 #include "C12832.h"
 
 DigitalIn up(A2);
+DigitalIn right(A5);
+DigitalIn center(D4);
+DigitalIn left(A4);
+DigitalIn down(A3);
+C12832 lcd(D11, D13, D12, D7, D10);
 
 
 
+void menu1(){
+    lcd.locate(10,0);
+    lcd.printf("Matin");
+    lcd.locate(10,10);
+    lcd.printf("Midi");
+    lcd.locate(10,20);
+    lcd.printf("Soir");
+}
+
+void menu2(){
+    lcd.locate(10,0);
+    lcd.printf("Petit-dejeuner");
+    lcd.locate(10,10);
+    lcd.printf("Dejeuner");
+    lcd.locate(10,20);
+    lcd.printf("Diner");
+}
+
+int i = 0;
+int k = 0;
+int out = 0;
+
+
 int main()
 {
 
-    while (1) {
-       
-    }
-}
+    menu1();
+    lcd.locate(0,0);
+    lcd.printf(">");
+    
+    while(1){
+        
+        if(down){
+            if(i==0){
+                lcd.cls();
+                menu1();
+                i++;
+                lcd.locate(0,10);
+                lcd.printf(">");
+                wait(0.8);
+                }
+                
+            else if(i==1){
+                lcd.cls();
+                menu1();
+                i++;
+                lcd.locate(0,20);
+                lcd.printf(">");
+                wait(0.8);
+                }
+            } //fin if(down)
+        
+        
+        if(up){
+            if(i==2){
+                lcd.cls();
+                menu1();
+                i--;
+                lcd.locate(0,10);
+                lcd.printf(">");
+                wait(0.8);
+                }
+                
+            else if(i==1){
+                lcd.cls();
+                menu1();
+                i--;
+                lcd.locate(0,0);
+                lcd.printf(">");
+                wait(0.8);
+                }
+            } //fin if(up)
+        
+        
+        
+        
+        
+        if(right){
+            wait(0.8);
+            lcd.cls();
+            menu2();
+            lcd.locate(0,0);
+            lcd.printf(">");
+            
+            while(left==0){ //bis
+                 if(down){
+                        if(k==0){
+                            lcd.cls();
+                            menu2();
+                            k++;
+                            lcd.locate(0,10);
+                            lcd.printf(">");
+                            wait(0.8);
+                            }
+                            
+                        else if(k==1){
+                            lcd.cls();
+                            menu2();
+                            k++;
+                            lcd.locate(0,20);
+                            lcd.printf(">");
+                            wait(0.8);
+                            }
+                        } //fin if(down)
+                    
+                    if(up){
+                        if(k==2){
+                            lcd.cls();
+                            menu2();
+                            k--;
+                            lcd.locate(0,10);
+                            lcd.printf(">");
+                            wait(0.8);
+                            }
+                            
+                        else if(k==1){
+                            lcd.cls();
+                            menu2();
+                            k--;
+                            lcd.locate(0,0);
+                            lcd.printf(">");
+                            wait(0.8);
+                            }
+                        } //fin if(up)
+                
+               
+                    if(right){
+                        
+                        wait(0.8);
+                        
+                        while(left==0 || out==0){
+                            
+                            if(i==0){
+                                
+                                if(k==0){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Ok !");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                                    
+                                else if(k==1){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Trop tot");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                                    
+                                else if(k==2){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Trop tot");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                            } //fin if(i==0);
+                            
+                             
+                                                                
+                            else if(i==1){
+                                
+                                if(k==0){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Trop tard");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                                    
+                                else if(k==1){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Ok !");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                                    
+                                else if(k==2){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Trop tot");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                            }  //fin if(i==1)
+                                    
+                                    
+                                    
+                            else if(i==2){
+                                
+                                if(k==0){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Trop tard");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                                    
+                                else if(k==1){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Trop tard");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                                    
+                                else if(k==2){
+                                    lcd.cls();
+                                    lcd.locate(0,0);
+                                    lcd.printf("Ok !");
+                                    out = 1;
+                                    wait(2.5);
+                                }
+                            } //fin if(i==2); 
+                                    
+                        } //fin while(left==0) bis
+                    } //fin if(right)
+                                    
+                        
+            
+            
+            } //fin boucle while(left==0)
+            
+            lcd.cls();
+            menu1();
+            lcd.locate(0,0);
+            lcd.printf(">");
+            i = 0;
+            k = 0;
+            
+        } //fin if(right)
+            
 
-
+        
+    } //fin boucle while(1)
+    
+} //fin main
--- a/mbed.bld	Tue Oct 06 15:46:06 2015 +0000
+++ b/mbed.bld	Wed Sep 28 15:52:04 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file