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

Files at this revision

API Documentation at this revision

Comitter:
lucas_favre
Date:
Tue Mar 29 20:46:56 2016 +0000
Parent:
6:e9d398c3fbb4
Commit message:
Ajout du menu

Changed in this revision

LCD_lib.lib Show annotated file Show diff for this revision Revisions of this file
MyLab_Lib.cpp Show annotated file Show diff for this revision Revisions of this file
MyLab_Lib.h Show annotated file Show diff for this revision Revisions of this file
--- a/LCD_lib.lib	Tue Mar 29 20:31:34 2016 +0000
+++ b/LCD_lib.lib	Tue Mar 29 20:46:56 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/lucas_favre/code/LCD_lib/#337e207baca2
+https://developer.mbed.org/users/lucas_favre/code/LCD_lib/#88fc5dbc0993
--- 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;
+ }
--- a/MyLab_Lib.h	Tue Mar 29 20:31:34 2016 +0000
+++ b/MyLab_Lib.h	Tue Mar 29 20:46:56 2016 +0000
@@ -32,6 +32,8 @@
     void Sound_Play(short * buffer);
     void PlayNote(float frequency, float duration, float volume);
     float Luminosity_Mesure();
+    int setMenu();
+    void printMenu(int menuitem);
     float Acc_X_Mesure();
     float Acc_Y_Mesure();
     float Acc_Z_Mesure();
@@ -39,6 +41,10 @@
     float val_x;
     float val_y;
     float val_z;
+    short dat[NUMDAT];
+    char* joystickPos ;
+    int select_app ;
+    int menuItem ;
 
 private:
     // Définitions des objets utiles pour la carte MyLab