Programme test pour librairie MyLab

Dependencies:   MyLab_Lib mbed

Committer:
lucas_favre
Date:
Tue Mar 29 20:30:04 2016 +0000
Revision:
0:b7728b6800cc
Child:
2:75dd587ca336
Programme test de la libraire;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lucas_favre 0:b7728b6800cc 1 /* Programme d'exemple d'utilisation de la librairie pour carte MyLabLib
lucas_favre 0:b7728b6800cc 2 *
lucas_favre 0:b7728b6800cc 3 * Vous devez exporter ce programme pour l'IDE LPCXpresso
lucas_favre 0:b7728b6800cc 4 *
lucas_favre 0:b7728b6800cc 5 *
lucas_favre 0:b7728b6800cc 6 */
lucas_favre 0:b7728b6800cc 7 #include "mbed.h"
lucas_favre 0:b7728b6800cc 8
lucas_favre 0:b7728b6800cc 9 #include "MyLab_Lib.h"
lucas_favre 0:b7728b6800cc 10
lucas_favre 0:b7728b6800cc 11 // Initialisation lcd (Pin E,Pin RW,Pin A0,Pin CS,Pin Data0...Data7)
lucas_favre 0:b7728b6800cc 12 C12832 lcd(P0_1,P0_22,P0_24,P0_0,P2_0,P2_1,P2_2,P2_3,P2_4,P2_5,P2_6,P2_7);
lucas_favre 0:b7728b6800cc 13 // Initialisation communication UART ser(Pin UART_Tx,Pin UART_RX)
lucas_favre 0:b7728b6800cc 14 Serial ser(P0_2,P0_3);
lucas_favre 0:b7728b6800cc 15 // Initialisation accéléromètre Acc(Pin I2C_SDA,Pin I2C_SCL,Adresse acc)
lucas_favre 0:b7728b6800cc 16 MMA7660FC Acc(P0_27,P0_28, ADDR_MMA7660);
lucas_favre 0:b7728b6800cc 17 // Initialisation periph pour MyLab(Pin JoyNord,Pin JoyCentre,Pin JoySud,Pin JoyEst,PinJoyWest,Pin Micro,Pin Audio_out,Pin CaptR,Pin CaptG,Pin CaptB)
lucas_favre 0:b7728b6800cc 18 MyLab periph(P2_10,P2_8,P2_12,P2_11,P2_13,P0_23,P0_26,P0_25,P1_30,P1_31);
lucas_favre 0:b7728b6800cc 19 // Initialisation led Mylab(Pin Led0..Pin Led7)
lucas_favre 0:b7728b6800cc 20 BusOut leds(P0_4,P0_5,P0_6,P0_7,P0_8,P0_9,P0_10,P0_11);
lucas_favre 0:b7728b6800cc 21
lucas_favre 0:b7728b6800cc 22
lucas_favre 0:b7728b6800cc 23 int main() {
lucas_favre 0:b7728b6800cc 24 printMenu(0);
lucas_favre 0:b7728b6800cc 25 while(1) {
lucas_favre 0:b7728b6800cc 26
lucas_favre 0:b7728b6800cc 27 switch (setMenu()) {
lucas_favre 0:b7728b6800cc 28 case 1:
lucas_favre 0:b7728b6800cc 29 lcd.cls();
lucas_favre 0:b7728b6800cc 30 lcd.locate(0,0);
lucas_favre 0:b7728b6800cc 31 lcd.printf("Lecture de deux notes");
lucas_favre 0:b7728b6800cc 32 periph.PlayNote(969.0, 1, 1);
lucas_favre 0:b7728b6800cc 33 periph.PlayNote(800.0, 1, 0.5);
lucas_favre 0:b7728b6800cc 34 wait(1);
lucas_favre 0:b7728b6800cc 35 select_app=0;
lucas_favre 0:b7728b6800cc 36 printMenu(0);
lucas_favre 0:b7728b6800cc 37 break;
lucas_favre 0:b7728b6800cc 38 case 2:
lucas_favre 0:b7728b6800cc 39 lcd.cls();
lucas_favre 0:b7728b6800cc 40 lcd.locate(0,0);
lucas_favre 0:b7728b6800cc 41 lcd.printf("Enregistrement en cours");
lucas_favre 0:b7728b6800cc 42 periph.Sound_Record(periph.dat);
lucas_favre 0:b7728b6800cc 43 lcd.cls();
lucas_favre 0:b7728b6800cc 44 lcd.locate(0,0);
lucas_favre 0:b7728b6800cc 45 lcd.printf("Enregistrement termine");
lucas_favre 0:b7728b6800cc 46 wait(1);
lucas_favre 0:b7728b6800cc 47 lcd.cls();
lucas_favre 0:b7728b6800cc 48 lcd.locate(0,0);
lucas_favre 0:b7728b6800cc 49 lcd.printf("Lecture de l'enregistrement");
lucas_favre 0:b7728b6800cc 50 periph.Sound_Play(periph.dat);
lucas_favre 0:b7728b6800cc 51 wait(1);
lucas_favre 0:b7728b6800cc 52 select_app=0;
lucas_favre 0:b7728b6800cc 53 printMenu(0);
lucas_favre 0:b7728b6800cc 54 break;
lucas_favre 0:b7728b6800cc 55 case 3:
lucas_favre 0:b7728b6800cc 56 lcd.cls();
lucas_favre 0:b7728b6800cc 57 lcd.locate(0,0);
lucas_favre 0:b7728b6800cc 58 lcd.printf("Valeur acc en x :");
lucas_favre 0:b7728b6800cc 59 for (int var = 0; var < 200; ++var) {
lucas_favre 0:b7728b6800cc 60 periph.val_x = periph.Acc_X_Mesure();
lucas_favre 0:b7728b6800cc 61 lcd.locate(0,12);
lucas_favre 0:b7728b6800cc 62 lcd.printf("%f",periph.val_x);
lucas_favre 0:b7728b6800cc 63 }
lucas_favre 0:b7728b6800cc 64 select_app=0;
lucas_favre 0:b7728b6800cc 65 printMenu(0);
lucas_favre 0:b7728b6800cc 66 break;
lucas_favre 0:b7728b6800cc 67 }
lucas_favre 0:b7728b6800cc 68 }
lucas_favre 0:b7728b6800cc 69 }