![](/media/cache/profiles/9f0876a200701e5fdece2e58aa965574.jpg.50x50_q85.jpg)
Русифицированная версия программы для измерения температуры и отн. влажности и вывода информации на сенсорный TFT
Dependencies: FT800_2 HYT mbed
Компоненты
- Датчик температуры и относительной влажности HYT-271 / HYT-221 / HYT-939 от компании IST-AG
- TFT-модуль серии uxTouch от компании Riverdi
- Плата-переходник Break Out Board 20 от компании Riverdi
- Любая отладочная плата с поддержкой mbed, интерфейсами I2C и SPI interface двумя свободными линиями для сигналов PD и INT
Подключение
Отладочная плата к TFT-модулю
Отладочная плата подключается к модулю через переходник Break Out Board 20. На плате-переходнике используется 6 сигналов: SCK, MOSI, MISO, SS (интерфейс SPI), PD (powerdown) и INT (interrupt).
Питание должно быть подано не только на VDD, но и на BLVDD - подсветку экрана. Соответствующие выводы можно просто соединить между собой:
Отладочная плата к датчику серии HYT
К датчику отладочная плата подключается по I2C. Не забываем про подтяжку к питанию:
Демонстрация работы
Процесс создания приложения подробно описан тут: https://habrahabr.ru/users/uuuulala/topics/
display.h@1:8ca8a4ecbe6b, 2016-10-12 (annotated)
- Committer:
- Ksenia
- Date:
- Wed Oct 12 10:53:35 2016 +0000
- Revision:
- 1:8ca8a4ecbe6b
- Parent:
- 0:9db07391e780
?????? ??????? ? ?????? ?????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ksenia | 0:9db07391e780 | 1 | #include "mbed.h" |
Ksenia | 0:9db07391e780 | 2 | #include "FT_Platform.h" |
Ksenia | 0:9db07391e780 | 3 | #include "pictures.h" |
Ksenia | 0:9db07391e780 | 4 | #include "statistics.h" |
Ksenia | 0:9db07391e780 | 5 | #include <string> |
Ksenia | 0:9db07391e780 | 6 | |
Ksenia | 0:9db07391e780 | 7 | #ifndef DISPLAY_H_ |
Ksenia | 0:9db07391e780 | 8 | #define DISPLAY_H_ |
Ksenia | 0:9db07391e780 | 9 | |
Ksenia | 0:9db07391e780 | 10 | /************************************************************************************************************************** |
Ksenia | 0:9db07391e780 | 11 | ************************** Defines using for drawing ********************************************************************** |
Ksenia | 0:9db07391e780 | 12 | **************************************************************************************************************************/ |
Ksenia | 0:9db07391e780 | 13 | |
Ksenia | 0:9db07391e780 | 14 | // all tracking touch screen areas |
Ksenia | 0:9db07391e780 | 15 | typedef enum { |
Ksenia | 0:9db07391e780 | 16 | NONE_PRESS, |
Ksenia | 0:9db07391e780 | 17 | CURR_TEMP_PRESS, |
Ksenia | 0:9db07391e780 | 18 | CURR_HUM_PRESS, |
Ksenia | 0:9db07391e780 | 19 | STAT_TEMP_PRESS, |
Ksenia | 0:9db07391e780 | 20 | STAT_HUM_PRESS, |
Ksenia | 0:9db07391e780 | 21 | ZONE_1_PRESS, |
Ksenia | 0:9db07391e780 | 22 | ZONE_2_PRESS, |
Ksenia | 0:9db07391e780 | 23 | ZONE_3_PRESS, |
Ksenia | 0:9db07391e780 | 24 | ZONE_4_PRESS, |
Ksenia | 0:9db07391e780 | 25 | ZONE_5_PRESS, |
Ksenia | 0:9db07391e780 | 26 | ZONE_6_PRESS, |
Ksenia | 0:9db07391e780 | 27 | ZONE_7_PRESS, |
Ksenia | 0:9db07391e780 | 28 | ZONE_8_PRESS, |
Ksenia | 0:9db07391e780 | 29 | ABOUT_PRESS, |
Ksenia | 0:9db07391e780 | 30 | MENU_PRESS, |
Ksenia | 0:9db07391e780 | 31 | } pressValues; |
Ksenia | 0:9db07391e780 | 32 | |
Ksenia | 0:9db07391e780 | 33 | // all screens available in app |
Ksenia | 0:9db07391e780 | 34 | typedef enum { |
Ksenia | 0:9db07391e780 | 35 | MENU_SCREEN, |
Ksenia | 0:9db07391e780 | 36 | CURR_HUM_SCREEN, |
Ksenia | 0:9db07391e780 | 37 | CURR_TEMP_SCREEN, |
Ksenia | 0:9db07391e780 | 38 | ABOUT_SCREEN, |
Ksenia | 0:9db07391e780 | 39 | HUM_24HRS_SCREEN, |
Ksenia | 0:9db07391e780 | 40 | HUM_3HRS_SCREEN, |
Ksenia | 0:9db07391e780 | 41 | HUM_30MIN_SCREEN, |
Ksenia | 0:9db07391e780 | 42 | TEMP_24HRS_SCREEN, |
Ksenia | 0:9db07391e780 | 43 | TEMP_3HRS_SCREEN, |
Ksenia | 0:9db07391e780 | 44 | TEMP_30MIN_SCREEN |
Ksenia | 0:9db07391e780 | 45 | } screenValues; |
Ksenia | 0:9db07391e780 | 46 | |
Ksenia | 0:9db07391e780 | 47 | |
Ksenia | 0:9db07391e780 | 48 | /************************************************************************************************************************** |
Ksenia | 0:9db07391e780 | 49 | ************************** User class for drawing at FT800 **************************************************************** |
Ksenia | 0:9db07391e780 | 50 | **************************************************************************************************************************/ |
Ksenia | 0:9db07391e780 | 51 | |
Ksenia | 0:9db07391e780 | 52 | class Display |
Ksenia | 0:9db07391e780 | 53 | { |
Ksenia | 0:9db07391e780 | 54 | public: |
Ksenia | 0:9db07391e780 | 55 | // in Display class we use FT800 TFT (definition is available in main.cpp) |
Ksenia | 0:9db07391e780 | 56 | Display(FT800 *TFT) { |
Ksenia | 0:9db07391e780 | 57 | _TFT = TFT; |
Ksenia | 0:9db07391e780 | 58 | } |
Ksenia | 0:9db07391e780 | 59 | |
Ksenia | 0:9db07391e780 | 60 | // functions describing all available screens (screens-functions) |
Ksenia | 0:9db07391e780 | 61 | void MainMenu(float humidity, float temperature); // [display.Draw_MainMenu.cpp] |
Ksenia | 0:9db07391e780 | 62 | void CurrentHumidity(float humidity); // [display.Draw_CurrentValues.cpp] |
Ksenia | 0:9db07391e780 | 63 | void CurrentTemperature(float temperature); // [display.Draw_CurrentValues.cpp] |
Ksenia | 0:9db07391e780 | 64 | void StatHumidity_24hrs(volatile uint64_t seconds, short int statistics24hrs[3][288], |
Ksenia | 0:9db07391e780 | 65 | uint64_t gridSecondsOffset); // [display.Draw_24hrsStatistics.cpp] |
Ksenia | 0:9db07391e780 | 66 | void StatTemperature_24hrs(volatile uint64_t seconds, short int statistics24hrs[3][288], |
Ksenia | 0:9db07391e780 | 67 | uint64_t gridSecondsOffset); // [display.Draw_24hrsStatistics.cpp] |
Ksenia | 0:9db07391e780 | 68 | void StatHumidity_3hrs(volatile uint64_t seconds, short int statistics24hrs[3][288], |
Ksenia | 0:9db07391e780 | 69 | uint64_t gridSecondsOffset); // [display.Draw_3hrsStatistics.cpp] |
Ksenia | 0:9db07391e780 | 70 | void StatTemperature_3hrs(volatile uint64_t seconds, short int statistics24hrs[3][288], |
Ksenia | 0:9db07391e780 | 71 | uint64_t gridSecondsOffset); // [display.Draw_3hrsStatistics.cpp] |
Ksenia | 0:9db07391e780 | 72 | void StatHumidity_30min(volatile uint64_t seconds, short int statistics24hrs[3][288], |
Ksenia | 0:9db07391e780 | 73 | uint64_t gridSecondsOffset); // [display.Draw_30minStatistics.cpp] |
Ksenia | 0:9db07391e780 | 74 | void StatTemperature_30min(volatile uint64_t seconds, short int statistics24hrs[3][288], |
Ksenia | 0:9db07391e780 | 75 | uint64_t gridSecondsOffset); // [display.Draw_30minStatistics.cpp] |
Ksenia | 0:9db07391e780 | 76 | void AboutSensor(void); // [display.Draw_AboutSensor.cpp] |
Ksenia | 0:9db07391e780 | 77 | |
Ksenia | 0:9db07391e780 | 78 | // functions using to prepare FT800 / FT801 |
Ksenia | 0:9db07391e780 | 79 | void LoadImagesAndFonts(void); // [display.LoadImagesAndFonts.cpp] |
Ksenia | 0:9db07391e780 | 80 | void HandleAllBitmaps(void); // [display.LoadImagesAndFonts.cpp] |
Ksenia | 0:9db07391e780 | 81 | void Calibration(void); // [display.Calibration.cpp] |
Ksenia | 0:9db07391e780 | 82 | |
Ksenia | 0:9db07391e780 | 83 | // function for touchscreen tracking |
Ksenia | 0:9db07391e780 | 84 | char GetTouch(void); // [display.GetTouch.cpp] |
Ksenia | 0:9db07391e780 | 85 | |
Ksenia | 0:9db07391e780 | 86 | // variables using for navigation between screens |
Ksenia | 0:9db07391e780 | 87 | char pressedButton; |
Ksenia | 0:9db07391e780 | 88 | char activeScreen; |
Ksenia | 0:9db07391e780 | 89 | char timePoint3hrs, timePoint30min; |
Ksenia | 0:9db07391e780 | 90 | |
Ksenia | 0:9db07391e780 | 91 | private: |
Ksenia | 0:9db07391e780 | 92 | FT800 *_TFT; |
Ksenia | 0:9db07391e780 | 93 | |
Ksenia | 0:9db07391e780 | 94 | // For start and end every display list (every screen) |
Ksenia | 0:9db07391e780 | 95 | void StartDL(void); // [display.DisplayListFunctions.cpp] |
Ksenia | 0:9db07391e780 | 96 | void FinishDL(void); // [display.DisplayListFunctions.cpp] |
Ksenia | 0:9db07391e780 | 97 | |
Ksenia | 0:9db07391e780 | 98 | // Utility function for drawing |
Ksenia | 0:9db07391e780 | 99 | void MainMenuReference(void); // [display.Draw_MainMenuReference.cpp] |
Ksenia | 0:9db07391e780 | 100 | void TimeSinceTurnOn(uint64_t seconds); // [display.Draw_TimeSinceTurnOn.cpp] |
Ksenia | 0:9db07391e780 | 101 | void HorisontalGrid_Current_Temperature(void); // [display.Draw_Grids.cpp] |
Ksenia | 0:9db07391e780 | 102 | void HorisontalGrid_Current_Humidity(void); // [display.Draw_Grids.cpp] |
Ksenia | 0:9db07391e780 | 103 | void HorisontalGrid_Statistics_Temperature(void); // [display.Draw_Grids.cpp] |
Ksenia | 0:9db07391e780 | 104 | void HorisontalGrid_Statistics_Humidity(void); // [display.Draw_Grids.cpp] |
Ksenia | 0:9db07391e780 | 105 | void VerticalGrid3hrs(uint64_t gridSecondsOffset); // [display.Draw_Grids.cpp] |
Ksenia | 0:9db07391e780 | 106 | void VerticalGrid24hrs(uint64_t gridSecondsOffset); // [display.Draw_Grids.cpp] |
Ksenia | 0:9db07391e780 | 107 | void VerticalGrid30min(uint64_t gridSecondsOffset); // [display.Draw_Grids.cpp] |
Ksenia | 0:9db07391e780 | 108 | |
Ksenia | 0:9db07391e780 | 109 | // String operations |
Ksenia | 0:9db07391e780 | 110 | char CreateStringTempHum(char *str, float number, bool isTemp); // [display.StringsTransform.cpp] |
Ksenia | 0:9db07391e780 | 111 | void CreateStringMultipliedTemp(char *str, short int number); // [display.StringsTransform.cpp] |
Ksenia | 0:9db07391e780 | 112 | void CreateStringTime(char *str, uint32_t numberOfSeconds); // [display.StringsTransform.cpp] |
Ksenia | 0:9db07391e780 | 113 | void CreateStringRussian(const string rustext); // [display.StringsTransform.cpp] |
Ksenia | 0:9db07391e780 | 114 | |
Ksenia | 0:9db07391e780 | 115 | // String variables |
Ksenia | 0:9db07391e780 | 116 | char humidityStr[8], temperatureStr[8]; |
Ksenia | 0:9db07391e780 | 117 | char timeStr[9], gridTimeStr[9]; |
Ksenia | 0:9db07391e780 | 118 | char russianStr[150]; |
Ksenia | 0:9db07391e780 | 119 | |
Ksenia | 0:9db07391e780 | 120 | // Variables for managing graphs with current temperature or humidity |
Ksenia | 0:9db07391e780 | 121 | char currentHumidity_X, currentTemperature_X; |
Ksenia | 0:9db07391e780 | 122 | char currentHumidity_Y[68], currentTemperature_Y[68]; |
Ksenia | 0:9db07391e780 | 123 | }; |
Ksenia | 0:9db07391e780 | 124 | |
Ksenia | 0:9db07391e780 | 125 | #endif /* SCREENS_H_ */ |