Русифицированная версия программы для измерения температуры и отн. влажности и вывода информации на сенсорный TFT
Dependencies: FT800_2 HYT mbed
display.Draw_30minStatistics.cpp
00001 #include "display.h" 00002 00003 /************************************************************************************************************************** 00004 ************************** Display data about humidity in the 30-minutes interval ***************************************** 00005 **************************************************************************************************************************/ 00006 00007 void Display::StatHumidity_30min(volatile uint64_t seconds, short int statistics24hrs[3][288], uint64_t gridSecondsOffset) 00008 { 00009 // start FT800 display list 00010 StartDL(); 00011 00012 // mark the plot area as touch input (to return to 24-hrs statistics) 00013 (*_TFT).DL(COLOR_RGB(213, 213, 213)); 00014 (*_TFT).DL(TAG_MASK(1)); 00015 (*_TFT).DL(TAG(STAT_HUM_PRESS)); 00016 (*_TFT).DL(BEGIN(RECTS)); 00017 (*_TFT).DL(VERTEX2II(25, 100, 0, 0)); 00018 (*_TFT).DL(VERTEX2II(433, 200, 0, 0)); 00019 (*_TFT).DL(TAG_MASK(0)); 00020 00021 // create time string, GridLines, link to main menu 00022 TimeSinceTurnOn(seconds); 00023 VerticalGrid30min(gridSecondsOffset); 00024 HorisontalGrid_Statistics_Humidity(); 00025 MainMenuReference(); 00026 00027 // draw graph line 00028 for (int i = 0; i < 6; i++) { 00029 char currentValue = statistics24hrs[0][i + timePoint3hrs + timePoint30min]; 00030 char currentMinValue = statistics24hrs[1][i + timePoint3hrs + timePoint30min]; 00031 char currentMaxValue = statistics24hrs[2][i + timePoint3hrs + timePoint30min]; 00032 if (currentValue != INIT_STATISTICS_NUMBER && (i + timePoint3hrs + timePoint30min) != 0) { 00033 if (currentMaxValue - currentMinValue >= DELTA_HUMIDITY) { 00034 (*_TFT).DL(COLOR_RGB(207, 45, 13)); 00035 (*_TFT).Number(i * 68, 200 - currentMaxValue - 15, 26, 0, currentMaxValue); 00036 (*_TFT).Number(i * 68, 200 - currentMinValue + 1, 26, 0, currentMinValue); 00037 (*_TFT).Number(i * 68 + 43, 200 - currentValue - 7, 26, 0, currentValue); 00038 } else { 00039 (*_TFT).DL(COLOR_RGB(9, 0, 63)); 00040 (*_TFT).Number(i * 68 + 43, 200 - currentValue - 7, 26, 0, currentValue); 00041 } 00042 (*_TFT).DL(BEGIN(LINES)); 00043 (*_TFT).DL(LINE_WIDTH(16)); 00044 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue) * 16)); 00045 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentMaxValue) * 16)); 00046 (*_TFT).DL(VERTEX2F((i * 68 + 10) * 16, (200 - currentMaxValue) * 16)); 00047 (*_TFT).DL(VERTEX2F((i * 68 + 40) * 16, (200 - currentMaxValue) * 16)); 00048 (*_TFT).DL(END()); 00049 00050 (*_TFT).DL(BEGIN(LINES)); 00051 (*_TFT).DL(LINE_WIDTH(16)); 00052 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue) * 16)); 00053 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentMinValue) * 16)); 00054 (*_TFT).DL(VERTEX2F((i * 68 + 10) * 16, (200 - currentMinValue) * 16)); 00055 (*_TFT).DL(VERTEX2F((i * 68 + 40) * 16, (200 - currentMinValue) * 16)); 00056 (*_TFT).DL(END()); 00057 00058 (*_TFT).DL(BEGIN(POINTS)); 00059 (*_TFT).DL(POINT_SIZE(70)); 00060 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue) * 16)); 00061 (*_TFT).DL(END()); 00062 00063 (*_TFT).DL(BEGIN(LINES)); 00064 (*_TFT).DL(LINE_WIDTH(24)); 00065 (*_TFT).DL(VERTEX2F((i * 68 + 15) * 16, (200 - currentValue) * 16)); 00066 (*_TFT).DL(VERTEX2F((i * 68 + 35) * 16, (200 - currentValue) * 16)); 00067 (*_TFT).DL(END()); 00068 } 00069 if (timePoint3hrs + timePoint30min == 0) { 00070 (*_TFT).DL(COLOR_RGB(9, 0, 63)); 00071 (*_TFT).DL(BEGIN(POINTS)); 00072 (*_TFT).DL(POINT_SIZE(70)); 00073 (*_TFT).DL(VERTEX2F(25 * 16, (200 - statistics24hrs[0][0]) * 16)); 00074 (*_TFT).DL(END()); 00075 } 00076 } 00077 00078 // write main title 00079 (*_TFT).DL(COLOR_RGB(0, 0, 0)); 00080 CreateStringRussian("Отн. влажность за 30 минут"); 00081 (*_TFT).Text(15, 15, 3, 0, russianStr); 00082 00083 // finish FT800 display list 00084 FinishDL(); 00085 } 00086 00087 /************************************************************************************************************************** 00088 ************************** Display data about temperature in the 30-minutes interval ************************************** 00089 **************************************************************************************************************************/ 00090 00091 void Display::StatTemperature_30min(volatile uint64_t seconds, short int statistics24hrs[3][288], uint64_t gridSecondsOffset) 00092 { 00093 // strings needed to output temperature values with decimal mark 00094 char currentValueStr[8], currentMinValueStr[8], currentMaxValueStr[8]; 00095 00096 // start FT800 display list 00097 StartDL(); 00098 00099 // mark the plot area as touch input (to return to 24-hrs statistics) 00100 (*_TFT).DL(COLOR_RGB(213, 213, 213)); 00101 (*_TFT).DL(TAG_MASK(1)); 00102 (*_TFT).DL(TAG(STAT_TEMP_PRESS)); 00103 (*_TFT).DL(BEGIN(RECTS)); 00104 (*_TFT).DL(VERTEX2II(25, 100, 0, 0)); 00105 (*_TFT).DL(VERTEX2II(433, 200, 0, 0)); 00106 (*_TFT).DL(TAG_MASK(0)); 00107 00108 // create time string, GridLines, link to main menu 00109 TimeSinceTurnOn(seconds); 00110 VerticalGrid30min(gridSecondsOffset); 00111 HorisontalGrid_Statistics_Temperature(); 00112 MainMenuReference(); 00113 00114 // draw graph line 00115 // Temperature values are multiplied by 10 in the statistics data array. 00116 // To receive "normal" temperature with decimal mark we have to divide it 00117 for (int i = 0; i < 6; i++) { 00118 char currentValue_toDraw = (statistics24hrs[0][i + timePoint3hrs + timePoint30min] / TEMPERATURE_MULTIPLIER + 50) * 0.57; 00119 char currentMinValue_toDraw = (statistics24hrs[1][i + timePoint3hrs + timePoint30min] / TEMPERATURE_MULTIPLIER + 50) * 0.57; 00120 char currentMaxValue_toDraw = (statistics24hrs[2][i + timePoint3hrs + timePoint30min] / TEMPERATURE_MULTIPLIER + 50) * 0.57; 00121 00122 short int currentValue_multiplied = statistics24hrs[0][i + timePoint3hrs + timePoint30min]; 00123 CreateStringMultipliedTemp(currentValueStr, currentValue_multiplied); 00124 short int currentMinValue_multiplied = statistics24hrs[1][i + timePoint3hrs + timePoint30min]; 00125 CreateStringMultipliedTemp(currentMinValueStr, currentMinValue_multiplied); 00126 short int currentMaxValue_multiplied = statistics24hrs[2][i + timePoint3hrs + timePoint30min]; 00127 CreateStringMultipliedTemp(currentMaxValueStr, currentMaxValue_multiplied); 00128 00129 short int delta = currentMaxValue_multiplied - currentMinValue_multiplied; 00130 if (currentValue_multiplied != INIT_STATISTICS_NUMBER && (i + timePoint3hrs + timePoint30min) != 0) { 00131 if (delta >= DELTA_TEMPERATURE * TEMPERATURE_MULTIPLIER) { 00132 (*_TFT).DL(COLOR_RGB(207, 45, 13)); 00133 (*_TFT).Text(i * 68 + 5, 200 - currentMaxValue_toDraw - 17, 20, 0, currentMaxValueStr); 00134 (*_TFT).Text(i * 68 + 5, 200 - currentMinValue_toDraw + 3, 20, 0, currentMinValueStr); 00135 (*_TFT).Text(i * 68 + 43, 200 - currentValue_toDraw - 7, 26, 0, currentValueStr); 00136 } else { 00137 (*_TFT).DL(COLOR_RGB(9, 0, 63)); 00138 (*_TFT).Text(i * 68 + 43, 200 - currentValue_toDraw - 7, 26, 0, currentValueStr); 00139 } 00140 (*_TFT).DL(BEGIN(LINES)); 00141 (*_TFT).DL(LINE_WIDTH(16)); 00142 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue_toDraw) * 16)); 00143 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentMaxValue_toDraw) * 16)); 00144 (*_TFT).DL(VERTEX2F((i * 68 + 10) * 16, (200 - currentMaxValue_toDraw) * 16)); 00145 (*_TFT).DL(VERTEX2F((i * 68 + 40) * 16, (200 - currentMaxValue_toDraw) * 16)); 00146 (*_TFT).DL(END()); 00147 00148 (*_TFT).DL(BEGIN(LINES)); 00149 (*_TFT).DL(LINE_WIDTH(16)); 00150 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue_toDraw) * 16)); 00151 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentMinValue_toDraw) * 16)); 00152 (*_TFT).DL(VERTEX2F((i * 68 + 10) * 16, (200 - currentMinValue_toDraw) * 16)); 00153 (*_TFT).DL(VERTEX2F((i * 68 + 40) * 16, (200 - currentMinValue_toDraw) * 16)); 00154 (*_TFT).DL(END()); 00155 00156 (*_TFT).DL(BEGIN(POINTS)); 00157 (*_TFT).DL(POINT_SIZE(70)); 00158 (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue_toDraw) * 16)); 00159 (*_TFT).DL(END()); 00160 00161 (*_TFT).DL(BEGIN(LINES)); 00162 (*_TFT).DL(LINE_WIDTH(24)); 00163 (*_TFT).DL(VERTEX2F((i * 68 + 15) * 16, (200 - currentValue_toDraw) * 16)); 00164 (*_TFT).DL(VERTEX2F((i * 68 + 35) * 16, (200 - currentValue_toDraw) * 16)); 00165 (*_TFT).DL(END()); 00166 } 00167 if (timePoint3hrs + timePoint30min == 0) { 00168 (*_TFT).DL(COLOR_RGB(9, 0, 63)); 00169 (*_TFT).DL(BEGIN(POINTS)); 00170 (*_TFT).DL(POINT_SIZE(70)); 00171 (*_TFT).DL(VERTEX2F(25 * 16, (200 - statistics24hrs[0][0]) * 16)); 00172 (*_TFT).DL(END()); 00173 } 00174 } 00175 00176 // write main title 00177 (*_TFT).DL(COLOR_RGB(0, 0, 0)); 00178 CreateStringRussian("Температура за 30 минут"); 00179 (*_TFT).Text(15, 15, 3, 0, russianStr); 00180 00181 // finish FT800 display list 00182 FinishDL(); 00183 }
Generated on Wed Jul 13 2022 04:41:34 by
1.7.2