Lezione_1

Dependencies:   TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BUTTON_GROUP

Revision:
0:2464a8f6b740
Child:
1:f5a3a0a28be5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 28 08:16:44 2019 +0000
@@ -0,0 +1,128 @@
+
+//-----------------------------------------------------------------------
+//  LEZIONE 1
+//
+//
+//  28/01/2019, Copyright (c) 2019 SCUOLA PROFESSIONALE l. EINAUDI
+//  Beta
+//-----------------------------------------------------------------------
+
+#include "mbed.h"
+#include "button_group.hpp"
+#include "TS_DISCO_F746NG.h"
+#include "LCD_DISCO_F746NG.h"
+
+Serial pc(USBTX, USBRX);
+
+void init_lcd(void)
+{
+    lcd_.Clear(LCD_COLOR_WHITE);
+    printf("********** start INIT_LCD *********\n");
+    lcd_.SetBackColor(LCD_COLOR_WHITE);
+    lcd_.SetTextColor(LCD_COLOR_BLACK);
+    lcd_.DisplayStringAt(0, LINE(1), (uint8_t *)"LEZIONE 1", CENTER_MODE);
+
+    wait(1.5);
+
+    lcd_.Clear(LCD_COLOR_BLACK);
+    lcd_.SetBackColor(LCD_COLOR_BLACK);
+    lcd_.SetTextColor(LCD_COLOR_WHITE);
+    lcd_.SetFont(&Font16);
+    lcd_.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);
+
+    wait(0.5);
+    lcd_.SetFont(&Font16);
+    screen_setup_menu(void)
+}
+
+
+void screen_setup_menu(void)
+{
+    using namespace Mikami;
+    lcd_.Clear(LCD_COLOR_DARKBLUE);
+    const string FIRST_CHOICE[9] = {"DISPLAY PARAMETERS","WiFi", "MACHINE NUMBER","BASE PRESSURE","SCREEN SUSPENSION","SETUP LITERS","WATER PRESSURE","SETUP ALARMS","RETURN"};
+    const string FIRST_CHOICE1[9] = {" ", " ", " "," "," "," "," "," "," "};
+    ButtonGroup menu_schadow(lcd_, ts_, 18, 17, 220, 40,
+                             LCD_COLOR_BLACK, LCD_COLOR_DARKBLUE, 9, FIRST_CHOICE1, 10, 10, 2, Font16);
+    ButtonGroup menu(lcd_, ts_, 16, 15, 220, 40,
+                     BACK_COLOR, LCD_COLOR_DARKBLUE, 9, FIRST_CHOICE, 10, 10, 2, Font16);
+
+
+
+    bool exitFromLoop = false;
+    while (!exitFromLoop) {
+        if (menu.Touched(8, LCD_COLOR_GREEN)) {
+            Thread::wait(200);
+            lcd_.Clear(BACK_COLOR);
+            mode = mode_prec;
+            //writeFlash();
+            
+            exitFromLoop=true;
+        } else if (menu.Touched(0, LCD_COLOR_GREEN)) {
+            screen_setup_display_parameters();
+            exitFromLoop=true;
+        } else if (menu.Touched(1, LCD_COLOR_GREEN)) {
+            screen_setup_wifi();
+            exitFromLoop=true;
+        } else if (menu.Touched(2, LCD_COLOR_GREEN)) {
+            screen_setup_Machine_Number();
+            exitFromLoop=true;
+        } else if (menu.Touched(3, LCD_COLOR_GREEN)) {
+            screen_setup_pressure();
+            exitFromLoop=true;
+        } else if (menu.Touched(4, LCD_COLOR_GREEN)) {
+            screen_setup_screen_suspended();
+            exitFromLoop=true;
+        } else if (menu.Touched(5, LCD_COLOR_GREEN)) {
+            screen_setup_liters();
+            exitFromLoop=true;
+        } else if (menu.Touched(6, LCD_COLOR_GREEN)) {
+            screen_setup_water_pressure();
+            exitFromLoop=true;
+        }
+        
+        
+        
+        Thread::wait(100);
+
+    }
+    return;
+}
+
+
+
+
+
+int main()
+{
+    pc.baud(115200);
+    printf("START...\n");
+    Thread::wait(2000);
+    init_lcd();   // inizializzazione lcd e touch screen
+    lcd_.SetFont(&Font16);
+    Thread::wait(2000);
+}
+
+
+void init_lcd(void)
+{
+    lcd_.Clear(LCD_COLOR_WHITE);
+    printf("********** start INIT_LCD *********\n");
+    lcd_.SetBackColor(LCD_COLOR_WHITE);
+    lcd_.SetTextColor(LCD_COLOR_BLACK);
+    lcd_.DisplayStringAt(0, LINE(1), (uint8_t *)"LEZIONE 1", CENTER_MODE);
+
+    wait(1.5);
+
+    lcd_.Clear(LCD_COLOR_BLACK);
+    lcd_.SetBackColor(LCD_COLOR_BLACK);
+    lcd_.SetTextColor(LCD_COLOR_WHITE);
+    lcd_.SetFont(&Font16);
+    lcd_.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);
+
+    wait(0.5);
+    lcd_.SetFont(&Font16);
+    screen_setup_menu(void)
+}
+
+