test

Dependencies:   mbed HYT FT813

Files at this revision

API Documentation at this revision

Comitter:
vitlog
Date:
Thu Jun 18 13:18:02 2020 +0000
Commit message:
Riverdi EVE 70

Changed in this revision

FT813.lib Show annotated file Show diff for this revision Revisions of this file
HYT.lib Show annotated file Show diff for this revision Revisions of this file
TFT/display.Calibration.cpp Show annotated file Show diff for this revision Revisions of this file
TFT/display.DisplayListFunctions.cpp Show annotated file Show diff for this revision Revisions of this file
TFT/display.Draw_CurrentValuesGraphs.cpp Show annotated file Show diff for this revision Revisions of this file
TFT/display.Draw_Grids.cpp Show annotated file Show diff for this revision Revisions of this file
TFT/display.Draw_MainMenu.cpp Show annotated file Show diff for this revision Revisions of this file
TFT/display.Draw_MainMenuReference.cpp Show annotated file Show diff for this revision Revisions of this file
TFT/display.GetTouch.cpp Show annotated file Show diff for this revision Revisions of this file
TFT/display.StringsTransforming.cpp Show annotated file Show diff for this revision Revisions of this file
display.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FT813.lib	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/vitlog/code/FT813/#2f11d40f0f9a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HYT.lib	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/koosvanderwat/code/HYT/#2d50976e2506
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.Calibration.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,12 @@
+#include "display.h"
+ 
+/**************************************************************************************************************************
+************************** Put calibration data to FT800 ******************************************************************
+**************************************************************************************************************************/
+void Display::Calibration()
+{   
+    char calibration[25] = {98, 99, 0, 0, 182, 254, 255, 255, 245, 142, 248, 255, 117, 254, 255, 255, 34, 98, 0, 0, 123, 154, 248, 255};
+    for (int i = 0; i < 24; i++) {
+        (*_TFT).Wr8(REG_TOUCH_TRANSFORM_A + i, calibration[i]);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.DisplayListFunctions.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,28 @@
+#include "display.h"
+
+/**************************************************************************************************************************
+************************** Start display list *****************************************************************************
+**************************************************************************************************************************/
+void Display::StartDL()
+{
+    (*_TFT).DLstart();
+    // set white color for background
+    (*_TFT).DL(CLEAR_COLOR_RGB(255, 255, 255));
+    // clear buffers for preset values
+    (*_TFT).DL(CLEAR(1, 1, 1));
+}
+
+/**************************************************************************************************************************
+************************** Finish display list ****************************************************************************
+**************************************************************************************************************************/
+void Display::FinishDL()
+{
+    (*_TFT).DL(DISPLAY());
+    // Swap the current display list
+    (*_TFT).Swap();
+    // Download the command list into fifo TFT
+    (*_TFT).Flush_Co_Buffer();
+    //  Wait for the complete consumption of FT800 Coprocessor commands
+    (*_TFT).WaitCmdfifo_empty();
+}
+            
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.Draw_CurrentValuesGraphs.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,164 @@
+#include "display.h"
+
+/**************************************************************************************************************************
+************************** Display real-time humidity *********************************************************************
+**************************************************************************************************************************/
+void Display::CurrentHumidity(float humidity)
+{
+    // accelerator for x-axis data output
+    char accelerator = 6;
+    // create string including current humididty and " %"
+    CreateStringTempHum(humidityStr, humidity, 0);
+    // write the new scalable (* 1.5) data to the next available array position
+    currentHumidity_Y[currentHumidity_X] = (char)(humidity * 1.5);
+
+    // start FT800 display list
+    StartDL();
+    
+    // draw bottom color for graph line
+    (*_TFT).DL(COLOR_RGB(200, 200, 200));
+    (*_TFT).DL(BEGIN(EDGE_STRIP_B));
+    for (int i = 0; i < 68; i++) {
+        if (currentHumidity_Y[i] != 0 && i <= currentHumidity_X) {
+            (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (220 - currentHumidity_Y[i]) * 16));
+        }
+    }
+    
+    // draw horisontal grid for humidity (0 .. 100)
+    HorisontalGrid_CurrentHumidity();
+    
+    // draw main graph line
+    (*_TFT).DL(COLOR_RGB(9, 0, 63));
+    (*_TFT).DL(BEGIN(POINTS));
+    (*_TFT).DL(POINT_SIZE(25));
+    for (int i = 0; i < 68; i++) {
+        if (currentHumidity_Y[i] != 0 && (i < currentHumidity_X || i >= currentHumidity_X + 13)) {
+            (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (222 - currentHumidity_Y[i]) * 16));
+        }
+    }
+
+    // draw subtitle for main graph line
+    (*_TFT).DL(COLOR_RGB(255, 255, 255));
+    (*_TFT).DL(BEGIN(RECTS));
+    (*_TFT).DL(VERTEX2II((currentHumidity_X * accelerator + 40) + 25, (200 - currentHumidity_Y[currentHumidity_X]), 0, 0));
+    (*_TFT).DL(VERTEX2II((currentHumidity_X * accelerator + 40), (177 - currentHumidity_Y[currentHumidity_X]), 0, 0));
+    (*_TFT).DL(COLOR_RGB(255, 0, 0));
+    (*_TFT).Text((currentHumidity_X * accelerator + 30), (180 - currentHumidity_Y[currentHumidity_X] - 7), 28, 0, humidityStr);
+    (*_TFT).DL(BEGIN(LINES));
+    (*_TFT).DL(LINE_WIDTH(8));
+    (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 15) * 16, (220 - currentHumidity_Y[currentHumidity_X]) * 16));
+    (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 35) * 16, (200 - currentHumidity_Y[currentHumidity_X]) * 16));
+    (*_TFT).DL(COLOR_RGB(255, 30, 33));
+    (*_TFT).DL(BEGIN(POINTS));
+    (*_TFT).DL(POINT_SIZE(33));
+    (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 15) * 16, (220 - currentHumidity_Y[currentHumidity_X]) * 16));
+    (*_TFT).DL(END());
+
+    // write main title
+    (*_TFT).DL(COLOR_RGB(0, 0, 0));
+    (*_TFT).Text(15, 15, 30, 0, "Current humidity, rH");
+
+    // clean the space under the plot, create link to the main menu
+    (*_TFT).DL(SCISSOR_XY(15, 222));
+    (*_TFT).DL(SCISSOR_SIZE(420, 53));
+    (*_TFT).Gradient(0, 256, 0xFFFFFF, 450, 16, 0xFFFFFF);
+    MainMenuReference();
+
+    // finish FT801 display list
+    FinishDL();
+
+    // manage the index for array
+    if (currentHumidity_X >= 68) {
+        currentHumidity_X = 0;
+    } else {
+        currentHumidity_X ++;
+    }
+    if (pressedButton == MENU_PRESS) {
+        for (int i = 0; i < 68; i++) {
+            currentHumidity_Y[i] = 0;
+            currentHumidity_X = 0;
+        }
+    }
+}
+
+/**************************************************************************************************************************
+************************** Display real-time temperature ******************************************************************
+**************************************************************************************************************************/
+void Display::CurrentTemperature(float temperature)
+{
+    // accelerator for x-axis data output
+    char accelerator = 6;
+    // create string including current temperature with decimal mark and " С"
+    CreateStringTempHum(temperatureStr, temperature, 1);
+    // write the new scalable (* 0.88 + 45) data to the next available array position
+    currentTemperature_Y[currentTemperature_X] = (char)(temperature * 0.88 + 45);
+
+    // start FT800 display list
+    StartDL();
+
+    // draw bottom color for graph line
+    (*_TFT).DL(COLOR_RGB(200, 177, 199));
+    (*_TFT).DL(BEGIN(EDGE_STRIP_B));
+    for (int i = 0; i < 68; i++) {
+        if (currentTemperature_Y[i] != 0 && i <= currentTemperature_X) {
+            (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (220 - currentTemperature_Y[i]) * 16));
+        }
+    }
+
+    // draw horisontal grid for temperature (-50 .. +125)
+    HorisontalGrid_CurrentTemp();
+
+    // draw main graph line
+    (*_TFT).DL(COLOR_RGB(9, 0, 63));
+    (*_TFT).DL(BEGIN(POINTS));
+    (*_TFT).DL(POINT_SIZE(25));
+    for (int i = 0; i < 68; i++) {
+        if (currentTemperature_Y[i] != 0 && (i < currentTemperature_X || i >= currentTemperature_X + 13)) {
+            (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (222 - currentTemperature_Y[i]) * 16));
+        }
+    }
+
+    // draw subtitle for main graph line
+    (*_TFT).DL(COLOR_RGB(255, 255, 255));
+    (*_TFT).DL(BEGIN(RECTS));
+    (*_TFT).DL(VERTEX2II((currentTemperature_X * accelerator + 40) + 25, (200 - currentTemperature_Y[currentTemperature_X]), 0, 0));
+    (*_TFT).DL(VERTEX2II((currentTemperature_X * accelerator + 40), (177 - currentTemperature_Y[currentTemperature_X]), 0, 0));
+    (*_TFT).DL(COLOR_RGB(255, 0, 0));
+    (*_TFT).Text((currentTemperature_X * accelerator + 25), (173 - currentTemperature_Y[currentTemperature_X]), 28, 0, temperatureStr);
+    (*_TFT).DL(BEGIN(LINES));
+    (*_TFT).DL(LINE_WIDTH(8));
+    (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 15) * 16, (220 - currentTemperature_Y[currentTemperature_X]) * 16));
+    (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 35) * 16, (200 - currentTemperature_Y[currentTemperature_X]) * 16));
+    (*_TFT).DL(COLOR_RGB(255, 30, 33));
+    (*_TFT).DL(BEGIN(POINTS));
+    (*_TFT).DL(POINT_SIZE(33));
+    (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 15) * 16, (220 - currentTemperature_Y[currentTemperature_X]) * 16));
+    (*_TFT).DL(END());
+
+    // write main title
+    (*_TFT).DL(COLOR_RGB(0, 0, 0));
+    (*_TFT).Text(15, 15, 30, 0, "Current temperature");
+
+    // clean the space under the plot, create link to the main menu
+    (*_TFT).DL(SCISSOR_XY(15, 225));
+    (*_TFT).DL(SCISSOR_SIZE(420, 53));
+    (*_TFT).Gradient(0, 256, 0xFFFFFF, 450, 16, 0xFFFFFF);
+    MainMenuReference();
+
+    // finish FT801 display list
+    FinishDL();
+
+    // manage the index for array
+    if (currentTemperature_X >= 68) {
+        currentTemperature_X = 0;
+    } else {
+        currentTemperature_X ++;
+    }
+    if (pressedButton == MENU_PRESS) {
+        for (int i = 0; i < 68; i++) {
+            currentTemperature_Y[i] = 0;
+            currentTemperature_X = 0;
+        }
+    }
+}
+          
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.Draw_Grids.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,42 @@
+#include "display.h"
+ 
+/**************************************************************************************************************************
+************************** Draw horisontal grid for temperature (-50 .. +125) *********************************************
+**************************************************************************************************************************/
+void Display::HorisontalGrid_CurrentTemp()
+{
+    (*_TFT).DL(COLOR_RGB(20, 20, 20));
+    char gridNumb = 125 + 50;
+    for (int i = 70 * 16; i <= 225 * 16; i += 352) {
+        (*_TFT).DL(BEGIN(LINES));
+        (*_TFT).DL(LINE_WIDTH(8));
+        (*_TFT).DL(VERTEX2F(15 * 16, i));
+        (*_TFT).DL(VERTEX2F(423 * 16, i));
+        if (gridNumb  >= 50) {
+            (*_TFT).Number(435, i/16 - 9, 26, 0, gridNumb - 50);
+        } else if (gridNumb == 25) {
+            (*_TFT).Text(435, i/16 - 9, 26, 0, "-25");
+        } else if (gridNumb == 0) {
+            (*_TFT).Text(435, i/16 - 9, 26, 0, "-50");
+        }
+        gridNumb = gridNumb - 25;
+    }
+}
+ 
+/**************************************************************************************************************************
+************************** Draw horisontal grid for humidity (0 .. 100) ***************************************************
+**************************************************************************************************************************/
+void Display::HorisontalGrid_CurrentHumidity()
+{
+    (*_TFT).DL(COLOR_RGB(20, 20, 20));
+    char gridNumb = 100;
+    for (int i = 70 * 16; i <= 220 * 16; i += 600) {
+        (*_TFT).DL(BEGIN(LINES));
+        (*_TFT).DL(LINE_WIDTH(8));
+        (*_TFT).DL(VERTEX2F(15 * 16, i));
+        (*_TFT).DL(VERTEX2F(423 * 16, i));
+        (*_TFT).Number(435, i/16 - 9, 26, 0, gridNumb);
+        gridNumb = gridNumb - 25;
+    }
+}
+            
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.Draw_MainMenu.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,54 @@
+#include "display.h"
+
+/**************************************************************************************************************************
+************************** Display Main Menu ******************************************************************************
+**************************************************************************************************************************/
+void Display::MainMenu(float humidity, float temperature)
+{
+    // start FT800 display list
+    StartDL();
+    
+    // write main title
+    (*_TFT).DL(COLOR_RGB(0, 0, 0));
+    (*_TFT).Text(11, 15, 30, 0, "HYT-271 sensor from IST");
+
+    // create blue rectangle with current humididty including 
+    // rectangle is tagged as CURR_HUM_PRESS
+    (*_TFT).DL(TAG_MASK(1));
+    (*_TFT).DL(TAG(CURR_HUM_PRESS));
+    (*_TFT).DL(COLOR_RGB(9, 0, 63));
+    // if rectangle is already pressed, draw it with lighter color
+    if (pressedButton == CURR_HUM_PRESS) {
+        (*_TFT).DL(COLOR_RGB(75, 70, 108));
+    }
+    (*_TFT).DL(BEGIN(RECTS));
+    (*_TFT).DL(VERTEX2II(12, 62, 0, 0));
+    (*_TFT).DL(VERTEX2II(12 + 400, 62 + 93, 0, 0));
+    (*_TFT).DL(COLOR_RGB(255, 255, 255));
+    (*_TFT).Text(12 + 10, 62 + 5, 30, 0, "Current humidity (rH)");
+    CreateStringTempHum(humidityStr, humidity, 0);
+    (*_TFT).Text(12 + 10, 62 + 45, 31, 0, humidityStr);
+    (*_TFT).DL(TAG_MASK(0));
+
+    // create blue rectangle with current temperature including 
+    // rectangle is tagged as CURR_TEMP_PRESS
+    (*_TFT).DL(TAG_MASK(1));
+    (*_TFT).DL(TAG(CURR_TEMP_PRESS));
+    (*_TFT).DL(COLOR_RGB(9, 0, 63));
+    // if rectangle is already pressed, draw it with lighter color
+    if (pressedButton == CURR_TEMP_PRESS) {
+        (*_TFT).DL(COLOR_RGB(75, 70, 108));
+    }
+    (*_TFT).DL(BEGIN(RECTS));
+    (*_TFT).DL(VERTEX2II(12, 62 + 93 + 12, 0, 0));
+    (*_TFT).DL(VERTEX2II(12 + 400, 62 + 93 + 12 + 93, 0, 0));
+    (*_TFT).DL(COLOR_RGB(255, 255, 255));
+    (*_TFT).Text(12 + 10, 62 + 93 + 12 + 5, 30, 0, "Current temperature");
+    CreateStringTempHum(temperatureStr, temperature, 1);
+    (*_TFT).Text(12 + 10, 62 + 93 + 12 + 45, 31, 0, temperatureStr);
+    (*_TFT).DL(TAG_MASK(0));
+    
+    // finish FT800 display list
+    FinishDL();
+}
+         
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.Draw_MainMenuReference.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,18 @@
+#include "display.h"
+ 
+/**************************************************************************************************************************
+************************** Draw link to the main menu screen **************************************************************
+**************************************************************************************************************************/
+void Display::MainMenuReference()
+{
+    (*_TFT).DL(COLOR_RGB(0, 0, 0));
+    (*_TFT).DL(TAG_MASK(1));
+    (*_TFT).DL(TAG(MENU_PRESS));
+    (*_TFT).Text(14, 240, 22, 0, "Back to main menu");
+    (*_TFT).DL(BEGIN(LINES));
+    (*_TFT).DL(LINE_WIDTH(8));
+    (*_TFT).DL(VERTEX2F(15 * 16, 260 * 16));
+    (*_TFT).DL(VERTEX2F(155 * 16, 260 * 16));
+    (*_TFT).DL(TAG_MASK(0));
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.GetTouch.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,9 @@
+#include "display.h"
+ 
+/**************************************************************************************************************************
+************************** Get number of touched object *******************************************************************
+**************************************************************************************************************************/
+char Display::GetTouch()
+{   
+    return (*_TFT).Rd8(REG_TOUCH_TAG);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.StringsTransforming.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,51 @@
+#include "display.h"
+
+/**************************************************************************************************************************
+************************** Transform humiditity / temperature float value to string ***************************************
+**************************************************************************************************************************/
+// If isTemp = 0, string includes
+// 1. current humididty
+// 3. " %"
+
+// If isTemp = 1, string includes
+// 1. "-" (optional),
+// 2. current temperature with decimal mark
+// 3. " С"
+void Display::CreateStringTempHum(char *str, float number, bool isTemp)
+{
+    short int multipedNumber = (short int)(number * 100);
+    char strCnt = 0;
+    if (isTemp) {
+        if (multipedNumber < 0) {
+            multipedNumber = -multipedNumber;
+            str[strCnt] = '-';
+            strCnt++;
+        }
+    }
+    if (multipedNumber >= 10000) {
+        str[strCnt] = '0' + (multipedNumber % 100000) / 10000;
+        strCnt++;
+    }
+    if (multipedNumber >= 1000) {
+        str[strCnt] = '0' + (multipedNumber % 10000) / 1000;
+        strCnt++;
+    }
+    if (multipedNumber >= 100) {
+        str[strCnt] = '0' + (multipedNumber % 1000) / 100;
+        strCnt++;
+    }
+    if (isTemp) {
+        str[strCnt] = '.';
+        strCnt++;
+        str[strCnt] = '0' + (multipedNumber % 100) / 10;
+        strCnt++;
+        str[strCnt] = ' ';
+        strCnt++;
+        str[strCnt] = 'C';
+        strCnt++;
+    } else {
+        str[strCnt] = '%';
+        strCnt++;
+    }
+    str[strCnt] = 0;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/display.h	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,71 @@
+#include "mbed.h"
+#include "FT_Platform.h"
+#include <string>
+
+#ifndef DISPLAY_H_
+#define DISPLAY_H_
+
+/**************************************************************************************************************************
+************************** Defines using for drawing **********************************************************************
+**************************************************************************************************************************/
+
+// all tracking touch screen areas
+typedef enum {
+    NONE_PRESS,
+    CURR_TEMP_PRESS,
+    CURR_HUM_PRESS,
+    MENU_PRESS,
+} pressValues;
+
+// all existing screens 
+typedef enum {
+    MENU_SCREEN,
+    CURR_HUM_SCREEN,
+    CURR_TEMP_SCREEN,
+} screenValues;
+
+
+/**************************************************************************************************************************
+************************** User class for drawing at FT800 ****************************************************************
+**************************************************************************************************************************/
+
+class Display
+{
+public:
+    // in Display class we use FT800 TFT (definition is available in main.cpp)
+    Display(FT813 *TFT) {
+        _TFT = TFT;
+    }
+
+    // functions describing all available screens (screens-functions)
+    void MainMenu(float humidity, float temperature);   // [display.Draw_MainMenu.cpp]
+    void CurrentHumidity(float humidity);               // [display.Draw_CurrentValuesGraphs.cpp]
+    void CurrentTemperature(float temperature);         // [display.Draw_CurrentValuesGraphs.cpp]
+
+    // functions using to prepare FT800
+    void Calibration(void);                             // [display.Calibration.cpp]
+
+    // functions for touch screen tracking
+    char GetTouch(void);                                // [display.GetTouch.cpp]
+
+    // variables using for navigation between screens
+    char pressedButton;
+    char activeScreen;
+
+private:
+    FT813 *_TFT;
+
+    void StartDL(void);                                 // [display.DisplayListFunctions.cpp]
+    void FinishDL(void);                                // [display.DisplayListFunctions.cpp]
+    void MainMenuReference(void);                       // [display.Draw_MainMenuReference.cpp]
+    void HorisontalGrid_CurrentTemp(void);              // [display.Draw_Grids.cpp]
+    void HorisontalGrid_CurrentHumidity(void);          // [display.Draw_Grids.cpp]
+
+    void CreateStringTempHum(char *str, float number, bool isTemp);       // [display.StringsTransforming.cpp]
+
+    char humidityStr[8], temperatureStr[8];
+    char currentHumidity_X, currentTemperature_X;
+    char currentHumidity_Y[68], currentTemperature_Y[68];
+};
+
+#endif /* SCREENS_H_ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "FT_Platform.h"
+#include "HYT.h"
+#include "display.h"
+ 
+// NUCLEO-F429ZI
+HYT SENSOR (D14, D15); // sda, scl
+FT813 TFT (D11, D12, D13, D10, D9, D8); // mosi, miso, sck, ss, int, pd
+ 
+Display disp(&TFT);
+ 
+/**************************************************************************************************************************
+************************** HYT sensor polling cycle ***********************************************************************
+**************************************************************************************************************************/
+void dataUpdate(void)
+{
+    SENSOR.MRCommand();
+    wait_ms(100);
+    SENSOR.DFCommand();
+}
+ 
+/**************************************************************************************************************************
+************************** Main function **********************************************************************************
+**************************************************************************************************************************/
+
+int main()
+{
+    
+    disp.Calibration();
+ 
+    disp.activeScreen = MENU_SCREEN;
+    disp.pressedButton = NONE_PRESS;
+ 
+    // change active screen depending on pressed area
+    while(1) {
+        dataUpdate();
+        disp.pressedButton = disp.GetTouch();
+ 
+        // ----------------------------------------------------------------------------------------------
+        // Main menu screen
+        if (disp.activeScreen == MENU_SCREEN) {
+            disp.MainMenu(SENSOR.humidity, SENSOR.temperature);
+            if (disp.pressedButton) {
+                wait_ms(150);
+                if (disp.pressedButton == CURR_TEMP_PRESS) {
+                    disp.activeScreen = CURR_TEMP_SCREEN;
+                } else if (disp.pressedButton == CURR_HUM_PRESS) {
+                    disp.activeScreen = CURR_HUM_SCREEN;
+                } 
+                disp.pressedButton = NONE_PRESS;
+            }
+ 
+        // ----------------------------------------------------------------------------------------------
+        // Any other screen
+        } else {
+            // ----------------------------------------------------------------------------------------------
+            // You can back to main menu from any screen
+            if (disp.pressedButton == MENU_PRESS) {
+                disp.pressedButton = NONE_PRESS;
+                disp.activeScreen = MENU_SCREEN;
+            } else {
+                // ----------------------------------------------------------------------------------------------
+                // Screen with current temperature / humidity
+                if (disp.activeScreen == CURR_TEMP_SCREEN) {
+                    disp.CurrentTemperature(SENSOR.temperature);
+                } else if (disp.activeScreen == CURR_HUM_SCREEN) {
+                    disp.CurrentHumidity(SENSOR.humidity);
+                } 
+            }
+        }
+    }
+}
+            
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 18 13:18:02 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file