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

display.Draw_24hrsStatistics.cpp

00001 #include "display.h"
00002 
00003 /**************************************************************************************************************************
00004 ************************** Display data about humidity in the 24-hour interval ********************************************
00005 **************************************************************************************************************************/
00006 
00007 void Display::StatHumidity_24hrs(volatile uint64_t seconds, short int statistics24hrs[3][288], uint64_t gridSecondsOffset)
00008 {
00009     // start FT800 display list
00010     StartDL();
00011  
00012     // mark 8 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 += 17 * 3) {
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             timePoint3hrs = 36 * 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 + 17 * 3, 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     VerticalGrid24hrs(gridSecondsOffset);
00036     HorisontalGrid_Statistics_Humidity();
00037     MainMenuReference();
00038     
00039     // draw graph line
00040     (*_TFT).DL(COLOR_RGB(0, 0, 0));
00041     for (int i = 1; i < 287; i++) {
00042         short int currentValue = statistics24hrs[0][i];
00043         if (currentValue != INIT_STATISTICS_NUMBER) {
00044             char previousValue = statistics24hrs[0][i - 1];
00045             char delta = statistics24hrs[2][i] - statistics24hrs[1][i];
00046             if (delta >= DELTA_HUMIDITY) {
00047                 (*_TFT).DL(COLOR_RGB(255, 0, 0));
00048                 (*_TFT).DL(BEGIN(LINES));
00049                 (*_TFT).DL(LINE_WIDTH(8));
00050                 (*_TFT).DL(VERTEX2F(i * 23 + 25 * 16, (200 - currentValue) * 16));
00051                 (*_TFT).DL(VERTEX2F(i * 23 + 25 * 16, (180 - currentValue) * 16));
00052                 (*_TFT).DL(END());
00053                 (*_TFT).DL(BEGIN(POINTS));
00054                 (*_TFT).DL(POINT_SIZE(33));
00055                 (*_TFT).DL(VERTEX2F(i * 23 + 25 * 16, (180 - currentValue) * 16));
00056                 (*_TFT).DL(END());
00057             }
00058             (*_TFT).DL(COLOR_RGB(0, 0, 0));
00059             (*_TFT).DL(BEGIN(LINES));
00060             (*_TFT).DL(LINE_WIDTH(16));
00061             (*_TFT).DL(VERTEX2F((i - 1) * 23 + 25 * 16, (200 - previousValue) * 16));
00062             (*_TFT).DL(VERTEX2F(i * 23 + 25 * 16, (200 - currentValue) * 16));
00063             (*_TFT).DL(END());
00064         }
00065     }
00066 
00067     // write main title
00068     (*_TFT).DL(COLOR_RGB(0, 0, 0));
00069     (*_TFT).Text(11, 15, 30, 0, "Humidity statistics (24 hrs)");
00070     
00071     // finish FT800 display list
00072     FinishDL();
00073 }
00074 
00075 /**************************************************************************************************************************
00076 ************************** Display data about temperature in the 24-hour interval *****************************************
00077 **************************************************************************************************************************/
00078 
00079 void Display::StatTemperature_24hrs(volatile uint64_t seconds, short int statistics24hrs[3][288], uint64_t gridSecondsOffset)
00080 {
00081     // start FT800 display list
00082     StartDL();
00083  
00084     // mark 8 areas for touch input (for zoom in),
00085     // make each every second zone gray, make the active zone green
00086     char ZonesCnt = 0;
00087     for (int i = 25; i < 433; i += 17 * 3) {
00088         (*_TFT).DL(COLOR_RGB(255, 255, 255));
00089         if (ZonesCnt % 2 == 0) {
00090             (*_TFT).DL(COLOR_RGB(233, 233, 233));
00091         }
00092         if (pressedButton - ZONE_1_PRESS == ZonesCnt) {
00093             (*_TFT).DL(COLOR_RGB(200, 255, 200));
00094             timePoint3hrs = 36 * ZonesCnt;
00095         }
00096         (*_TFT).DL(TAG_MASK(1));
00097         (*_TFT).DL(TAG(ZONE_1_PRESS + ZonesCnt));
00098         (*_TFT).DL(BEGIN(RECTS));
00099         (*_TFT).DL(VERTEX2II(i, 100, 0, 0));
00100         (*_TFT).DL(VERTEX2II(i + 17 * 3, 200, 0, 0));
00101         (*_TFT).DL(TAG_MASK(0));
00102         ZonesCnt++;
00103     }
00104 
00105     // create time string, GridLines, link to main menu 
00106     TimeSinceTurnOn(seconds);
00107     VerticalGrid24hrs(gridSecondsOffset);
00108     HorisontalGrid_Statistics_Temperature();
00109     MainMenuReference();
00110     
00111     // draw graph line
00112     (*_TFT).DL(COLOR_RGB(0, 0, 0));
00113     for (int i = 1; i < 287; i++) {
00114         char previousValue = (statistics24hrs[0][i - 1] / TEMPERATURE_MULTIPLIER + 50) * 0.57;
00115         char currentValue = (statistics24hrs[0][i] / TEMPERATURE_MULTIPLIER + 50) * 0.57;
00116         char delta = statistics24hrs[2][i] - statistics24hrs[1][i];
00117         if (statistics24hrs[0][i] != INIT_STATISTICS_NUMBER) {
00118             if (delta >= DELTA_TEMPERATURE * TEMPERATURE_MULTIPLIER) {
00119                 (*_TFT).DL(COLOR_RGB(255, 0, 0));
00120                 (*_TFT).DL(BEGIN(LINES));
00121                 (*_TFT).DL(LINE_WIDTH(8));
00122                 (*_TFT).DL(VERTEX2F(i * 23 + 25 * 16, (200 - currentValue) * 16));
00123                 (*_TFT).DL(VERTEX2F(i * 23 + 25 * 16, (180 - currentValue) * 16));
00124                 (*_TFT).DL(END());
00125                 (*_TFT).DL(BEGIN(POINTS));
00126                 (*_TFT).DL(POINT_SIZE(33));
00127                 (*_TFT).DL(VERTEX2F(i * 23 + 25 * 16, (180 - currentValue) * 16));
00128                 (*_TFT).DL(END());
00129             }
00130             (*_TFT).DL(COLOR_RGB(0, 0, 0));
00131             (*_TFT).DL(BEGIN(LINES));
00132             (*_TFT).DL(LINE_WIDTH(16));
00133             (*_TFT).DL(VERTEX2F((i - 1) * 23 + 25 * 16, (200 - previousValue) * 16));
00134             (*_TFT).DL(VERTEX2F(i * 23 + 25 * 16, (200 - currentValue) * 16));
00135         }
00136     }
00137 
00138     // write main title
00139     (*_TFT).DL(COLOR_RGB(0, 0, 0));
00140     (*_TFT).Text(11, 15, 30, 0, "Temperature statistics (24 hrs)");
00141 
00142     // finish FT800 display list
00143     FinishDL();
00144 }