BTS SNEC Menus

Dependencies:   mbed C12832

Revision:
5:d879f538c159
Parent:
4:dd6d3b44dcb9
Child:
6:a31127c43225
--- a/main.cpp	Tue Oct 06 15:46:06 2015 +0000
+++ b/main.cpp	Sun Oct 10 14:26:20 2021 +0000
@@ -1,16 +1,99 @@
 #include "mbed.h"
 #include "C12832.h"
 
-DigitalIn up(A2);
-
 
 
-int main()
-{
+DigitalIn up(A2);
+DigitalIn down(A3);
+DigitalIn left(A4);
+DigitalIn right(A5);
+DigitalIn center(D4);
+C12832 lcd(D11, D13, D12, D7, D10);
+enum {MATIN,MIDI,SOIR, PETIT, DEJ,DINER} etat = MATIN;
 
-    while (1) {
-       
+int menu_precedent = MIDI;
+char message_precedent[]="            ";
+void Afficher_Menu(int Menu)
+{
+    if (menu_precedent == Menu) return;
+    menu_precedent = Menu;
+    lcd.cls();
+    lcd.locate(0,8);
+    //wait(0.050);
+    switch(Menu) {
+        case MATIN :
+            lcd.printf("Matin");
+            break;
+        case MIDI :
+            lcd.printf("Midi");
+            break;
+        case SOIR :
+            lcd.printf("Soir");
+            break;
+        case PETIT :
+            lcd.printf("Petit dejeuner");
+            break;
+        case DEJ :
+            lcd.printf("Dejeuner");
+            break;
+        case DINER :
+            lcd.printf("Diner");
+            break;
     }
 }
 
+void Afficher_Message(char *Message)
+{
+    if (strcmp(message_precedent,Message) ==0) return;
+    lcd.cls();
+    lcd.locate(0,8);
+    lcd.printf(Message);
 
+}
+
+void Menu_Matin(int etat)
+{
+    bool Sortir = false; // On sort du sous-menu
+    while (!Sortir) {
+        Afficher_Menu(etat);
+        switch (etat) {
+            case PETIT :
+                // évèments
+                if (left) {
+                    etat = MATIN;
+                    Sortir=true;
+                }
+                if (right) etat=DEJ;
+                if (center)Afficher_Message("Ok");
+                break;
+            case DEJ :
+                // évèments
+                break;
+            case DINER :
+
+        }
+        wait(0.125);
+
+    }
+}
+
+int main()
+{
+    while (1) {
+        Afficher_Menu(etat);
+        switch (etat) {
+            case MATIN :
+                // évèments
+                if (down) etat = MIDI;
+                if (right) Menu_Matin(PETIT);
+                break;
+            case MIDI :
+                break;
+            case SOIR :
+                break;
+        }
+
+
+    }
+
+}