![](/media/cache/profiles/9f0876a200701e5fdece2e58aa965574.jpg.50x50_q85.jpg)
Русифицированная версия программы для измерения температуры и отн. влажности и вывода информации на сенсорный TFT
Dependencies: FT800_2 HYT mbed
display.Draw_CurrentValues.cpp
00001 #include "display.h" 00002 00003 /************************************************************************************************************************** 00004 ************************** Display real-time humidity ********************************************************************* 00005 **************************************************************************************************************************/ 00006 00007 void Display::CurrentHumidity(float humidity) 00008 { 00009 // accelerator for x-axis data output 00010 char accelerator = 6; 00011 // create string including current humididty and " %" 00012 CreateStringTempHum(humidityStr, humidity, 0); 00013 // write the new scalable (* 1.5) data to the next available array position 00014 currentHumidity_Y[currentHumidity_X] = (char)(humidity * 1.5); 00015 00016 // start FT800 display list 00017 StartDL(); 00018 00019 // draw bottom color for graph line 00020 (*_TFT).DL(COLOR_RGB(200, 200, 200)); 00021 (*_TFT).DL(BEGIN(EDGE_STRIP_B)); 00022 for (int i = 0; i < 68; i++) { 00023 if (currentHumidity_Y[i] != 0 && i <= currentHumidity_X) { 00024 (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (220 - currentHumidity_Y[i]) * 16)); 00025 } 00026 } 00027 00028 // draw horisontal grid for humidity (0 .. 100) 00029 HorisontalGrid_Current_Humidity(); 00030 00031 // draw main graph line 00032 (*_TFT).DL(COLOR_RGB(9, 0, 63)); 00033 (*_TFT).DL(BEGIN(POINTS)); 00034 (*_TFT).DL(POINT_SIZE(25)); 00035 for (int i = 0; i < 68; i++) { 00036 if (currentHumidity_Y[i] != 0 && (i < currentHumidity_X || i >= currentHumidity_X + 13)) { 00037 (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (222 - currentHumidity_Y[i]) * 16)); 00038 } 00039 } 00040 00041 // draw subtitle for main graph line 00042 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00043 (*_TFT).DL(BEGIN(RECTS)); 00044 (*_TFT).DL(VERTEX2II((currentHumidity_X * accelerator + 40) + 25, (200 - currentHumidity_Y[currentHumidity_X]), 0, 0)); 00045 (*_TFT).DL(VERTEX2II((currentHumidity_X * accelerator + 40), (177 - currentHumidity_Y[currentHumidity_X]), 0, 0)); 00046 (*_TFT).DL(COLOR_RGB(255, 0, 0)); 00047 (*_TFT).Text((currentHumidity_X * accelerator + 30), (180 - currentHumidity_Y[currentHumidity_X] - 7), 28, 0, humidityStr); 00048 (*_TFT).DL(BEGIN(LINES)); 00049 (*_TFT).DL(LINE_WIDTH(8)); 00050 (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 15) * 16, (220 - currentHumidity_Y[currentHumidity_X]) * 16)); 00051 (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 35) * 16, (200 - currentHumidity_Y[currentHumidity_X]) * 16)); 00052 (*_TFT).DL(COLOR_RGB(255, 30, 33)); 00053 (*_TFT).DL(BEGIN(POINTS)); 00054 (*_TFT).DL(POINT_SIZE(33)); 00055 (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 15) * 16, (220 - currentHumidity_Y[currentHumidity_X]) * 16)); 00056 (*_TFT).DL(END()); 00057 00058 // write main title 00059 (*_TFT).DL(COLOR_RGB(0, 0, 0)); 00060 CreateStringRussian("Относительная влажность"); 00061 (*_TFT).Text(15, 15, 3, 0, russianStr); 00062 00063 // clean the space under the plot, create link to the main menu 00064 (*_TFT).DL(SCISSOR_XY(15, 222)); 00065 (*_TFT).DL(SCISSOR_SIZE(420, 53)); 00066 (*_TFT).Gradient(0, 256, 0xFFFFFF, 450, 16, 0xFFFFFF); 00067 MainMenuReference(); 00068 00069 // finish FT800 display list 00070 FinishDL(); 00071 00072 // manage the index for array with real-time humidity 00073 if (currentHumidity_X >= 68) { 00074 currentHumidity_X = 0; 00075 } else { 00076 currentHumidity_X ++; 00077 } 00078 if (pressedButton == MENU_PRESS) { 00079 for (int i = 0; i < 68; i++) { 00080 currentHumidity_Y[i] = 0; 00081 currentHumidity_X = 0; 00082 } 00083 } 00084 } 00085 00086 /************************************************************************************************************************** 00087 ************************** Display real-time temperature ****************************************************************** 00088 **************************************************************************************************************************/ 00089 00090 void Display::CurrentTemperature(float temperature) 00091 { 00092 // accelerator for x-axis data output 00093 char accelerator = 6; 00094 // create string including current temperature with decimal mark and " С" 00095 char degreeOffset = CreateStringTempHum(temperatureStr, temperature, 1); 00096 // write the new scalable (* 0.88 + 45) data to the next available array position 00097 currentTemperature_Y[currentTemperature_X] = (char)(temperature * 0.88 + 45); 00098 00099 // start FT800 display list 00100 StartDL(); 00101 00102 // draw bottom color for graph line 00103 (*_TFT).DL(COLOR_RGB(200, 177, 199)); 00104 (*_TFT).DL(BEGIN(EDGE_STRIP_B)); 00105 for (int i = 0; i < 68; i++) { 00106 if (currentTemperature_Y[i] != 0 && i <= currentTemperature_X) { 00107 (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (220 - currentTemperature_Y[i]) * 16)); 00108 } 00109 } 00110 00111 // draw horisontal grid for temperature (-50 .. +125) 00112 HorisontalGrid_Current_Temperature(); 00113 00114 // draw main graph line 00115 (*_TFT).DL(COLOR_RGB(9, 0, 63)); 00116 (*_TFT).DL(BEGIN(POINTS)); 00117 (*_TFT).DL(POINT_SIZE(25)); 00118 for (int i = 0; i < 68; i++) { 00119 if (currentTemperature_Y[i] != 0 && (i < currentTemperature_X || i >= currentTemperature_X + 13)) { 00120 (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (222 - currentTemperature_Y[i]) * 16)); 00121 } 00122 } 00123 00124 // draw subtitle for main graph line 00125 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00126 (*_TFT).DL(BEGIN(RECTS)); 00127 (*_TFT).DL(VERTEX2II((currentTemperature_X * accelerator + 40) + 25, (200 - currentTemperature_Y[currentTemperature_X]), 0, 0)); 00128 (*_TFT).DL(VERTEX2II((currentTemperature_X * accelerator + 40), (177 - currentTemperature_Y[currentTemperature_X]), 0, 0)); 00129 (*_TFT).DL(COLOR_RGB(255, 0, 0)); 00130 (*_TFT).Text((currentTemperature_X * accelerator + 25), (173 - currentTemperature_Y[currentTemperature_X]), 28, 0, temperatureStr); 00131 (*_TFT).Text((currentTemperature_X * accelerator + 25) + (degreeOffset * 8 + 3), (173 - currentTemperature_Y[currentTemperature_X]) - 4, 20, 0, "o"); 00132 (*_TFT).DL(BEGIN(LINES)); 00133 (*_TFT).DL(LINE_WIDTH(8)); 00134 (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 15) * 16, (220 - currentTemperature_Y[currentTemperature_X]) * 16)); 00135 (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 35) * 16, (200 - currentTemperature_Y[currentTemperature_X]) * 16)); 00136 (*_TFT).DL(COLOR_RGB(255, 30, 33)); 00137 (*_TFT).DL(BEGIN(POINTS)); 00138 (*_TFT).DL(POINT_SIZE(33)); 00139 (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 15) * 16, (220 - currentTemperature_Y[currentTemperature_X]) * 16)); 00140 (*_TFT).DL(END()); 00141 00142 // write main title 00143 (*_TFT).DL(COLOR_RGB(0, 0, 0)); 00144 CreateStringRussian("Температура"); 00145 (*_TFT).Text(15, 15, 3, 0, russianStr); 00146 00147 // clean the space under the plot, create link to the main menu 00148 (*_TFT).DL(SCISSOR_XY(15, 225)); 00149 (*_TFT).DL(SCISSOR_SIZE(420, 53)); 00150 (*_TFT).Gradient(0, 256, 0xFFFFFF, 450, 16, 0xFFFFFF); 00151 MainMenuReference(); 00152 00153 // finish FT800 display list 00154 FinishDL(); 00155 00156 if (currentTemperature_X >= 68) { 00157 currentTemperature_X = 0; 00158 } else { 00159 currentTemperature_X ++; 00160 } 00161 if (pressedButton == MENU_PRESS) { 00162 for (int i = 0; i < 68; i++) { 00163 currentTemperature_Y[i] = 0; 00164 currentTemperature_X = 0; 00165 } 00166 } 00167 }
Generated on Wed Jul 13 2022 04:41:34 by
![doxygen](doxygen.png)