[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

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.

/media/uploads/Ksenia/4_-22-.jpg

You have to connect VDD to BLVDD at Break Out Board if you use the board:

/media/uploads/Ksenia/4_-5-.jpg

MCU-board to HYT sensor

MCU-board is connected to sensor via I2C. Remember to use pull-up resisrors there:

/media/uploads/Ksenia/freshpaint-20-2016.09.16-10.37.03.png

Подробнее в статьях Как перестать бояться и полюбить mbed [Часть 1 - 5] на https://habrahabr.ru/users/uuuulala/topics/

Committer:
Ksenia
Date:
Wed Oct 05 10:06:54 2016 +0000
Revision:
1:e20b5da0c912
Parent:
0:1f5444f2977d
Changed wrong comment in GetTouch function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ksenia 0:1f5444f2977d 1 #include "mbed.h"
Ksenia 0:1f5444f2977d 2 #include "FT_Platform.h"
Ksenia 0:1f5444f2977d 3 #include "HYT.h"
Ksenia 0:1f5444f2977d 4 #include "display.h"
Ksenia 0:1f5444f2977d 5
Ksenia 0:1f5444f2977d 6 HYT SENSOR (PD6, PD7); // sda, scl [SLSTK3400A]
Ksenia 0:1f5444f2977d 7 FT800 TFT (PE10, PE11, PE12, PE13, PB11, PD4); // mosi, miso, sck, ss, int, pd [SLSTK3400A]
Ksenia 0:1f5444f2977d 8 //HYT SENSOR (D14, D15); // sda, scl [WIZwiki-W7500P]
Ksenia 0:1f5444f2977d 9 //FT800 TFT (D11, D12, D13, D10, D9, D8); // mosi, miso, sck, ss, int, pd [WIZwiki-W7500P]
Ksenia 0:1f5444f2977d 10 //HYT SENSOR (PA08, PA09); // sda, scl [ATSAMD21-XPRO]
Ksenia 0:1f5444f2977d 11 //FT800 TFT (PA18, PA16, PA19, PA17, PA20, PA21); // mosi, miso, sck, ss, int, pd [ATSAMD21-XPRO]
Ksenia 0:1f5444f2977d 12
Ksenia 0:1f5444f2977d 13 Display disp(&TFT);
Ksenia 0:1f5444f2977d 14
Ksenia 0:1f5444f2977d 15 /**************************************************************************************************************************
Ksenia 0:1f5444f2977d 16 ************************** HYT sensor polling cycle ***********************************************************************
Ksenia 0:1f5444f2977d 17 **************************************************************************************************************************/
Ksenia 0:1f5444f2977d 18 void dataUpdate(void)
Ksenia 0:1f5444f2977d 19 {
Ksenia 0:1f5444f2977d 20 SENSOR.MRCommand();
Ksenia 0:1f5444f2977d 21 wait_ms(100);
Ksenia 0:1f5444f2977d 22 SENSOR.DFCommand();
Ksenia 0:1f5444f2977d 23 }
Ksenia 0:1f5444f2977d 24
Ksenia 0:1f5444f2977d 25 /**************************************************************************************************************************
Ksenia 0:1f5444f2977d 26 ************************** Main function **********************************************************************************
Ksenia 0:1f5444f2977d 27 **************************************************************************************************************************/
Ksenia 0:1f5444f2977d 28 int main()
Ksenia 0:1f5444f2977d 29 {
Ksenia 0:1f5444f2977d 30 disp.Calibration();
Ksenia 0:1f5444f2977d 31
Ksenia 0:1f5444f2977d 32 disp.activeScreen = MENU_SCREEN;
Ksenia 0:1f5444f2977d 33 disp.pressedButton = NONE_PRESS;
Ksenia 0:1f5444f2977d 34
Ksenia 0:1f5444f2977d 35 // change active screen depending on pressed area
Ksenia 0:1f5444f2977d 36 while(1) {
Ksenia 0:1f5444f2977d 37 dataUpdate();
Ksenia 0:1f5444f2977d 38 disp.pressedButton = disp.GetTouch();
Ksenia 0:1f5444f2977d 39
Ksenia 0:1f5444f2977d 40 // ----------------------------------------------------------------------------------------------
Ksenia 0:1f5444f2977d 41 // Main menu screen
Ksenia 0:1f5444f2977d 42 if (disp.activeScreen == MENU_SCREEN) {
Ksenia 0:1f5444f2977d 43 disp.MainMenu(SENSOR.humidity, SENSOR.temperature);
Ksenia 0:1f5444f2977d 44 if (disp.pressedButton) {
Ksenia 0:1f5444f2977d 45 wait_ms(150);
Ksenia 0:1f5444f2977d 46 if (disp.pressedButton == CURR_TEMP_PRESS) {
Ksenia 0:1f5444f2977d 47 disp.activeScreen = CURR_TEMP_SCREEN;
Ksenia 0:1f5444f2977d 48 } else if (disp.pressedButton == CURR_HUM_PRESS) {
Ksenia 0:1f5444f2977d 49 disp.activeScreen = CURR_HUM_SCREEN;
Ksenia 0:1f5444f2977d 50 }
Ksenia 0:1f5444f2977d 51 disp.pressedButton = NONE_PRESS;
Ksenia 0:1f5444f2977d 52 }
Ksenia 0:1f5444f2977d 53
Ksenia 0:1f5444f2977d 54 // ----------------------------------------------------------------------------------------------
Ksenia 0:1f5444f2977d 55 // Any other screen
Ksenia 0:1f5444f2977d 56 } else {
Ksenia 0:1f5444f2977d 57 // ----------------------------------------------------------------------------------------------
Ksenia 0:1f5444f2977d 58 // You can back to main menu from any screen
Ksenia 0:1f5444f2977d 59 if (disp.pressedButton == MENU_PRESS) {
Ksenia 0:1f5444f2977d 60 disp.pressedButton = NONE_PRESS;
Ksenia 0:1f5444f2977d 61 disp.activeScreen = MENU_SCREEN;
Ksenia 0:1f5444f2977d 62 } else {
Ksenia 0:1f5444f2977d 63 // ----------------------------------------------------------------------------------------------
Ksenia 0:1f5444f2977d 64 // Screen with current temperature / humidity
Ksenia 0:1f5444f2977d 65 if (disp.activeScreen == CURR_TEMP_SCREEN) {
Ksenia 0:1f5444f2977d 66 disp.CurrentTemperature(SENSOR.temperature);
Ksenia 0:1f5444f2977d 67 } else if (disp.activeScreen == CURR_HUM_SCREEN) {
Ksenia 0:1f5444f2977d 68 disp.CurrentHumidity(SENSOR.humidity);
Ksenia 0:1f5444f2977d 69 }
Ksenia 0:1f5444f2977d 70 }
Ksenia 0:1f5444f2977d 71 }
Ksenia 0:1f5444f2977d 72 }
Ksenia 0:1f5444f2977d 73 }