Basic Example / test application for the on-board MICRON QSPI-Flash. Ported from DISCO_L476VG_QSPI. Added printing on serial output and LCD screen.

Dependencies:   BSP_DISCO_F746NG LCD_DISCO_F746NG QSPI_DISCO_F746NG TS_DISCO_F746NG mbed

Revision:
2:a655d6640167
Parent:
1:7bec6efe01d9
Child:
3:13b323fb08e8
--- a/main.cpp	Sun Oct 18 12:24:51 2015 +0000
+++ b/main.cpp	Tue Oct 20 15:00:59 2015 +0000
@@ -2,9 +2,19 @@
 #include "TS_DISCO_F746NG.h"
 #include "LCD_DISCO_F746NG.h"
 
+#include "MenuGUIButton.h"
+#include "MenuGUIMenu.h"
+#include "MenuGUI.h"
+#include "main.h"
+
 LCD_DISCO_F746NG lcd;
 TS_DISCO_F746NG ts;
 
+//MenuGUIButton button01;
+//MenuGUIButton button02;
+
+// TODO : add Ticker function
+
 int main()
 {
     TS_StateTypeDef TS_State;
@@ -16,7 +26,7 @@
     uint8_t prev_nb_touches = 0;
 
     lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", CENTER_MODE);
-    wait(1);
+    wait(0.2);
 
     status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
     if (status != TS_OK) {
@@ -31,22 +41,74 @@
         lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);
     }
 
-    wait(1);
+    wait(0.2);
     lcd.SetFont(&Font12);
     lcd.SetBackColor(LCD_COLOR_BLUE);
     lcd.SetTextColor(LCD_COLOR_WHITE);
     
-    lcd.DrawRect(10, 80, 50, 50);
-    lcd.DrawRect(10, 140, 50, 50);
-    lcd.DrawRect(10, 200, 50, 50);
-    lcd.DrawRect(70, 80, 50, 50);
-    lcd.DrawRect(130, 80, 50, 50);
-    lcd.DrawRect(190, 80, 50, 50);
-    lcd.DrawRect(250, 80, 50, 50);
-    lcd.DrawRect(310, 80, 50, 50);
-    lcd.DrawRect(370, 80, 50, 50);
+    /* For test / demo
+    ------------------
+    2 menus + 1 main menu. The main menu has two buttons, each calling one of the two sub-menus:
+    
+    |------|  |------|  |------|
+    |  b1  |  |  b3  |  |  b6  |
+    |------|  |------|  |------|
+     ->menu01
+    
+    |------|  |------|  |------|
+    |  b2  |  |  b4  |  |  b7  |
+    |------|  |------|  |------|
+     ->menu02
 
+              |------|  |------|
+              |  b5  |  |  b8  |
+              |------|  |------|
+    menu_main  menu01    menu02
+    
+    */
+    
+    MenuGUIButton button01 (10, 80, 80, 50, "b1", &lcd);
+    MenuGUIButton button02 (10, 140, 80, 50, "b2", &lcd);
+    MenuGUIButton button03 (100, 80, 80, 50, "b3", &lcd);
+    MenuGUIButton button04 (100, 140, 80, 50, "b4", &lcd);
+    
+    MenuGUIButton button05 (190, 80, 80, 50, "b5", &lcd);
+    MenuGUIButton button06 (190, 140, 80, 50, "b6", &lcd);
+    MenuGUIButton button07 (190, 80, 80, 50, "b7", &lcd);
+    MenuGUIButton button08 (190, 140, 80, 50, "b8", &lcd);
+    
+    // Main menu
+    MenuGUIMenu menu_main (2, 10, 80);
+    menu_main.add_button(&button01, 0, 1);
+    menu_main.add_button(&button02, 1, 1);
+    
+    // Menu01
+    MenuGUIMenu menu01 (3, 100, 80);
+    menu01.add_button(&button03, 0, 1);
+    menu01.add_button(&button04, 1, 1);
+    menu01.add_button(&button05, 2, 1);
+    
+    // Menu02
+    MenuGUIMenu menu02 (3, 190, 80);
+    menu02.add_button(&button06, 0, 1);
+    menu02.add_button(&button07, 1, 1);
+    menu02.add_button(&button08, 2, 1);
+    
+    // Main MenuGUI object
+    MenuGUI menugui01 (3);
+    menugui01.add_menu (&menu_main, 0);
+    menugui01.add_menu (&menu01, 1);
+    menugui01.add_menu (&menu02, 2);
+    
+    // Set transitions
+    menugui01.set_transition(1, 0, 0);
+    menugui01.set_transition(2, 0, 1);
+    
+    
     while(1) {
+        
+        lcd.SetBackColor(LCD_COLOR_BLUE);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
 
         ts.GetState(&TS_State);
         if (TS_State.touchDetected) {
@@ -69,37 +131,40 @@
                 sprintf((char*)text, "Touch %d: x=%d y=%d    ", idx+1, x, y);
                 lcd.DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE);
                 
-                if ((x < 60) && (x > 10) && (y < 120) && (y > 70)) {
-                    lcd.FillRect(10, 80, 50, 50);
-                    }
-                else {
-                    lcd.DrawRect(10, 80, 50, 50);
-                    }
-                
             }
 
             lcd.DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
             
-            
         } else {
             if (!cleared) {
                 lcd.Clear(LCD_COLOR_BLUE);
                 sprintf((char*)text, "Touches: 0");
                 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
                 
-                lcd.DrawRect(10, 80, 50, 50);
-                lcd.DrawRect(10, 140, 50, 50);
-                lcd.DrawRect(10, 200, 50, 50);
-                lcd.DrawRect(70, 80, 50, 50);
-                lcd.DrawRect(130, 80, 50, 50);
-                lcd.DrawRect(190, 80, 50, 50);
-                lcd.DrawRect(250, 80, 50, 50);
-                lcd.DrawRect(310, 80, 50, 50);
-                lcd.DrawRect(370, 80, 50, 50);
-        
                 cleared = 1;
             }
         }
+        
+/* ------------------------------------------------------------------------ */
+        
+        // Touch detection of one button
+        if (TS_State.touchDetected > 0) {
+            
+            menugui01.update(TS_State.touchX[0], TS_State.touchY[0]);
+            
+            }
+        else {
+            
+            menugui01.update();
+            
+            }
+        
+        menugui01.display();
+        
     }
 }
 
+
+
+
+