HYT humidity & temp sensor polling / showing received data at TFT with capacitive touchscreen

Dependencies:   FT800_2 HYT mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers display.Draw_3hrsStatistics.cpp Source File

display.Draw_3hrsStatistics.cpp

00001 #include "display.h"
00002 
00003 /**************************************************************************************************************************
00004 ************************** Display data about humidity in the three-hour interval *****************************************
00005 **************************************************************************************************************************/
00006 
00007 void Display::StatHumidity_3hrs(volatile uint64_t seconds, short int statistics24hrs[3][288], uint64_t gridSecondsOffset)
00008 {
00009     // start FT800 display list
00010     StartDL();
00011  
00012     // mark 6 areas for touch input (for zoom in),
00013     // make each every second zone gray, make the active zone green
00014     char ZonesCnt = 0;
00015     for (int i = 25; i < 433; i += 68) {
00016         (*_TFT).DL(COLOR_RGB(255, 255, 255));
00017         if (ZonesCnt % 2 == 0) {
00018             (*_TFT).DL(COLOR_RGB(233, 233, 233));
00019         }
00020         if (pressedButton - ZONE_1_PRESS == ZonesCnt) {
00021             (*_TFT).DL(COLOR_RGB(200, 255, 200));
00022             timePoint30min = 6 * ZonesCnt;
00023         }
00024         (*_TFT).DL(TAG_MASK(1));
00025         (*_TFT).DL(TAG(ZONE_1_PRESS + ZonesCnt));
00026         (*_TFT).DL(BEGIN(RECTS));
00027         (*_TFT).DL(VERTEX2II(i, 100, 0, 0));
00028         (*_TFT).DL(VERTEX2II(i + 68, 200, 0, 0));
00029         (*_TFT).DL(TAG_MASK(0));
00030         ZonesCnt++;
00031     }
00032     
00033     // create time string, GridLines, link to main menu 
00034     TimeSinceTurnOn(seconds);
00035     VerticalGrid3hrs(gridSecondsOffset);
00036     HorisontalGrid_Statistics_Humidity();
00037     MainMenuReference();
00038 
00039     // draw graph line
00040     for (int i = 0; i < 36; i++) {
00041         char currentValue = statistics24hrs[0][i + timePoint3hrs];
00042         char currentMinValue = statistics24hrs[1][i + timePoint3hrs];
00043         char currentMaxValue = statistics24hrs[2][i + timePoint3hrs];
00044         if (currentValue != INIT_STATISTICS_NUMBER) {
00045             (*_TFT).DL(COLOR_RGB(9, 0, 63));
00046             if (currentMaxValue - currentMinValue >= DELTA_HUMIDITY) {
00047                 (*_TFT).DL(COLOR_RGB(207, 45, 13));
00048                 (*_TFT).DL(BEGIN(LINES));
00049                 (*_TFT).DL(LINE_WIDTH(16));
00050                 (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentValue) * 16));
00051                 (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentMaxValue) * 16));
00052                 (*_TFT).DL(VERTEX2F(i * 181 + 22 * 16, (200 - currentMaxValue) * 16));
00053                 (*_TFT).DL(VERTEX2F(i * 181 + 28 * 16, (200 - currentMaxValue) * 16));
00054                 (*_TFT).DL(END());
00055                 (*_TFT).DL(BEGIN(LINES));
00056                 (*_TFT).DL(LINE_WIDTH(16));
00057                 (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentValue) * 16));
00058                 (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentMinValue) * 16));
00059                 (*_TFT).DL(VERTEX2F(i * 181 + 22 * 16, (200 - currentMinValue) * 16));
00060                 (*_TFT).DL(VERTEX2F(i * 181 + 28 * 16, (200 - currentMinValue) * 16));
00061                 (*_TFT).DL(END());
00062             } 
00063             (*_TFT).DL(BEGIN(POINTS));
00064             (*_TFT).DL(POINT_SIZE(45));
00065             (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentValue) * 16));
00066         }
00067     }
00068     
00069     // write main title
00070     (*_TFT).DL(COLOR_RGB(0, 0, 0));
00071     (*_TFT).Text(11, 15, 30, 0, "Humidity statistics (3 hrs)");
00072     
00073     // finish FT800 display list
00074     FinishDL();
00075 }
00076 
00077 /**************************************************************************************************************************
00078 ************************** Display data about temeprature in the three-hour interval **************************************
00079 **************************************************************************************************************************/
00080 void Display::StatTemperature_3hrs(volatile uint64_t seconds, short int statistics24hrs[3][288], uint64_t gridSecondsOffset) 
00081 {
00082     // start FT800 display list
00083     StartDL();
00084  
00085     // mark 6 areas for touch input (for zoom in),
00086     // make each every second zone gray, make the active zone green
00087     char ZonesCnt = 0;
00088     for (int i = 25; i < 433; i += 68) {
00089         (*_TFT).DL(COLOR_RGB(255, 255, 255));
00090         if (ZonesCnt % 2 == 0) {
00091             (*_TFT).DL(COLOR_RGB(233, 233, 233));
00092         }
00093         if (pressedButton - ZONE_1_PRESS == ZonesCnt) {
00094             (*_TFT).DL(COLOR_RGB(200, 255, 200));
00095             timePoint30min = 6 * ZonesCnt;
00096         }
00097         (*_TFT).DL(TAG_MASK(1));
00098         (*_TFT).DL(TAG(ZONE_1_PRESS + ZonesCnt));
00099         (*_TFT).DL(BEGIN(RECTS));
00100         (*_TFT).DL(VERTEX2II(i, 100, 0, 0));
00101         (*_TFT).DL(VERTEX2II(i + 68, 200, 0, 0));
00102         (*_TFT).DL(TAG_MASK(0));
00103         ZonesCnt++;
00104     }
00105 
00106     // create time string, GridLines, link to main menu 
00107     TimeSinceTurnOn(seconds);
00108     VerticalGrid3hrs(gridSecondsOffset);
00109     HorisontalGrid_Statistics_Temperature();
00110     MainMenuReference();
00111     
00112     // draw graph line
00113     for (int i = 0; i < 36; i++) {
00114         char currentValue = (statistics24hrs[0][i + timePoint3hrs] / TEMPERATURE_MULTIPLIER + 50) * 0.57;
00115         char currentMinValue = (statistics24hrs[1][i + timePoint3hrs] / TEMPERATURE_MULTIPLIER + 50) * 0.57;
00116         char currentMaxValue = (statistics24hrs[2][i + timePoint3hrs] / TEMPERATURE_MULTIPLIER + 50) * 0.57;
00117         char delta = statistics24hrs[2][i + timePoint3hrs] - statistics24hrs[1][i + timePoint3hrs];
00118         
00119         if (statistics24hrs[0][i + timePoint3hrs] != INIT_STATISTICS_NUMBER) {
00120             (*_TFT).DL(COLOR_RGB(9, 0, 63));
00121             if (delta >= DELTA_TEMPERATURE + TEMPERATURE_MULTIPLIER) {
00122                 (*_TFT).DL(COLOR_RGB(207, 45, 13));
00123                 (*_TFT).DL(BEGIN(LINES));
00124                 (*_TFT).DL(LINE_WIDTH(16));
00125                 (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentValue) * 16));
00126                 (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentMaxValue) * 16));
00127                 (*_TFT).DL(VERTEX2F(i * 181 + 22 * 16, (200 - currentMaxValue) * 16));
00128                 (*_TFT).DL(VERTEX2F(i * 181 + 28 * 16, (200 - currentMaxValue) * 16));
00129                 (*_TFT).DL(END());
00130                 (*_TFT).DL(BEGIN(LINES));
00131                 (*_TFT).DL(LINE_WIDTH(16));
00132                 (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentValue) * 16));
00133                 (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentMinValue) * 16));
00134                 (*_TFT).DL(VERTEX2F(i * 181 + 22 * 16, (200 - currentMinValue) * 16));
00135                 (*_TFT).DL(VERTEX2F(i * 181 + 28 * 16, (200 - currentMinValue) * 16));
00136                 (*_TFT).DL(END());
00137             } 
00138             (*_TFT).DL(BEGIN(POINTS));
00139             (*_TFT).DL(POINT_SIZE(45));
00140             (*_TFT).DL(VERTEX2F(i * 181 + 25 * 16, (200 - currentValue) * 16));
00141         }
00142     }
00143     
00144     // write main title
00145     (*_TFT).DL(COLOR_RGB(0, 0, 0));
00146     (*_TFT).Text(11, 15, 30, 0, "Temperature statistics (3 hrs)");
00147     
00148     // finish FT800 display list
00149     FinishDL();  
00150 }