Michele Furlanetto / Mbed 2 deprecated mbed_keyboard

Dependencies:   TextLCD mbed MMA8451Q TSI

Branch:
mono
Revision:
16:b3cc7cf41a1b
Parent:
15:b358e700d2d7
Child:
17:01fe47dda43b
--- a/main.cpp	Mon Oct 26 13:02:36 2015 +0000
+++ b/main.cpp	Mon Oct 26 13:20:14 2015 +0000
@@ -1,8 +1,8 @@
 #include "ButtonMusical.cpp"
 #include "ButtonDiesis.cpp"
-#include "MyLCD.cpp"
+//#include "MyLCD.cpp"
 
-//#include "TextLCD.h"
+#include "TextLCD.h"
 #include "MMA8451Q.h"
 #include "TSISensor.h"
 
@@ -18,8 +18,8 @@
 #define MAX_OCTAVE 6
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
 
-//TextLCD lcd(PTE5, PTE3, PTE2, PTB11, PTB10, PTB9, TextLCD::LCD16x2); //TextLCD (PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type=LCD16x2, PinName bl=NC, PinName e2=NC, LCDCtrl ctrl=HD44780)
-MyLCD lcd(10, PTE5, PTE3, PTE2, PTB11, PTB10, PTB9);
+TextLCD lcd(PTE5, PTE3, PTE2, PTB11, PTB10, PTB9, TextLCD::LCD16x2); //TextLCD (PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type=LCD16x2, PinName bl=NC, PinName e2=NC, LCDCtrl ctrl=HD44780)
+//MyLCD lcd(10, PTE5, PTE3, PTE2, PTB11, PTB10, PTB9);
 Speaker speaker (PTA4);
 DigitalOut led1(LED1);
 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
@@ -31,11 +31,14 @@
     bool allowEdit=false;
     int mode=OCTAVE;
     
+//string lcdBuffer;
+//string lcdBufferCache;
 void volumeSettings(float* volume)
 {
     float tmp= slider.readPercentage();
     if (tmp>0) *volume = tmp;
-    lcd.printf("VOLUME: ", (*volume)*10,"<ottave     bpm>");
+    //lcdBuffer=
+    lcd.printf("VOLUME: %.0f\n%s", (*volume)*10,"<ottave     bpm>");
 }
 
 void menuManager()
@@ -73,14 +76,14 @@
 void metronomeSettings(int* bpmReg)
 {
     float t_bpm = *bpmReg;
-    lcd.printf("BPM: ", bpm ,"<volume  ottave>");
+    lcd.printf("BPM: %.0f\n%s", bpm ,"<volume  ottave>");
     float tmp = slider.readPercentage();
     if(tmp>0) {
         tLedOn.detach();
         while (tmp>0) {
             t_bpm =int((MIN_METRONOME_BPM+tmp*(MAX_METRONOME_BPM-MIN_METRONOME_BPM))/INTERVAL_METRONOME_BPM);
             tmp = slider.readPercentage();
-            lcd.printf("BPM ",t_bpm*INTERVAL_METRONOME_BPM,"");
+            lcd.printf("BPM %.0f\n%s",t_bpm*INTERVAL_METRONOME_BPM,"<volume  ottave>");
         }
         *bpmReg=(int(t_bpm))*INTERVAL_METRONOME_BPM;
         tLedOn.attach(&ledOn, 60.0/(*bpmReg));
@@ -90,7 +93,7 @@
 
 void octaveSettings()
 {
-    lcd.printf("OTTAVA",multiplier+4,"         volume>");
+    lcd.printf("OTTAVA %.0f\n%s",multiplier+4,"        volume>");
     float octave=4;
     float tmp = slider.readPercentage();
     if(tmp>0) {
@@ -98,7 +101,7 @@
             octave = MIN_OCTAVE+tmp*(MAX_OCTAVE-MIN_OCTAVE);
             multiplier=((int)octave)-4;
             tmp = slider.readPercentage();
-            lcd.printf("OTTAVA",octave,"");
+            lcd.printf("OTTAVA %.0f\n%s",octave,"         volume>");
         }
     }
 }
@@ -130,7 +133,7 @@
 
     while (true) {
         menuManager();
-
+lcd.cls();
         switch(mode) {
             case OCTAVE:
                 octaveSettings();
@@ -145,5 +148,6 @@
                 mode=OCTAVE;
                 break;
         }
+wait(0.1);        
     }
 }
\ No newline at end of file