HYT humidity & temp sensor polling / showing received data at TFT with capacitive touchscreen
Dependencies: FT800_2 HYT mbed
display.Draw_MainMenu.cpp
00001 #include "display.h" 00002 00003 /************************************************************************************************************************** 00004 ************************** Display Main Menu ****************************************************************************** 00005 **************************************************************************************************************************/ 00006 00007 void Display::MainMenu(float humidity, float temperature) 00008 { 00009 // start FT800 display list 00010 StartDL(); 00011 00012 // write main title 00013 (*_TFT).DL(COLOR_RGB(0, 0, 0)); 00014 00015 (*_TFT).Text(11, 15, 30, 0, "HYT-271 sensor from IST"); 00016 00017 // create blue rectangle with current humididty including 00018 // rectangle is tagged as CURR_HUM_PRESS 00019 (*_TFT).DL(TAG_MASK(1)); 00020 (*_TFT).DL(TAG(CURR_HUM_PRESS)); 00021 (*_TFT).DL(COLOR_RGB(9, 0, 63)); 00022 // if rectangle is already pressed, draw it with lighter color 00023 if (pressedButton == CURR_HUM_PRESS) { 00024 (*_TFT).DL(COLOR_RGB(75, 70, 108)); 00025 } 00026 (*_TFT).DL(BEGIN(RECTS)); 00027 (*_TFT).DL(VERTEX2II(12 + 222 + 12, 62, 0, 0)); 00028 (*_TFT).DL(VERTEX2II(12 + 222 + 12 + 222, 62 + 124, 0, 0)); 00029 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00030 (*_TFT).Text(12 + 222 + 12 + 10, 62 + 5, 29, 0, "Current"); 00031 (*_TFT).Text(12 + 222 + 12 + 10, 62 + 35, 29, 0, "humidity (rH)"); 00032 CreateStringTempHum(humidityStr, humidity, 0); 00033 (*_TFT).Text(12 + 222 + 12 + 10, 62 + 75, 31, 0, humidityStr); 00034 (*_TFT).DL(BEGIN(BITMAPS)); 00035 (*_TFT).DL(VERTEX2II(12 + 222 + 10 + 180, 62 + 10, 0, 0)); 00036 (*_TFT).DL(END()); 00037 (*_TFT).DL(TAG_MASK(0)); 00038 00039 // create blue rectangle with current temperature including 00040 // rectangle is tagged as CURR_TEMP_PRESS 00041 (*_TFT).DL(TAG_MASK(1)); 00042 (*_TFT).DL(TAG(CURR_TEMP_PRESS)); 00043 (*_TFT).DL(COLOR_RGB(9, 0, 63)); 00044 // if rectangle is already pressed, draw it with lighter color 00045 if (pressedButton == CURR_TEMP_PRESS) { 00046 (*_TFT).DL(COLOR_RGB(75, 70, 108)); 00047 } 00048 (*_TFT).DL(BEGIN(RECTS)); 00049 (*_TFT).DL(VERTEX2II(12, 62, 0, 0)); 00050 (*_TFT).DL(VERTEX2II(12 + 222, 62 + 124, 0, 0)); 00051 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00052 (*_TFT).Text(12 + 10, 62 + 5, 29, 0, "Current"); 00053 (*_TFT).Text(12 + 10, 62 + 35, 29, 0, "temperature"); 00054 char degreeOffset = CreateStringTempHum(temperatureStr, temperature, 1); 00055 (*_TFT).Text(12 + 10, 62 + 75, 31, 0, temperatureStr); 00056 (*_TFT).Text(12 + 10 + (degreeOffset * 16 + 3), 62 + 75 - 2, 28, 0, "o"); 00057 (*_TFT).DL(BEGIN(BITMAPS)); 00058 (*_TFT).DL(VERTEX2II(12 + 10 + 180, 62 + 7, 1, 0)); 00059 (*_TFT).DL(END()); 00060 (*_TFT).DL(TAG_MASK(0)); 00061 00062 // create black rectangle tagged as STAT_HUM_PRESS 00063 (*_TFT).DL(TAG_MASK(1)); 00064 (*_TFT).DL(TAG(STAT_HUM_PRESS)); 00065 (*_TFT).DL(COLOR_RGB(36, 36, 36)); 00066 // if rectangle is already pressed, draw it with lighter color 00067 if (pressedButton == STAT_HUM_PRESS) { 00068 (*_TFT).DL(COLOR_RGB(56, 56, 56)); 00069 } 00070 (*_TFT).DL(BEGIN(RECTS)); 00071 (*_TFT).DL(VERTEX2II(12, 62 + 124 + 12, 0, 0)); 00072 (*_TFT).DL(VERTEX2II(12 + 144, 62 + 124 + 12 + 62, 0, 0)); 00073 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00074 (*_TFT).Text(12 + 10, 62 + 124 + 12 + 5, 27, 0, "Humidity"); 00075 (*_TFT).Text(12 + 10, 62 + 124 + 12 + 30, 27, 0, "statisticss"); 00076 (*_TFT).DL(TAG_MASK(0)); 00077 00078 // create black rectangle tagged as STAT_TEMP_PRESS 00079 (*_TFT).DL(TAG_MASK(1)); 00080 (*_TFT).DL(TAG(STAT_TEMP_PRESS)); 00081 (*_TFT).DL(COLOR_RGB(36, 36, 36)); 00082 // if rectangle is already pressed, draw it lighter 00083 if (pressedButton == STAT_TEMP_PRESS) { 00084 (*_TFT).DL(COLOR_RGB(56, 56, 56)); 00085 } 00086 (*_TFT).DL(BEGIN(RECTS)); 00087 (*_TFT).DL(VERTEX2II(12 + 144 + 12, 62 + 124 + 12, 0, 0)); 00088 (*_TFT).DL(VERTEX2II(12 + 144 + 12 + 144, 62 + 124 + 12 + 62, 0, 0)); 00089 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00090 (*_TFT).Text(12 +144 + 12 + 10, 62 + 124 + 12 + 5, 27, 0, "Temperature"); 00091 (*_TFT).Text(12 + 144 + 12 + 10, 62 + 124 + 12 + 30, 27, 0, "statistics"); 00092 (*_TFT).DL(TAG_MASK(0)); 00093 00094 // create black rectangle tagged as ABOUT_PRESS 00095 (*_TFT).DL(TAG_MASK(1)); 00096 (*_TFT).DL(TAG(ABOUT_PRESS)); 00097 (*_TFT).DL(COLOR_RGB(36, 36, 36)); 00098 // if rectangle is already pressed, draw it lighter 00099 if (pressedButton == ABOUT_PRESS) { 00100 (*_TFT).DL(COLOR_RGB(56, 56, 56)); 00101 } 00102 (*_TFT).DL(BEGIN(RECTS)); 00103 (*_TFT).DL(VERTEX2II(12 + 144 + 12 + 144 + 12, 62 + 124 + 12, 0, 0)); 00104 (*_TFT).DL(VERTEX2II(12 + 144 + 12 + 144 + 12 + 144, 62 + 124 + 12 + 62, 0, 0)); 00105 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00106 (*_TFT).Text(12 + 144 + 12 + 144 + 12 + 10, 62 + 124 + 12 + 5, 27, 0, "About"); 00107 (*_TFT).Text(12 + 144 + 12 + 144 + 12 + 10, 62 + 124 + 12 + 30, 27, 0, "the sensor"); 00108 (*_TFT).DL(TAG_MASK(0)); 00109 00110 // finish FT800 display list 00111 FinishDL(); 00112 }
Generated on Tue Jul 12 2022 20:15:53 by
1.7.2