[SIMPLE PROGRAM] HYT humidity & temp sensor polling / showing received data at TFT with capacitive touchscreen
Dependencies: FT800_2 HYT mbed
HYT humidity and temperature sensor polling & showing received data at TFT via graphical controller FT800/FT801.
Hardware
- HYT-271 / HYT-221 / HYT-939 humidity and temperature sensor by IST-AG
- TFT module uxTouch by Riverdi
- Break Out Board 20 by Riverdi
- Any mbed platform with I2C interface, SPI interface and 2 free GPIO for PD and INT signals
For documentation on the FT800 library, please refer to the library pages.
Connection
MCU-board to TFT-module
MCU-board is connected to TFT-module via Break Out Board. You need 6 signals to connect: SCK, MOSI and MISO are connected to a SPI channel, SS is the chip select signal, PD work as powerdown and INT for interrupts from TFT to MCU.
You have to connect VDD to BLVDD at Break Out Board if you use the board:
MCU-board to HYT sensor
MCU-board is connected to sensor via I2C. Remember to use pull-up resisrors there:
Подробнее в статьях Как перестать бояться и полюбить mbed [Часть 1 - 5] на https://habrahabr.ru/users/uuuulala/topics/
Diff: display.h
- Revision:
- 0:1f5444f2977d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/display.h Mon Sep 26 15:39:09 2016 +0000 @@ -0,0 +1,71 @@ +#include "mbed.h" +#include "FT_Platform.h" +#include <string> + +#ifndef DISPLAY_H_ +#define DISPLAY_H_ + +/************************************************************************************************************************** +************************** Defines using for drawing ********************************************************************** +**************************************************************************************************************************/ + +// all tracking touch screen areas +typedef enum { + NONE_PRESS, + CURR_TEMP_PRESS, + CURR_HUM_PRESS, + MENU_PRESS, +} pressValues; + +// all existing screens +typedef enum { + MENU_SCREEN, + CURR_HUM_SCREEN, + CURR_TEMP_SCREEN, +} screenValues; + + +/************************************************************************************************************************** +************************** User class for drawing at FT800 **************************************************************** +**************************************************************************************************************************/ + +class Display +{ +public: + // in Display class we use FT800 TFT (definition is available in main.cpp) + Display(FT800 *TFT) { + _TFT = TFT; + } + + // functions describing all available screens (screens-functions) + void MainMenu(float humidity, float temperature); // [display.Draw_MainMenu.cpp] + void CurrentHumidity(float humidity); // [display.Draw_CurrentValuesGraphs.cpp] + void CurrentTemperature(float temperature); // [display.Draw_CurrentValuesGraphs.cpp] + + // functions using to prepare FT800 + void Calibration(void); // [display.Calibration.cpp] + + // functions for touch screen tracking + char GetTouch(void); // [display.GetTouch.cpp] + + // variables using for navigation between screens + char pressedButton; + char activeScreen; + +private: + FT800 *_TFT; + + void StartDL(void); // [display.DisplayListFunctions.cpp] + void FinishDL(void); // [display.DisplayListFunctions.cpp] + void MainMenuReference(void); // [display.Draw_MainMenuReference.cpp] + void HorisontalGrid_CurrentTemp(void); // [display.Draw_Grids.cpp] + void HorisontalGrid_CurrentHumidity(void); // [display.Draw_Grids.cpp] + + void CreateStringTempHum(char *str, float number, bool isTemp); // [display.StringsTransforming.cpp] + + char humidityStr[8], temperatureStr[8]; + char currentHumidity_X, currentTemperature_X; + char currentHumidity_Y[68], currentTemperature_Y[68]; +}; + +#endif /* SCREENS_H_ */ \ No newline at end of file