Librairie contenant les fonctions nécessaires pour pouvoir contrôler les différents composants de la carte d'extension MyLab

Dependencies:   MMA7660FC LCD_lib

Dependents:   Example_MyLab_lib

Revision:
7:48800c84346c
Parent:
4:f0cbc6c47b11
--- a/MyLab_Lib.cpp	Tue Mar 29 20:31:34 2016 +0000
+++ b/MyLab_Lib.cpp	Tue Mar 29 20:46:56 2016 +0000
@@ -19,6 +19,9 @@
     }
 
     Acc.init();
+    joystickPos = "CENTRE";
+    select_app = 0;
+    menuItem=0;
 
 }
 
@@ -101,6 +104,7 @@
     return r+g+b;
 }
 
+
 // Stockage des valeurs x y z de l'accéléromètre MMA7660FC
 float MyLab::Acc_X_Mesure(){
     return Acc.read_x();
@@ -114,3 +118,65 @@
     return Acc.read_z();
 }
 
+void MyLab::printMenu(int menuitem){
+    lcd.cls();
+       lcd.locate(0,0);
+       switch (menuItem)
+       {
+           case 0:
+               lcd.printf("mBed Librairie pour MyLab");
+               lcd.locate(0,16);
+               lcd.printf("Scroll with joystick");
+               break;
+           case 1:
+               lcd.printf("Lecture de deux notes");
+               lcd.locate(0,16);
+               lcd.printf("Click center to Start");
+               break;
+           case 2:
+               lcd.printf("Enregistrement audio");
+               lcd.locate(0,16);
+               lcd.printf("Click center to Start");
+               break;
+           case 3:
+               lcd.printf("Lecture valeur x acc");
+               lcd.locate(0,16);
+               lcd.printf("Click center to Start");
+               break;
+           case 4:
+             lcd.printf("Credits");
+             lcd.locate(0,16);
+             lcd.printf("Favre Lucas ITI3 Hepia ");
+             break;
+       }
+  
+}
+
+int MyLab::setMenu()
+ {
+     char pos[6];
+     periph.JoyStick_Position(pos);
+
+     if (strcmp(pos,"South") == 0)
+     {
+         periph.joystickPos = "DOWN";
+         if (periph.menuItem >= 0 && periph.menuItem < 4)
+             printMenu(++periph.menuItem);
+     }
+     else if (strcmp(pos,"Center") == 0){
+         if (periph.menuItem == 1)
+             periph.select_app = 1;
+         else if(periph.menuItem == 2)
+             periph.select_app = 2;
+         else if(periph.menuItem == 3)
+             select_app = 3;
+         periph.joystickPos = "CLICK";
+     }
+     else if (strcmp(pos,"North") == 0)
+     {
+         periph.joystickPos = "UP";
+         if (periph.menuItem <= 4 && periph.menuItem > 0)
+             printMenu(--periph.menuItem);
+     }
+     return periph.select_app;
+ }