Droni e Droidi / Mbed OS F746NG_TestAll

Dependencies:   TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BUTTON_GROUP Arduino

Revision:
6:ba00a5cd9466
Parent:
5:19f1743cecb1
Child:
7:f654d2b1f08b
diff -r 19f1743cecb1 -r ba00a5cd9466 Functions.h
--- a/Functions.h	Mon Dec 21 00:57:41 2020 +0000
+++ b/Functions.h	Mon Dec 21 20:31:09 2020 +0000
@@ -2,55 +2,90 @@
 #define FUNCTIONS_H
 using namespace ButGrp;
 
+void SetLayer(int numlayer, int tipo=0)
+{
+    return;
+    // vedere come passare BSPLCD_
+    for (int idx = 0; idx < NUMLAYER; idx++) {
+        //  sprintf(str, "Touches: %d",idx);
+        BSP_LCD_DisplayStringAt(0, LINE(12+idx), (uint8_t *)&str, LEFT_MODE);
+        if (idx==numlayer) {
+            BSP_LCD_SetLayerVisible(idx, ENABLE);
+            BSP_LCD_SelectLayer(idx);
+            //   BSP_LCD_DisplayStringAt(50, LINE(12+idx), (uint8_t *)"ON", RIGHT_MODE);
+        } else  {
+            if (tipo==0) {
+                BSP_LCD_SetLayerVisible(idx, DISABLE);
+                // BSP_LCD_DisplayStringAt(50, LINE(12+idx), (uint8_t *)"OFF", RIGHT_MODE);
+            }
+        }
+    }
+}
+
 void PressButton()
 {
     static int ccont=0;
     led1= !led1;
     ccont++;
-    sprintf(str, "Tasto premuto %d volte", ccont);
-    BSP_LCD_DisplayStringAt(0, LINE(10), (uint8_t *) str, CENTER_MODE);
+    if (nummenu==0) {
+        BSP_LCD_.SetFont(&Font16);
+        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+        sprintf(str, "Tasto premuto %d volte", ccont);
+        BSP_LCD_DisplayStringAt(0, LINE(10), (uint8_t *) str, CENTER_MODE);
+    }
 }
 
 void GestioneButton()
 {
-    int num;
-    bool touched = bGroup.GetTouchedNumber(num, LCD_COLOR_DARKBLUE);
-    const int Y0 = 5;
-    const int X1 = 30;
-    const int Y1 = 100;
+    // vedi buttoGroup_Demo per esempio group
+    static bool toccato=false;
+    bool modifica=false;
+    BSP_TS_GetState(&TS_State);
 
-    if (touched) {
-        char str[20];
-        BSP_LCD_.SetFont(&Font16);
-        BSP_LCD_.SetTextColor(LCD_COLOR_WHITE);
-        sprintf(str, "Button%d pressed", num+1);
-        BSP_LCD_.DisplayStringAt(X1, Y1, (uint8_t *)str, LEFT_MODE);
-
-        reset.Redraw();
-    }
 
-    if (sw.Touched(0, LCD_COLOR_DARKGREEN))
-        BSP_LCD_.DisplayStringAt(X1, LINE(7), (uint8_t *)"ON ", LEFT_MODE);
-    if (sw.Touched(1, LCD_COLOR_DARKGREEN))
-        BSP_LCD_.DisplayStringAt(X1, LINE(7), (uint8_t *)"OFF", LEFT_MODE);
-
-    if (reset.Touched()) {
-        bGroup.Redraw(num);
-        reset.Draw(INACTIVE, LCD_COLOR_GRAY);
-        BSP_LCD_.SetFont(&Font16);
-        BSP_LCD_.DisplayStringAt(X1, Y1, (uint8_t *)"               ", LEFT_MODE);
+    if ((avanti.Touched())&& (toccato==false)) {
+        nummenu=(++nummenu)%MAXMENU;
+        // reset.Draw(INACTIVE, LCD_COLOR_GRAY);
+        modifica=true;
     }
-
-    int mNum;
-    if (multiTouch.GetTouchedNumber(mNum, LCD_COLOR_DARKBLUE)) {
-        Button::SetMultiTouch(mNum == 0);   // Set or reset multi-touch
-        if (mNum == 0)
-            BSP_LCD_.DisplayStringAt(320, Y0+150, (uint8_t *)"ON ", LEFT_MODE);
-        else
-            BSP_LCD_.DisplayStringAt(320, Y0+150, (uint8_t *)"OFF", LEFT_MODE);
+    if ((indietro.Touched()) && (toccato==false)) {
+        nummenu=((--nummenu)+MAXMENU)%MAXMENU;
+        // reset.Draw(INACTIVE, LCD_COLOR_GRAY);
+        modifica=true;
     }
     wait(0.01f);
 
+    if((TS_State.touchDetected) && (toccato==false)) {
+        toccato=true;
+    } else if((!TS_State.touchDetected) && (toccato==true)) {
+        toccato=false;
+    }
+
+    if (modifica==true) {
+        if (nummenu==0) {
+            BSP_LCD_.SetFont(&Font12);
+            BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+            sprintf(str, "menu: %d", nummenu);
+        }
+        BSP_LCD_DisplayStringAt(50, LINE(7), (uint8_t *)str, LEFT_MODE);
+        BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+        BSP_LCD_FillRect(40+1, 45+1, DimX-80-1, DimY-45-45-1);
+        BSP_LCD_FillRect(DimX/3+6, 1, ((DimX*2)/3)-7, 38);
+        BSP_LCD_.SetFont(&Font24);
+        BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
+        switch (nummenu) {
+            case 0:
+                BSP_LCD_DisplayStringAt(DimX/3+10, 10, (uint8_t *) "Dati Generali", LEFT_MODE);
+                break;
+            case 1:
+                BSP_LCD_DisplayStringAt(DimX/3+10, 10, (uint8_t *) "Da assegnare", LEFT_MODE);
+                break;
+            case 2:
+                BSP_LCD_DisplayStringAt(DimX/3+10, 10, (uint8_t *) "Dati TCP", LEFT_MODE);
+                break;
+        }
+
+    }
 }
 
 void GestioneTouch()
@@ -59,6 +94,7 @@
     uint8_t cleared = 0;
     uint8_t prev_nb_touches = 0;
     BSP_TS_GetState(&TS_State);
+    BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
     BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
     BSP_LCD_.SetFont(&Font16);
     if (TS_State.touchDetected) {
@@ -72,16 +108,18 @@
         cleared = 0;
         sprintf(str, "Touches: %d", TS_State.touchDetected);
         BSP_LCD_DisplayStringAt(50, LINE(3), (uint8_t *)str, LEFT_MODE);
-
+        SetLayer( 1);
         BSP_LCD_DrawPixel(x, y, LCD_COLOR_BLACK);
+        SetLayer( 0);
         for (int idx = 0; idx < TS_State.touchDetected; idx++) {
             x = TS_State.touchX[idx];
             y = TS_State.touchY[idx];
             sprintf(str, "Touch %d: x=%d y=%d    ", idx+1, x, y);
             BSP_LCD_DisplayStringAt(50, LINE(idx+4), (uint8_t *)str, LEFT_MODE);
         }
-
+        SetLayer( 1);
         BSP_LCD_DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_WHITE);
+        SetLayer( 0);
     } else {
         if (!cleared) {
             sprintf(str, "Touches: 0");
@@ -91,21 +129,32 @@
     }
 }
 
-void SetLayer(int numlayer)
+void DatiTCP()
 {
-    // vedere come passare BSPLCD_
-    for (int idx = 0; idx < NUMLAYER; idx++) {
-        //  sprintf(str, "Touches: %d",idx);
-        BSP_LCD_DisplayStringAt(0, LINE(12+idx), (uint8_t *)&str, LEFT_MODE);
-        if (idx==numlayer) {
-            BSP_LCD_SelectLayer(idx);
-            BSP_LCD_SetLayerVisible(idx, ENABLE);
-            //   BSP_LCD_DisplayStringAt(50, LINE(12+idx), (uint8_t *)"ON", RIGHT_MODE);
-        } else {
-            BSP_LCD_SetLayerVisible(idx, DISABLE);
-            //      BSP_LCD_DisplayStringAt(50, LINE(12+idx), (uint8_t *)"OFF", RIGHT_MODE);
-        }
+    static bool giavisualizzato=false;
+    if ((nummenu==2)&&(giavisualizzato==false)) {
+        BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
+        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+        BSP_LCD_.SetFont(&Font16);
+        BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"Ethernet socket example", CENTER_MODE);
+        // Show the network address
+        const char *ip = net.get_ip_address();
+        const char *netmask = net.get_netmask();
+        const char *gateway = net.get_gateway();
+        sprintf(str,"IP address: %s", ip ? ip : "None");
+        BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)str, CENTER_MODE);
+        sprintf(str,"Netmask: %s", netmask ? netmask : "None");
+        BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)str, CENTER_MODE);
+        sprintf(str,"Gateway: %s", gateway ? gateway : "None");
+        BSP_LCD_DisplayStringAt(0, LINE(7), (uint8_t *)str, CENTER_MODE);
+
+        giavisualizzato=true;
     }
+
+    if (nummenu!=2)
+        giavisualizzato=false;
 }
 
+
+
 #endif
\ No newline at end of file