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_30minStatistics.cpp Source File

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     (*_TFT).Text(11, 15, 30, 0, "Humidity statistics (30 min)");
00081     
00082     // finish FT800 display list
00083     FinishDL();
00084 }
00085 
00086 /**************************************************************************************************************************
00087 ************************** Display data about temperature in the 30-minutes interval **************************************
00088 **************************************************************************************************************************/
00089 
00090 void Display::StatTemperature_30min(volatile uint64_t seconds, short int statistics24hrs[3][288], uint64_t gridSecondsOffset)
00091 {
00092     // strings needed to output temperature values with decimal mark
00093     char currentValueStr[8], currentMinValueStr[8], currentMaxValueStr[8];
00094 
00095     // start FT800 display list
00096     StartDL();
00097  
00098     // mark the plot area as touch input (to return to 24-hrs statistics)    
00099     (*_TFT).DL(COLOR_RGB(213, 213, 213));
00100     (*_TFT).DL(TAG_MASK(1));
00101     (*_TFT).DL(TAG(STAT_TEMP_PRESS));
00102     (*_TFT).DL(BEGIN(RECTS));
00103     (*_TFT).DL(VERTEX2II(25, 100, 0, 0));
00104     (*_TFT).DL(VERTEX2II(433, 200, 0, 0));
00105     (*_TFT).DL(TAG_MASK(0));
00106 
00107     // create time string, GridLines, link to main menu 
00108     TimeSinceTurnOn(seconds);
00109     VerticalGrid30min(gridSecondsOffset);
00110     HorisontalGrid_Statistics_Temperature();
00111     MainMenuReference();
00112 
00113     // draw graph line
00114     // Temperature values are multiplied by 10 in the statistics data array.
00115     // To receive "normal" temperature with decimal mark we have to divide it
00116     for (int i = 0; i < 6; i++) {
00117         char currentValue_toDraw = (statistics24hrs[0][i + timePoint3hrs + timePoint30min] / TEMPERATURE_MULTIPLIER + 50) * 0.57;
00118         char currentMinValue_toDraw = (statistics24hrs[1][i + timePoint3hrs + timePoint30min] / TEMPERATURE_MULTIPLIER + 50) * 0.57;
00119         char currentMaxValue_toDraw = (statistics24hrs[2][i + timePoint3hrs + timePoint30min] / TEMPERATURE_MULTIPLIER + 50) * 0.57;
00120 
00121         short int currentValue_multiplied = statistics24hrs[0][i + timePoint3hrs + timePoint30min];
00122         CreateStringMultipliedTemp(currentValueStr, currentValue_multiplied);
00123         short int currentMinValue_multiplied = statistics24hrs[1][i + timePoint3hrs + timePoint30min];
00124         CreateStringMultipliedTemp(currentMinValueStr, currentMinValue_multiplied);
00125         short int currentMaxValue_multiplied = statistics24hrs[2][i + timePoint3hrs + timePoint30min];
00126         CreateStringMultipliedTemp(currentMaxValueStr, currentMaxValue_multiplied);
00127 
00128         short int delta = currentMaxValue_multiplied - currentMinValue_multiplied;
00129         if (currentValue_multiplied != INIT_STATISTICS_NUMBER && (i + timePoint3hrs + timePoint30min) != 0) {
00130             if (delta >= DELTA_TEMPERATURE * TEMPERATURE_MULTIPLIER) {
00131                 (*_TFT).DL(COLOR_RGB(207, 45, 13));
00132                 (*_TFT).Text(i * 68 + 5, 200 - currentMaxValue_toDraw - 17, 20, 0, currentMaxValueStr);
00133                 (*_TFT).Text(i * 68 + 5, 200 - currentMinValue_toDraw + 3, 20, 0, currentMinValueStr);
00134                 (*_TFT).Text(i * 68 + 43, 200 - currentValue_toDraw - 7, 26, 0, currentValueStr);
00135             } else {
00136                 (*_TFT).DL(COLOR_RGB(9, 0, 63));
00137                 (*_TFT).Text(i * 68 + 43, 200 - currentValue_toDraw - 7, 26, 0, currentValueStr);
00138             }
00139             (*_TFT).DL(BEGIN(LINES));
00140             (*_TFT).DL(LINE_WIDTH(16));
00141             (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue_toDraw) * 16));
00142             (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentMaxValue_toDraw) * 16));
00143             (*_TFT).DL(VERTEX2F((i * 68 + 10) * 16, (200 - currentMaxValue_toDraw) * 16));
00144             (*_TFT).DL(VERTEX2F((i * 68 + 40) * 16, (200 - currentMaxValue_toDraw) * 16));
00145             (*_TFT).DL(END());
00146 
00147             (*_TFT).DL(BEGIN(LINES));
00148             (*_TFT).DL(LINE_WIDTH(16));
00149             (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue_toDraw) * 16));
00150             (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentMinValue_toDraw) * 16));
00151             (*_TFT).DL(VERTEX2F((i * 68 + 10) * 16, (200 - currentMinValue_toDraw) * 16));
00152             (*_TFT).DL(VERTEX2F((i * 68 + 40) * 16, (200 - currentMinValue_toDraw) * 16));
00153             (*_TFT).DL(END());
00154 
00155             (*_TFT).DL(BEGIN(POINTS));
00156             (*_TFT).DL(POINT_SIZE(70));
00157             (*_TFT).DL(VERTEX2F((i * 68 + 25) * 16, (200 - currentValue_toDraw) * 16));
00158             (*_TFT).DL(END());
00159 
00160             (*_TFT).DL(BEGIN(LINES));
00161             (*_TFT).DL(LINE_WIDTH(24));
00162             (*_TFT).DL(VERTEX2F((i * 68 + 15) * 16, (200 - currentValue_toDraw) * 16));
00163             (*_TFT).DL(VERTEX2F((i * 68 + 35) * 16, (200 - currentValue_toDraw) * 16));
00164             (*_TFT).DL(END());
00165         }
00166         if (timePoint3hrs + timePoint30min == 0) {
00167             (*_TFT).DL(COLOR_RGB(9, 0, 63));
00168             (*_TFT).DL(BEGIN(POINTS));
00169             (*_TFT).DL(POINT_SIZE(70));
00170             (*_TFT).DL(VERTEX2F(25 * 16, (200 - statistics24hrs[0][0]) * 16));
00171             (*_TFT).DL(END());
00172         }
00173     }
00174 
00175     // write main title
00176     (*_TFT).DL(COLOR_RGB(0, 0, 0));
00177     (*_TFT).Text(11, 15, 30, 0, "Temperature statistics (30 min)");
00178     
00179     // finish FT800 display list
00180     FinishDL();
00181 }