Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "FT_Platform.h" 00003 #include "HYT.h" 00004 #include "display.h" 00005 00006 // NUCLEO-F429ZI 00007 HYT SENSOR (D14, D15); // sda, scl 00008 FT813 TFT (D11, D12, D13, D10, D9, D8); // mosi, miso, sck, ss, int, pd 00009 00010 Display disp(&TFT); 00011 00012 /************************************************************************************************************************** 00013 ************************** HYT sensor polling cycle *********************************************************************** 00014 **************************************************************************************************************************/ 00015 void dataUpdate(void) 00016 { 00017 SENSOR.MRCommand(); 00018 wait_ms(100); 00019 SENSOR.DFCommand(); 00020 } 00021 00022 /************************************************************************************************************************** 00023 ************************** Main function ********************************************************************************** 00024 **************************************************************************************************************************/ 00025 00026 int main() 00027 { 00028 00029 disp.Calibration(); 00030 00031 disp.activeScreen = MENU_SCREEN; 00032 disp.pressedButton = NONE_PRESS; 00033 00034 // change active screen depending on pressed area 00035 while(1) { 00036 dataUpdate(); 00037 disp.pressedButton = disp.GetTouch(); 00038 00039 // ---------------------------------------------------------------------------------------------- 00040 // Main menu screen 00041 if (disp.activeScreen == MENU_SCREEN) { 00042 disp.MainMenu(SENSOR.humidity, SENSOR.temperature); 00043 if (disp.pressedButton) { 00044 wait_ms(150); 00045 if (disp.pressedButton == CURR_TEMP_PRESS) { 00046 disp.activeScreen = CURR_TEMP_SCREEN; 00047 } else if (disp.pressedButton == CURR_HUM_PRESS) { 00048 disp.activeScreen = CURR_HUM_SCREEN; 00049 } 00050 disp.pressedButton = NONE_PRESS; 00051 } 00052 00053 // ---------------------------------------------------------------------------------------------- 00054 // Any other screen 00055 } else { 00056 // ---------------------------------------------------------------------------------------------- 00057 // You can back to main menu from any screen 00058 if (disp.pressedButton == MENU_PRESS) { 00059 disp.pressedButton = NONE_PRESS; 00060 disp.activeScreen = MENU_SCREEN; 00061 } else { 00062 // ---------------------------------------------------------------------------------------------- 00063 // Screen with current temperature / humidity 00064 if (disp.activeScreen == CURR_TEMP_SCREEN) { 00065 disp.CurrentTemperature(SENSOR.temperature); 00066 } else if (disp.activeScreen == CURR_HUM_SCREEN) { 00067 disp.CurrentHumidity(SENSOR.humidity); 00068 } 00069 } 00070 } 00071 } 00072 } 00073
Generated on Tue Jul 12 2022 18:31:54 by
1.7.2