Measuring air flow, relative humidity & temperature, then showing results at TFT

Dependencies:   FT800_2 HYT mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Display.h Source File

Display.h

00001 #include "mbed.h"
00002 #include "FT_Platform.h"
00003 #include "fonts.h"
00004 #include <string>
00005 
00006 #ifndef DISPLAY_H_
00007 #define DISPLAY_H_
00008 
00009 #define X_AXIS_MULTIPLIER   6
00010 #define POINTS_NUMBER       70
00011 
00012 #define Y_BOTTOM_OFFSET     17
00013 #define Y_UPPER_OFFSET      10
00014 #define X_LEFT_OFFSET       10
00015 
00016 #define BUTTON_1_WIDTH      136
00017 #define BUTTON_2_WIDTH      145
00018 #define BUTTON_3_WIDTH      120
00019 #define BUTTON_HEIGHT       30
00020 
00021 #define SET_FLOW_COLOR              COLOR_RGB(100,46,79)
00022 #define SET_HUMIDITY_COLOR          COLOR_RGB(52,67,94)
00023 #define SET_TEMPERATURE_COLOR       COLOR_RGB(40,66,36)
00024 
00025 #define SET_FLOW_LOW_COLOR          COLOR_RGB(66,40,52)
00026 #define SET_HUMIDITY_LOW_COLOR      COLOR_RGB(33,43,61)
00027 #define SET_TEMPERATURE_LOW_COLOR   COLOR_RGB(20,34,18)
00028 
00029 #define SET_GRAY_COLOR              COLOR_RGB(100,100,100)
00030 #define SET_WHITE_COLOR             COLOR_RGB(255,255,255)
00031 
00032 #define SET_BACKGROUND_COLOR        COLOR_RGB(240,240,240)
00033 
00034 #define CLEAR_BACKGROUND_COLOR      CLEAR_COLOR_RGB(240,240,240)
00035 #define BACKGROUND_COLOR            0xF0F0F0
00036 
00037 /**************************************************************************************************************************
00038 ************************** Defines using for drawing **********************************************************************
00039 **************************************************************************************************************************/
00040 
00041 // all tracking touch screen areas
00042 typedef enum {
00043     NONE_PRESS,
00044     SHOW_HUMIDITY,
00045     SHOW_FLOW,
00046     SHOW_TEMPERATURE
00047 } pressValues;
00048 
00049 
00050 /**************************************************************************************************************************
00051 ************************** User class for drawing at FT800 ****************************************************************
00052 **************************************************************************************************************************/
00053 
00054 class Display
00055 {
00056 public:
00057     // in Display class we use FT800 TFT (definition is available in main.cpp)
00058     Display(FT800 *TFT) {
00059         _TFT = TFT;
00060     }
00061 
00062     void UpdateDataToDraw(uint8_t humidity, int8_t temperature, float flow);
00063 
00064     // functions describing all available screens (screens-functions)
00065     void MainScreen();   // [display.Draw_MainScreen.cpp]
00066 
00067     // functions using to prepare FT800
00068     void Calibration(void);                             // [display.Calibration.cpp]
00069     
00070     void LoadImagesAndFonts(void);                                      // [display.LoadImagesAndFonts.cpp]
00071     void HandleAllBitmaps(void);                                      // [display.LoadImagesAndFonts.cpp]
00072     
00073     // functions for touch screen tracking
00074     void GetTouch(void);                                // [display.GetTouch.cpp]
00075 
00076     uint8_t pressedButton, buttonPressedPrev;
00077     bool showHumidity, showFlow, showTemperature;
00078 
00079 private:
00080     FT800 *_TFT;
00081 
00082     void StartDL(void);                                 // [display.DisplayListFunctions.cpp]
00083     void FinishDL(void);                                // [display.DisplayListFunctions.cpp]
00084     
00085     void VerticalGrid(void);
00086     void HorisontalGrid(void);
00087     void HorisontalGrid_Temperature(void);              // [display.Draw_Grids.cpp]
00088     void HorisontalGrid_Humidity(void);                 // [display.Draw_Grids.cpp]
00089     void HorisontalGrid_Flow(void);                     // [display.Draw_Grids.cpp]
00090 
00091 
00092     void CreateStringHumidity(char *str, uint8_t humidity);       // [display.StringsTransforming.cpp]
00093     void CreateStringFlow(char *str, float flow);       // [display.StringsTransforming.cpp]
00094     void CreateStringTemperature(char *str, int8_t temperature);       // [display.StringsTransforming.cpp]
00095     void CreateStringRussian(const string rustext);                     // [display.StringsTransform.cpp]
00096            
00097     char humidityStr[8], temperatureStr[8], flowStr[8];
00098     char russianStr[150];
00099         
00100     uint8_t current_X;
00101     int humidity_Y[POINTS_NUMBER + 1], temperature_Y[POINTS_NUMBER + 1], flow_Y[POINTS_NUMBER + 1];
00102 };
00103 
00104 #endif /* DISPLAY_H_ */