Measuring air flow, relative humidity & temperature, then showing results at TFT
Dependencies: FT800_2 HYT mbed
Air flow is measured with FS7 sensor by IST-AG, humidity & temperature are measured by HYT-271 sensor by IST. Graphs displayed it TFT by Riverdi via graphical controller FFT801.
Hardware
- HYT-271 / HYT-221 / HYT-939 humidity and temperature sensor by IST-AG
- FS7 gas flow sensor by IST-AG
- FS-flowmodule for FS7 sensors
- TFT module uxTouch by Riverdi
- Break Out Board 20 by Riverdi
- Any mbed platform with I2C interface, SPI interface, 2 free GPIO for PD and INT signals and one ADC input.
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:
MCU-board to FS7 sensor
MCU-board is connected to sensor via FS flowmodule. FS-flowmodul is a PCB implementing bridge circuit which is necessary for FS7.
Revision 0:3f440c2facb0, committed 2017-03-16
- Comitter:
- Ksenia
- Date:
- Thu Mar 16 08:58:18 2017 +0000
- Commit message:
- Initial Commit
Changed in this revision
diff -r 000000000000 -r 3f440c2facb0 FT800_2.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FT800_2.lib Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/dreschpe/code/FT800_2/#16e22c789f7d
diff -r 000000000000 -r 3f440c2facb0 HYT.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HYT.lib Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/Ksenia/code/HYT/#cb02bfe8cf44
diff -r 000000000000 -r 3f440c2facb0 TFT/Calibration.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/Calibration.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,12 @@ +#include "Display.h" + +/************************************************************************************************************************** +************************** Put calibration data to FT800 ****************************************************************** +**************************************************************************************************************************/ +void Display::Calibration() +{ + char calibration[25] = {98, 99, 0, 0, 182, 254, 255, 255, 245, 142, 248, 255, 117, 254, 255, 255, 34, 98, 0, 0, 123, 154, 248, 255}; + for (int i = 0; i < 24; i++) { + (*_TFT).Wr8(REG_TOUCH_TRANSFORM_A + i, calibration[i]); + } +} \ No newline at end of file
diff -r 000000000000 -r 3f440c2facb0 TFT/Display.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/Display.h Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,104 @@ +#include "mbed.h" +#include "FT_Platform.h" +#include "fonts.h" +#include <string> + +#ifndef DISPLAY_H_ +#define DISPLAY_H_ + +#define X_AXIS_MULTIPLIER 6 +#define POINTS_NUMBER 70 + +#define Y_BOTTOM_OFFSET 17 +#define Y_UPPER_OFFSET 10 +#define X_LEFT_OFFSET 10 + +#define BUTTON_1_WIDTH 136 +#define BUTTON_2_WIDTH 145 +#define BUTTON_3_WIDTH 120 +#define BUTTON_HEIGHT 30 + +#define SET_FLOW_COLOR COLOR_RGB(100,46,79) +#define SET_HUMIDITY_COLOR COLOR_RGB(52,67,94) +#define SET_TEMPERATURE_COLOR COLOR_RGB(40,66,36) + +#define SET_FLOW_LOW_COLOR COLOR_RGB(66,40,52) +#define SET_HUMIDITY_LOW_COLOR COLOR_RGB(33,43,61) +#define SET_TEMPERATURE_LOW_COLOR COLOR_RGB(20,34,18) + +#define SET_GRAY_COLOR COLOR_RGB(100,100,100) +#define SET_WHITE_COLOR COLOR_RGB(255,255,255) + +#define SET_BACKGROUND_COLOR COLOR_RGB(240,240,240) + +#define CLEAR_BACKGROUND_COLOR CLEAR_COLOR_RGB(240,240,240) +#define BACKGROUND_COLOR 0xF0F0F0 + +/************************************************************************************************************************** +************************** Defines using for drawing ********************************************************************** +**************************************************************************************************************************/ + +// all tracking touch screen areas +typedef enum { + NONE_PRESS, + SHOW_HUMIDITY, + SHOW_FLOW, + SHOW_TEMPERATURE +} pressValues; + + +/************************************************************************************************************************** +************************** 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; + } + + void UpdateDataToDraw(uint8_t humidity, int8_t temperature, float flow); + + // functions describing all available screens (screens-functions) + void MainScreen(); // [display.Draw_MainScreen.cpp] + + // functions using to prepare FT800 + void Calibration(void); // [display.Calibration.cpp] + + void LoadImagesAndFonts(void); // [display.LoadImagesAndFonts.cpp] + void HandleAllBitmaps(void); // [display.LoadImagesAndFonts.cpp] + + // functions for touch screen tracking + void GetTouch(void); // [display.GetTouch.cpp] + + uint8_t pressedButton, buttonPressedPrev; + bool showHumidity, showFlow, showTemperature; + +private: + FT800 *_TFT; + + void StartDL(void); // [display.DisplayListFunctions.cpp] + void FinishDL(void); // [display.DisplayListFunctions.cpp] + + void VerticalGrid(void); + void HorisontalGrid(void); + void HorisontalGrid_Temperature(void); // [display.Draw_Grids.cpp] + void HorisontalGrid_Humidity(void); // [display.Draw_Grids.cpp] + void HorisontalGrid_Flow(void); // [display.Draw_Grids.cpp] + + + void CreateStringHumidity(char *str, uint8_t humidity); // [display.StringsTransforming.cpp] + void CreateStringFlow(char *str, float flow); // [display.StringsTransforming.cpp] + void CreateStringTemperature(char *str, int8_t temperature); // [display.StringsTransforming.cpp] + void CreateStringRussian(const string rustext); // [display.StringsTransform.cpp] + + char humidityStr[8], temperatureStr[8], flowStr[8]; + char russianStr[150]; + + uint8_t current_X; + int humidity_Y[POINTS_NUMBER + 1], temperature_Y[POINTS_NUMBER + 1], flow_Y[POINTS_NUMBER + 1]; +}; + +#endif /* DISPLAY_H_ */
diff -r 000000000000 -r 3f440c2facb0 TFT/DisplayListFunctions.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/DisplayListFunctions.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,28 @@ +#include "Display.h" + + +/************************************************************************************************************************** +************************** Start display list ***************************************************************************** +**************************************************************************************************************************/ +void Display::StartDL() +{ + (*_TFT).DLstart(); + // set color for background + (*_TFT).DL(CLEAR_BACKGROUND_COLOR); + // clear buffers for preset values + (*_TFT).DL(CLEAR(1, 1, 1)); +} + +/************************************************************************************************************************** +************************** Finish display list **************************************************************************** +**************************************************************************************************************************/ +void Display::FinishDL() +{ + (*_TFT).DL(DISPLAY()); + // Swap the current display list + (*_TFT).Swap(); + // Download the command list into fifo TFT + (*_TFT).Flush_Co_Buffer(); + // Wait for the complete consumption of FT800 Coprocessor commands + (*_TFT).WaitCmdfifo_empty(); +}
diff -r 000000000000 -r 3f440c2facb0 TFT/Draw_Grids.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/Draw_Grids.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,88 @@ +#include "Display.h" + +/************************************************************************************************************************** +************************** Draw horisontal grid w/o legend *************************************************** +**************************************************************************************************************************/ +void Display::HorisontalGrid() +{ + (*_TFT).DL(COLOR_RGB(150, 150, 150)); + for (int i = 0; i <= 200; i += 40) { + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(LINE_WIDTH(8)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET, my_DispHeight - (i + Y_BOTTOM_OFFSET), 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + (POINTS_NUMBER * X_AXIS_MULTIPLIER + 5), my_DispHeight - (i + Y_BOTTOM_OFFSET), 0, 0)); + } +} + +/************************************************************************************************************************** +************************** Draw horisontal grid for temperature (-10 .. +40) ********************************************* +**************************************************************************************************************************/ +void Display::HorisontalGrid_Temperature() +{ + (*_TFT).DL(COLOR_RGB(20, 20, 20)); + int8_t gridNumb = -10; + for (int i = 0; i <= 200; i += 40) { + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(LINE_WIDTH(8)); + if (gridNumb == 0) { + (*_TFT).DL(LINE_WIDTH(11)); + } + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET, my_DispHeight - (i + Y_BOTTOM_OFFSET), 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + (POINTS_NUMBER * X_AXIS_MULTIPLIER + 5), my_DispHeight - (i + Y_BOTTOM_OFFSET), 0, 0)); + if (gridNumb < 0) { + (*_TFT).Text((POINTS_NUMBER * X_AXIS_MULTIPLIER + 18), my_DispHeight - (i + Y_BOTTOM_OFFSET + 8), 26, 0, "-"); + (*_TFT).Number((POINTS_NUMBER * X_AXIS_MULTIPLIER + 23), my_DispHeight - (i + Y_BOTTOM_OFFSET + 8), 26, 0, (-gridNumb)); + } else { + (*_TFT).Number((POINTS_NUMBER * X_AXIS_MULTIPLIER + 18), my_DispHeight - (i + Y_BOTTOM_OFFSET + 8), 26, 0, gridNumb); + } + gridNumb = gridNumb + 10; + } +} + +/************************************************************************************************************************** +************************** Draw horisontal grid for humidity (0 .. 100) *************************************************** +**************************************************************************************************************************/ +void Display::HorisontalGrid_Humidity() +{ + (*_TFT).DL(COLOR_RGB(20, 20, 20)); + uint8_t gridNumb = 0; + for (int i = 0; i <= 200; i += 40) { + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(LINE_WIDTH(8)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET, my_DispHeight - (i + Y_BOTTOM_OFFSET), 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + (POINTS_NUMBER * X_AXIS_MULTIPLIER + 5), my_DispHeight - (i + Y_BOTTOM_OFFSET), 0, 0)); + (*_TFT).Number((POINTS_NUMBER * X_AXIS_MULTIPLIER + 18), my_DispHeight - (i + Y_BOTTOM_OFFSET + 8), 26, 0, gridNumb); + gridNumb = gridNumb + 20; + } +} + +/************************************************************************************************************************** +************************** Draw horisontal grid for flow (0.0 .. 10.0) *************************************************** +**************************************************************************************************************************/ +void Display::HorisontalGrid_Flow() +{ + (*_TFT).DL(COLOR_RGB(20, 20, 20)); + uint8_t gridNumb = 0; + for (int i = 0; i <= 200; i += 40) { + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(LINE_WIDTH(8)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET, my_DispHeight - (i + Y_BOTTOM_OFFSET), 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + (POINTS_NUMBER * X_AXIS_MULTIPLIER + 5), my_DispHeight - (i + Y_BOTTOM_OFFSET), 0, 0)); + (*_TFT).Number((POINTS_NUMBER * X_AXIS_MULTIPLIER + 18), my_DispHeight - (i + Y_BOTTOM_OFFSET + 8), 26, 0, gridNumb); + gridNumb = gridNumb + 2; + } +} + +/************************************************************************************************************************** +************************** Draw vertical grid ***************************************************************************** +**************************************************************************************************************************/ +void Display::VerticalGrid() +{ + (*_TFT).DL(COLOR_RGB(200, 200, 200)); + for (int i = 0; i <= POINTS_NUMBER; i += 10) { + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(LINE_WIDTH(8)); + (*_TFT).DL(VERTEX2II(i * X_AXIS_MULTIPLIER + X_LEFT_OFFSET, my_DispHeight - Y_BOTTOM_OFFSET - 200, 0, 0)); + (*_TFT).DL(VERTEX2II(i * X_AXIS_MULTIPLIER + X_LEFT_OFFSET, my_DispHeight - Y_BOTTOM_OFFSET, 0, 0)); + } +}
diff -r 000000000000 -r 3f440c2facb0 TFT/Draw_MainScreen.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/Draw_MainScreen.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,204 @@ +#include "Display.h" + +/************************************************************************************************************************** +************************** Display Main Menu ****************************************************************************** +**************************************************************************************************************************/ +void Display::MainScreen() +{ + uint8_t numberOfGraphs = showHumidity + showFlow + showTemperature; + + // start FT800 display list + StartDL(); + + /****************************************************************************************************/ + (*_TFT).DL(SET_BACKGROUND_COLOR); + (*_TFT).DL(TAG_MASK(1)); + (*_TFT).DL(TAG(SHOW_HUMIDITY)); + (*_TFT).DL(BEGIN(RECTS)); + (*_TFT).DL(VERTEX2II(0, 0, 0, 0)); + (*_TFT).DL(VERTEX2II(0 + BUTTON_1_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET + BUTTON_HEIGHT + Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(TAG_MASK(0)); + + (*_TFT).DL(TAG_MASK(1)); + (*_TFT).DL(TAG(SHOW_FLOW)); + (*_TFT).DL(BEGIN(RECTS)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET / 2, 0, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET / 2, Y_UPPER_OFFSET + BUTTON_HEIGHT + Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(TAG_MASK(0)); + + (*_TFT).DL(TAG_MASK(1)); + (*_TFT).DL(TAG(SHOW_TEMPERATURE)); + (*_TFT).DL(BEGIN(RECTS)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET / 2, 0, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET + BUTTON_3_WIDTH + X_LEFT_OFFSET / 2, Y_UPPER_OFFSET + BUTTON_HEIGHT + Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(TAG_MASK(0)); + + /****************************************************************************************************/ + if (showHumidity) { + (*_TFT).DL(SET_HUMIDITY_COLOR); + } else { + (*_TFT).DL(SET_HUMIDITY_LOW_COLOR); + } + (*_TFT).DL(BEGIN(RECTS)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET, Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + if (showHumidity) { + (*_TFT).DL(SET_HUMIDITY_LOW_COLOR); + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET, Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(SET_WHITE_COLOR); + } else { + (*_TFT).DL(COLOR_RGB(100, 100, 100)); + } + CreateStringRussian("Отн. влажность"); + (*_TFT).Text(X_LEFT_OFFSET + 5, Y_UPPER_OFFSET + 5, 4, 0, russianStr); + + + (*_TFT).DL(SET_FLOW_COLOR); + if (showFlow) + (*_TFT).DL(SET_FLOW_COLOR); + else + (*_TFT).DL(SET_FLOW_LOW_COLOR); + (*_TFT).DL(BEGIN(RECTS)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + if (showFlow) { + (*_TFT).DL(SET_FLOW_LOW_COLOR); + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(SET_WHITE_COLOR); + } else { + (*_TFT).DL(COLOR_RGB(100, 100, 100)); + } + CreateStringRussian("Скорость потока"); + (*_TFT).Text(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + 5, Y_UPPER_OFFSET + 5, 4, 0, russianStr); + + + if (showTemperature) + (*_TFT).DL(SET_TEMPERATURE_COLOR); + else + (*_TFT).DL(SET_TEMPERATURE_LOW_COLOR); + (*_TFT).DL(BEGIN(RECTS)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET + BUTTON_3_WIDTH, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + if (showTemperature) { + (*_TFT).DL(SET_TEMPERATURE_LOW_COLOR); + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET + BUTTON_3_WIDTH, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(BEGIN(LINES)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET, 0, 0)); + (*_TFT).DL(VERTEX2II(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET, Y_UPPER_OFFSET + BUTTON_HEIGHT, 0, 0)); + (*_TFT).DL(END()); + (*_TFT).DL(SET_WHITE_COLOR); + } else { + (*_TFT).DL(COLOR_RGB(100, 100, 100)); + } + CreateStringRussian("Температура"); + (*_TFT).Text(X_LEFT_OFFSET + BUTTON_1_WIDTH + X_LEFT_OFFSET + BUTTON_2_WIDTH + X_LEFT_OFFSET + 5, Y_UPPER_OFFSET + 5, 4, 0, russianStr); + + +/****************************************************************************************************/ + if (showTemperature) { + (*_TFT).DL(BEGIN(EDGE_STRIP_B)); + for (int i = 0; i <= POINTS_NUMBER; i++) { + if (i <= current_X) { + (*_TFT).DL(COLOR_RGB(210,255,2016)); + (*_TFT).DL(VERTEX2II((i * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - temperature_Y[i], 0, 0)); + } + } + } + if (showHumidity) { + (*_TFT).DL(BEGIN(EDGE_STRIP_B)); + for (int i = 0; i <= POINTS_NUMBER; i++) { + if (i <= current_X) { + (*_TFT).DL(COLOR_RGB(184,213,255)); + (*_TFT).DL(VERTEX2II((i * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - humidity_Y[i], 0, 0)); + } + } + } + if (showFlow) { + (*_TFT).DL(BEGIN(EDGE_STRIP_B)); + for (int i = 0; i <= POINTS_NUMBER; i++) { + if (i <= current_X) { + (*_TFT).DL(COLOR_RGB(255,198,255)); + (*_TFT).DL(VERTEX2II((i * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - flow_Y[i], 0, 0)); + } + } + } + +/****************************************************************************************************/ + if (numberOfGraphs != 1) { + HorisontalGrid(); + } else { + if (showHumidity) + HorisontalGrid_Humidity(); + if (showFlow) + HorisontalGrid_Flow(); + if (showTemperature) + HorisontalGrid_Temperature(); + } + + VerticalGrid(); + +/****************************************************************************************************/ + for (int i = 0; i <= POINTS_NUMBER; i++) { + (*_TFT).DL(BEGIN(POINTS)); + (*_TFT).DL(POINT_SIZE(40)); + if (i <= current_X || i >= current_X + 13) { + (*_TFT).DL(SET_HUMIDITY_COLOR); + if (showHumidity) + (*_TFT).DL(VERTEX2II((i * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - humidity_Y[i], 0, 0)); + (*_TFT).DL(SET_FLOW_COLOR); + if (showFlow) + (*_TFT).DL(VERTEX2II((i * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - flow_Y[i], 0, 0)); + (*_TFT).DL(SET_TEMPERATURE_COLOR); + if (showTemperature) + (*_TFT).DL(VERTEX2II((i * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - temperature_Y[i], 0, 0)); + } + (*_TFT).DL(END()); + } + +/****************************************************************************************************/ + (*_TFT).DL(SET_HUMIDITY_COLOR); + if (showHumidity) + (*_TFT).Text((current_X * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - humidity_Y[current_X] - 25, 4, 0, humidityStr); + (*_TFT).DL(SET_FLOW_COLOR); + if (showFlow) + (*_TFT).Text((current_X * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - flow_Y[current_X] - 25, 4, 0, flowStr); + (*_TFT).DL(SET_TEMPERATURE_COLOR); + if (showTemperature) + (*_TFT).Text((current_X * X_AXIS_MULTIPLIER + X_LEFT_OFFSET), my_DispHeight - temperature_Y[current_X] - 25, 4, 0, temperatureStr); + +/****************************************************************************************************/ +// (*_TFT).Number(my_DispWidth - 25, my_DispHeight - 150, 27, 0, sec / 60); +// (*_TFT).Number(my_DispWidth - 25, my_DispHeight - 135, 27, 0, sec % 60); + +/****************************************************************************************************/ + (*_TFT).DL(SCISSOR_XY(0, my_DispHeight - Y_BOTTOM_OFFSET + 3)); + (*_TFT).DL(SCISSOR_SIZE(X_LEFT_OFFSET + (POINTS_NUMBER * X_AXIS_MULTIPLIER + 5), Y_BOTTOM_OFFSET - 3)); + (*_TFT).Gradient(0, my_DispHeight, BACKGROUND_COLOR, X_LEFT_OFFSET + (POINTS_NUMBER * X_AXIS_MULTIPLIER + 5), my_DispHeight - Y_BOTTOM_OFFSET + 3, BACKGROUND_COLOR); + + + // finish FT801 display list + FinishDL(); +}
diff -r 000000000000 -r 3f440c2facb0 TFT/GetTouch.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/GetTouch.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,26 @@ +#include "Display.h" + +/*************************************************************************************************************************/ + +void Display::GetTouch() +{ + pressedButton = (*_TFT).Rd8(REG_TOUCH_TAG); + + if (pressedButton == SHOW_HUMIDITY) { + if (buttonPressedPrev != SHOW_HUMIDITY) { + showHumidity = !showHumidity; + } + } + if (pressedButton == SHOW_FLOW) { + if (buttonPressedPrev != SHOW_FLOW) { + showFlow = !showFlow; + } + } + if (pressedButton == SHOW_TEMPERATURE) { + if (buttonPressedPrev != SHOW_TEMPERATURE) { + showTemperature = !showTemperature; + } + } + + buttonPressedPrev = pressedButton; +}
diff -r 000000000000 -r 3f440c2facb0 TFT/SetRussianFonts.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/SetRussianFonts.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,31 @@ +#include "Display.h" + + +/************************************************************************************************************************** +************************** Decompress images anf fonts from pictures.h and put them to the RAM memeory of FT800 *********** +**************************************************************************************************************************/ +void Display::LoadImagesAndFonts() +{ + (*_TFT).WrCmd32(CMD_INFLATE); + (*_TFT).WrCmd32(FONT_SET_ROBOTO_REGULAR_16); + (*_TFT).WrCmdBufFromFlash(font_RobotoRegular16, sizeof(font_RobotoRegular16)); +} + +/************************************************************************************************************************** +************************** Prepare images and fronts ********************************************************************** +**************************************************************************************************************************/ +void Display::HandleAllBitmaps() +{ + // start FT800 display list + StartDL(); + + (*_TFT).DL(BITMAP_HANDLE(4)); + (*_TFT).DL(BITMAP_SOURCE(FONT_ADDR_ROBOTO_REGULAR_16)); + (*_TFT).DL(BITMAP_LAYOUT(L4, 8, 20)); + (*_TFT).DL(BITMAP_SIZE(NEAREST, BORDER, BORDER, 16, 20)); + + (*_TFT).SetFont(4, FONT_SET_ROBOTO_REGULAR_16); + + // finish FT800 display list + FinishDL(); +}
diff -r 000000000000 -r 3f440c2facb0 TFT/StringsTransforming.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/StringsTransforming.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,176 @@ +#include "Display.h" + +/*************************************************************************************************************************/ +void Display::CreateStringRussian(const string rustext) +{ +// CHANGED ASCII: +// 0123456789АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя.,:-°±%<>rHYTICS + int len = rustext.length(); + int j = 0; + for (int i = 0; i < len; i ++) { + uint16_t res = uint8_t(rustext[i]); + if (res > 0x7F) { + res = res << 8 | uint8_t(rustext[i + 1]); + // АБВ ... ноп + if ((res >= 0xD090) && (res <= 0xD0BF)) { + char offset = (char)(res - 0xD090); + russianStr[j] = 32 + 11 + offset; + // рст ... эюя + } else if ((res >= 0xD180) && (res <= 0xD18F)) { + char offset = (char)(res - 0xD180); + russianStr[j] = 32 + 59 + offset; + } + // Degree sign + else if (res == 0xC2B0) { + russianStr[j] = 32 + 79; + } + // Plus-minus sign + else if (res == 0xC2B1) { + russianStr[j] = 32 + 80; + } + i++; + } else { + // Space + if (res == 0x20) { + russianStr[j] = 32; + } + // Numbers + else if (res >= 0x30 && res <= 0x39) { + russianStr[j] = 32 + 1 + (res - 0x30); + } + // . + else if (res == 0x2E) { + russianStr[j] = 32 + 75; + } + // , + else if (res == 0x2C) { + russianStr[j] = 32 + 76; + } + // : + else if (res == 0x3A) { + russianStr[j] = 32 + 77; + } + // - + else if (res == 0x2D) { + russianStr[j] = 32 + 78; + } + // % + else if (res == 0x25) { + russianStr[j] = 32 + 81; + } + // < + else if (res == 0x3C) { + russianStr[j] = 32 + 82; + } + // > + else if (res == 0x3C) { + russianStr[j] = 32 + 83; + } + // "r" + else if (res == 0x72) { + russianStr[j] = 32 + 84; + } + // "H" + else if (res == 0x48) { + russianStr[j] = 32 + 85; + } + // "Y" + else if (res == 0x59) { + russianStr[j] = 32 + 86; + } + // "T" + else if (res == 0x54) { + russianStr[j] = 32 + 87; + } + // "I" + else if (res == 0x49) { + russianStr[j] = 32 + 88; + } + // "C" + else if (res == 0x43) { + russianStr[j] = 32 + 89; + } + // "S" + else if (res == 0x53) { + russianStr[j] = 32 + 90; + } + } + j++; + } + russianStr[j] = 0; +} + +/*************************************************************************************************************************/ +void Display::CreateStringHumidity(char *str, uint8_t humidity) +{ + uint8_t strCnt = 0; + if (humidity == 100) { + str[strCnt] = 32 + 2; + strCnt++; + } + if (humidity >= 10) { + str[strCnt] = 32 + 1 + humidity / 10; + strCnt++; + } + str[strCnt] = 32 + 1 + humidity % 10; + strCnt++; + str[strCnt] = 32 + 81; + strCnt++; +// str[strCnt] = 32 + 84; +// strCnt++; +// str[strCnt] = 32 + 85; +// strCnt++; + str[strCnt] = 0; +} + +/*************************************************************************************************************************/ +void Display::CreateStringFlow(char *str, float flow) +{ + int8_t multipedFlow = (int8_t)(flow * 10); + uint8_t strCnt = 0; + if (multipedFlow == 100) { + str[strCnt] = 32 + 2; + strCnt++; + } + if (multipedFlow >= 10) { + str[strCnt] = 32 + 1 + multipedFlow / 10; + } else { + str[strCnt] = 32 + 1; + } + strCnt++; + str[strCnt] = 32 + 75; + strCnt++; + str[strCnt] = 32 + 1 + multipedFlow % 10; + strCnt++; + str[strCnt] = 32; + strCnt++; + str[strCnt] = 32 + 55; + strCnt++; + str[strCnt] = 32 + 86; + strCnt++; + str[strCnt] = 32 + 60; + strCnt++; + str[strCnt] = 0; +} + +/*************************************************************************************************************************/ +void Display::CreateStringTemperature(char *str, int8_t temperature) +{ + int8_t strCnt = 0; + if (temperature < 0) { + temperature = -temperature; + str[strCnt] = 32 + 78; + strCnt++; + } + if (temperature >= 10) { + str[strCnt] = 32 + 1 + temperature / 10; + strCnt++; + } + str[strCnt] = 32 + 1 + temperature % 10; + strCnt++; + str[strCnt] = 32 + 79; + strCnt++; + str[strCnt] = 32 + 87; + strCnt++; + str[strCnt] = 0; +}
diff -r 000000000000 -r 3f440c2facb0 TFT/UpdateDataToDraw.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/UpdateDataToDraw.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,23 @@ +#include "Display.h" + +/*************************************************************************************************************************/ +void Display::UpdateDataToDraw(uint8_t humidity, int8_t temperature, float flow) +{ + if (current_X >= POINTS_NUMBER) { + current_X = 0; + } else { + current_X ++; + } + + flow_Y[current_X] = flow * 20; + humidity_Y[current_X] = humidity * 2; + temperature_Y[current_X] = (temperature + 10) * 4; + + flow_Y[current_X] = flow_Y[current_X] + Y_BOTTOM_OFFSET; + humidity_Y[current_X] = humidity_Y[current_X] + Y_BOTTOM_OFFSET; + temperature_Y[current_X] = temperature_Y[current_X] + Y_BOTTOM_OFFSET; + + CreateStringHumidity(humidityStr, humidity); + CreateStringFlow(flowStr, flow); + CreateStringTemperature(temperatureStr, temperature); +}
diff -r 000000000000 -r 3f440c2facb0 TFT/fonts.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT/fonts.h Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,94 @@ + +#define FONT_ADDR_ROBOTO_REGULAR_16 82116 +#define FONT_SET_ROBOTO_REGULAR_16 87088 +const unsigned char font_RobotoRegular16[] = { + 120, 218, 221, 91, 93, 108, 19, 217, 21, 190, 254, 247, 248, 39, 246, 150, 190, 160, 22, 108, 105, 95, 250, 167, 198, 200, 82, 203, 210, 82, 103, 209, + 104, 183, 80, 109, 19, 169, 203, 67, 43, 26, 71, 90, 250, 182, 139, 141, 138, 84, 245, 165, 246, 67, 86, 171, 62, 128, 131, 154, 246, 165, 43, 28, + 45, 169, 212, 23, 226, 180, 101, 31, 186, 187, 196, 150, 86, 108, 171, 46, 144, 84, 109, 41, 219, 130, 18, 86, 45, 129, 128, 54, 9, 4, 123, 226, + 36, 158, 222, 123, 190, 51, 33, 73, 201, 15, 100, 28, 104, 71, 73, 62, 102, 230, 206, 189, 103, 206, 61, 247, 156, 239, 156, 59, 8, 177, 246, 225, + 214, 228, 17, 80, 63, 1, 121, 104, 97, 45, 18, 12, 6, 3, 193, 22, 245, 55, 16, 12, 132, 3, 161, 96, 36, 18, 14, 7, 2, 45, 178, 145, + 230, 11, 106, 33, 191, 166, 249, 181, 144, 70, 135, 63, 228, 151, 207, 180, 4, 229, 105, 88, 115, 187, 220, 94, 175, 188, 227, 247, 4, 125, 1, 171, + 127, 167, 252, 245, 203, 223, 168, 252, 253, 180, 248, 63, 57, 60, 163, 127, 35, 76, 245, 22, 19, 10, 207, 137, 240, 160, 194, 91, 66, 27, 83, 104, + 8, 255, 212, 90, 104, 181, 179, 158, 107, 239, 45, 182, 45, 237, 119, 179, 199, 215, 70, 243, 132, 159, 43, 0, 69, 196, 102, 220, 180, 254, 110, 18, + 166, 123, 115, 212, 225, 85, 17, 36, 125, 252, 74, 104, 83, 104, 17, 174, 0, 51, 164, 23, 225, 154, 197, 233, 151, 113, 217, 113, 45, 74, 24, 186, + 139, 203, 165, 110, 157, 218, 153, 166, 57, 101, 135, 124, 62, 150, 175, 208, 157, 235, 81, 56, 33, 2, 36, 95, 148, 231, 77, 136, 111, 64, 17, 195, + 115, 56, 125, 54, 151, 197, 63, 2, 35, 234, 239, 43, 252, 30, 183, 69, 144, 206, 115, 221, 133, 46, 244, 123, 217, 38, 11, 204, 96, 124, 199, 36, + 80, 227, 9, 111, 77, 3, 223, 197, 68, 121, 238, 2, 91, 242, 192, 227, 81, 160, 212, 147, 169, 48, 153, 76, 157, 110, 198, 4, 183, 154, 38, 233, + 173, 253, 176, 30, 39, 105, 49, 93, 162, 192, 247, 75, 195, 227, 132, 229, 87, 138, 29, 10, 245, 197, 249, 134, 222, 190, 179, 168, 63, 92, 47, 116, + 163, 157, 127, 210, 158, 245, 33, 78, 44, 144, 189, 132, 110, 188, 64, 242, 229, 226, 184, 252, 33, 223, 174, 151, 230, 232, 138, 217, 221, 73, 243, 55, + 43, 220, 247, 177, 126, 213, 143, 178, 7, 81, 83, 120, 42, 234, 153, 33, 179, 60, 223, 73, 114, 58, 203, 245, 168, 29, 226, 89, 243, 163, 235, 250, + 85, 182, 200, 235, 172, 217, 14, 224, 123, 236, 93, 103, 88, 109, 108, 150, 45, 61, 203, 155, 101, 18, 43, 20, 111, 143, 250, 220, 195, 183, 48, 204, + 89, 172, 143, 92, 20, 235, 35, 23, 197, 188, 181, 158, 76, 145, 29, 185, 204, 58, 86, 75, 111, 39, 181, 187, 32, 92, 247, 161, 79, 232, 241, 182, + 112, 85, 233, 185, 222, 78, 122, 63, 239, 232, 92, 220, 14, 249, 92, 44, 95, 234, 108, 134, 252, 235, 144, 240, 222, 195, 184, 142, 218, 210, 241, 175, + 50, 102, 142, 126, 145, 208, 111, 26, 6, 58, 120, 166, 138, 158, 188, 228, 97, 188, 47, 227, 61, 3, 147, 127, 183, 71, 129, 218, 52, 47, 55, 30, + 38, 125, 1, 248, 110, 154, 222, 223, 81, 141, 144, 63, 241, 77, 195, 159, 132, 43, 30, 146, 63, 117, 244, 83, 228, 8, 11, 166, 217, 80, 120, 71, + 215, 115, 210, 144, 149, 113, 182, 244, 9, 114, 82, 254, 41, 123, 236, 143, 236, 185, 174, 235, 9, 182, 123, 241, 48, 52, 205, 5, 146, 179, 158, 124, + 174, 198, 215, 207, 49, 22, 25, 47, 162, 159, 253, 85, 110, 223, 101, 207, 250, 152, 75, 160, 223, 67, 119, 49, 142, 195, 26, 159, 113, 251, 199, 252, + 30, 29, 144, 239, 171, 247, 87, 145, 111, 136, 229, 171, 217, 43, 31, 226, 208, 122, 250, 123, 92, 220, 244, 33, 13, 136, 250, 42, 232, 186, 193, 254, + 225, 161, 88, 100, 28, 96, 252, 144, 177, 6, 244, 76, 3, 95, 58, 171, 235, 245, 54, 248, 45, 245, 230, 234, 154, 111, 9, 126, 160, 218, 86, 30, + 73, 127, 53, 214, 223, 243, 107, 219, 31, 219, 105, 50, 25, 95, 171, 157, 236, 103, 31, 183, 183, 69, 133, 229, 168, 236, 90, 187, 39, 98, 125, 18, + 91, 243, 194, 59, 35, 81, 89, 250, 69, 97, 80, 68, 104, 205, 26, 59, 149, 199, 8, 202, 17, 149, 100, 169, 159, 213, 219, 251, 20, 95, 136, 26, + 126, 185, 146, 61, 53, 97, 56, 238, 200, 69, 59, 38, 159, 203, 117, 169, 31, 67, 132, 199, 28, 11, 74, 100, 207, 230, 69, 244, 12, 55, 78, 146, + 95, 125, 251, 133, 79, 162, 228, 103, 165, 68, 32, 225, 49, 16, 21, 231, 25, 10, 84, 49, 243, 207, 240, 119, 95, 225, 56, 35, 82, 106, 1, 188, + 206, 68, 224, 154, 12, 225, 106, 1, 165, 207, 191, 56, 79, 126, 191, 188, 96, 11, 63, 144, 111, 216, 158, 7, 142, 2, 125, 38, 48, 86, 4, 14, + 208, 248, 134, 171, 10, 12, 87, 128, 153, 4, 97, 253, 22, 228, 51, 175, 51, 118, 1, 23, 54, 74, 96, 142, 186, 17, 32, 175, 236, 64, 243, 244, + 2, 226, 182, 35, 97, 201, 151, 90, 46, 159, 119, 133, 124, 165, 216, 50, 249, 66, 35, 203, 229, 155, 96, 185, 166, 25, 179, 143, 40, 223, 250, 250, + 163, 196, 67, 202, 197, 126, 141, 212, 41, 12, 231, 109, 220, 223, 49, 194, 235, 3, 244, 185, 190, 23, 231, 6, 243, 104, 67, 20, 58, 128, 161, 235, + 64, 231, 60, 247, 155, 206, 219, 235, 0, 15, 76, 109, 36, 33, 98, 148, 94, 156, 80, 178, 4, 66, 223, 52, 161, 35, 211, 71, 232, 145, 236, 202, + 158, 248, 38, 213, 18, 148, 47, 107, 202, 53, 25, 147, 216, 144, 157, 254, 68, 226, 172, 140, 82, 87, 20, 201, 123, 83, 184, 238, 42, 76, 197, 181, + 138, 194, 112, 62, 210, 165, 208, 55, 150, 38, 18, 232, 152, 249, 61, 200, 224, 123, 247, 128, 233, 17, 96, 75, 214, 14, 39, 109, 176, 157, 108, 20, + 149, 219, 205, 195, 15, 166, 54, 210, 222, 6, 254, 156, 7, 127, 126, 145, 18, 160, 92, 66, 180, 103, 193, 167, 66, 21, 240, 43, 34, 130, 6, 243, + 17, 11, 173, 235, 86, 59, 235, 57, 171, 31, 171, 95, 59, 248, 115, 30, 126, 191, 61, 255, 24, 250, 108, 182, 254, 44, 158, 33, 151, 71, 117, 41, + 79, 90, 201, 75, 228, 250, 54, 248, 125, 122, 16, 231, 118, 109, 13, 63, 56, 181, 56, 191, 243, 60, 191, 233, 54, 204, 91, 75, 22, 243, 248, 208, + 113, 173, 235, 86, 59, 235, 57, 107, 126, 29, 167, 236, 155, 95, 101, 71, 250, 129, 25, 36, 254, 150, 87, 176, 11, 55, 153, 126, 72, 125, 40, 94, + 46, 46, 81, 8, 149, 78, 181, 205, 69, 124, 166, 101, 16, 196, 223, 55, 173, 232, 186, 242, 119, 237, 112, 208, 103, 6, 56, 250, 214, 128, 33, 206, + 15, 208, 76, 184, 81, 102, 18, 145, 241, 205, 138, 182, 34, 207, 63, 110, 154, 191, 83, 195, 141, 167, 250, 75, 50, 34, 20, 226, 145, 188, 146, 240, + 159, 242, 190, 179, 170, 230, 83, 182, 51, 84, 190, 27, 201, 43, 134, 125, 42, 26, 201, 251, 36, 227, 222, 249, 126, 228, 164, 170, 220, 56, 202, 166, + 121, 131, 94, 36, 245, 150, 141, 245, 3, 167, 52, 150, 130, 82, 76, 174, 205, 73, 9, 100, 120, 36, 64, 10, 113, 87, 219, 65, 95, 6, 174, 161, + 101, 140, 243, 223, 214, 251, 192, 161, 75, 224, 63, 213, 86, 212, 61, 42, 26, 229, 7, 197, 132, 98, 91, 194, 37, 59, 203, 117, 136, 173, 247, 207, + 235, 225, 220, 193, 131, 233, 215, 227, 176, 235, 213, 74, 118, 193, 46, 251, 228, 155, 96, 44, 181, 57, 41, 222, 127, 198, 52, 81, 72, 218, 182, 107, + 75, 42, 128, 20, 238, 99, 89, 219, 176, 174, 28, 65, 58, 139, 252, 195, 204, 218, 35, 31, 153, 190, 61, 72, 242, 181, 191, 197, 242, 173, 230, 181, + 63, 120, 4, 255, 135, 89, 64, 116, 91, 107, 182, 76, 147, 42, 22, 145, 211, 201, 98, 22, 215, 169, 34, 41, 145, 2, 177, 196, 16, 157, 247, 235, + 197, 46, 180, 191, 108, 207, 250, 32, 87, 186, 30, 170, 250, 129, 66, 85, 63, 224, 235, 231, 24, 139, 140, 23, 233, 190, 190, 191, 202, 237, 187, 236, + 112, 209, 27, 205, 179, 31, 212, 55, 118, 111, 105, 125, 195, 85, 158, 167, 184, 144, 122, 251, 0, 57, 54, 57, 72, 73, 37, 40, 127, 120, 80, 217, + 195, 12, 231, 216, 18, 182, 129, 247, 89, 215, 101, 28, 78, 117, 208, 254, 130, 74, 85, 229, 201, 121, 240, 12, 171, 95, 27, 214, 199, 232, 68, 92, + 225, 104, 247, 33, 233, 130, 13, 255, 12, 49, 22, 163, 165, 66, 35, 27, 145, 30, 146, 132, 164, 83, 246, 159, 2, 26, 45, 184, 110, 4, 185, 157, + 155, 159, 19, 197, 99, 212, 143, 240, 82, 191, 155, 207, 127, 177, 200, 50, 253, 250, 178, 58, 223, 131, 186, 163, 85, 247, 3, 122, 121, 81, 58, 107, + 73, 194, 192, 24, 174, 183, 118, 45, 43, 127, 56, 107, 54, 82, 172, 181, 234, 170, 169, 254, 28, 5, 254, 239, 137, 192, 50, 98, 178, 125, 18, 105, + 85, 249, 135, 123, 166, 240, 62, 184, 127, 233, 224, 0, 225, 151, 26, 63, 154, 222, 156, 4, 126, 20, 146, 63, 63, 74, 227, 123, 204, 43, 40, 19, + 252, 22, 119, 143, 115, 171, 143, 172, 250, 120, 111, 39, 181, 159, 231, 250, 184, 165, 223, 91, 92, 135, 59, 35, 80, 31, 79, 245, 31, 169, 112, 93, + 54, 218, 76, 253, 153, 230, 68, 20, 235, 49, 83, 129, 157, 106, 156, 94, 238, 29, 228, 245, 137, 251, 201, 206, 190, 165, 247, 235, 58, 234, 247, 166, + 105, 79, 253, 121, 117, 249, 170, 92, 143, 122, 254, 201, 214, 255, 86, 23, 208, 96, 1, 13, 30, 112, 57, 214, 128, 174, 25, 160, 198, 235, 36, 221, + 79, 229, 191, 69, 94, 190, 50, 239, 147, 145, 205, 91, 177, 195, 47, 14, 95, 230, 125, 7, 212, 47, 74, 81, 74, 35, 229, 122, 198, 60, 90, 101, + 135, 137, 100, 50, 177, 100, 151, 68, 218, 223, 119, 179, 120, 190, 169, 243, 171, 169, 98, 64, 73, 142, 112, 71, 24, 42, 7, 144, 188, 223, 160, 112, + 27, 172, 24, 68, 244, 221, 210, 0, 137, 207, 254, 165, 158, 81, 129, 162, 32, 239, 203, 5, 43, 73, 174, 161, 56, 175, 100, 253, 86, 101, 166, 73, + 2, 78, 66, 127, 165, 238, 18, 197, 129, 95, 47, 18, 5, 222, 103, 229, 253, 26, 145, 36, 250, 45, 126, 193, 247, 203, 199, 208, 126, 251, 228, 229, + 166, 154, 159, 33, 194, 188, 94, 115, 64, 71, 3, 24, 248, 8, 216, 254, 77, 248, 189, 127, 192, 31, 54, 166, 129, 102, 22, 184, 176, 201, 4, 46, + 220, 245, 26, 97, 224, 55, 239, 32, 17, 153, 252, 152, 13, 239, 233, 144, 111, 125, 253, 181, 14, 2, 47, 145, 159, 163, 98, 51, 201, 5, 78, 140, + 93, 35, 185, 188, 211, 216, 39, 52, 124, 85, 126, 174, 204, 251, 20, 59, 175, 55, 83, 190, 8, 175, 207, 72, 63, 202, 130, 145, 188, 255, 161, 24, + 99, 125, 165, 218, 80, 14, 28, 130, 222, 66, 127, 109, 178, 254, 204, 132, 208, 212, 186, 53, 123, 68, 132, 112, 74, 100, 20, 206, 86, 197, 159, 20, + 26, 111, 186, 238, 17, 166, 158, 171, 16, 134, 74, 29, 132, 158, 6, 57, 66, 67, 220, 108, 170, 143, 94, 175, 140, 186, 88, 118, 77, 238, 89, 179, + 93, 179, 14, 215, 226, 190, 112, 166, 15, 188, 9, 251, 174, 19, 15, 246, 231, 140, 165, 231, 214, 253, 86, 222, 167, 181, 158, 111, 94, 120, 123, 172, + 178, 244, 150, 233, 239, 126, 233, 6, 228, 60, 86, 110, 3, 159, 106, 225, 245, 140, 253, 245, 7, 114, 104, 204, 255, 240, 125, 132, 121, 172, 68, 81, + 99, 182, 52, 222, 84, 222, 224, 30, 190, 201, 241, 20, 85, 138, 33, 150, 75, 206, 103, 124, 233, 56, 19, 140, 67, 66, 27, 89, 218, 222, 61, 60, + 190, 37, 243, 171, 183, 247, 183, 109, 168, 138, 209, 164, 239, 155, 86, 11, 191, 211, 106, 199, 80, 168, 143, 30, 16, 111, 175, 162, 204, 43, 114, 81, + 104, 46, 246, 3, 248, 235, 224, 59, 216, 175, 241, 88, 181, 12, 147, 105, 51, 127, 38, 224, 228, 207, 6, 14, 129, 173, 59, 22, 18, 246, 100, 190, + 254, 79, 26, 13, 197, 75, 210, 189, 115, 7, 102, 40, 127, 52, 84, 174, 36, 231, 211, 80, 57, 16, 209, 192, 2, 217, 157, 65, 9, 240, 5, 137, + 106, 227, 48, 211, 93, 223, 175, 18, 0, 173, 209, 104, 100, 155, 103, 129, 238, 26, 202, 170, 162, 244, 12, 120, 202, 206, 159, 34, 221, 241, 154, 156, + 118, 155, 0, 31, 235, 173, 245, 141, 187, 108, 135, 183, 81, 22, 20, 153, 14, 241, 4, 253, 243, 106, 168, 234, 67, 86, 93, 155, 187, 42, 172, 192, + 87, 237, 145, 15, 6, 190, 18, 121, 59, 85, 12, 36, 80, 55, 221, 97, 21, 152, 158, 141, 109, 233, 2, 81, 214, 165, 54, 168, 31, 21, 235, 122, + 73, 149, 255, 132, 77, 229, 191, 53, 229, 83, 26, 120, 84, 84, 242, 181, 247, 179, 124, 205, 155, 97, 31, 103, 111, 14, 253, 191, 11, 89, 216, 154, + 169, 39, 51, 156, 248, 6, 166, 150, 6, 22, 153, 48, 247, 160, 221, 173, 230, 206, 47, 94, 119, 53, 148, 249, 119, 180, 128, 252, 188, 82, 224, 56, + 71, 231, 250, 145, 193, 2, 231, 247, 133, 38, 203, 183, 118, 61, 112, 206, 170, 31, 84, 150, 215, 15, 142, 12, 46, 173, 63, 52, 235, 240, 77, 190, + 143, 120, 209, 93, 138, 35, 206, 242, 6, 17, 79, 163, 40, 240, 247, 175, 219, 246, 96, 90, 69, 136, 238, 23, 143, 21, 169, 189, 159, 159, 111, 162, + 255, 163, 17, 100, 116, 56, 92, 86, 245, 65, 25, 168, 148, 132, 134, 119, 154, 36, 84, 225, 153, 234, 185, 187, 113, 110, 184, 248, 190, 40, 163, 189, + 204, 80, 155, 41, 225, 98, 253, 236, 240, 1, 230, 79, 240, 191, 215, 226, 192, 189, 204, 31, 180, 25, 240, 231, 86, 206, 71, 6, 162, 200, 67, 106, + 77, 230, 127, 143, 123, 236, 219, 170, 250, 208, 38, 215, 21, 239, 110, 186, 184, 72, 233, 235, 105, 210, 56, 251, 254, 199, 244, 103, 197, 132, 100, 114, + 107, 198, 251, 246, 191, 128, 119, 46, 113, 61, 128, 191, 11, 206, 241, 4, 57, 227, 79, 153, 1, 173, 194, 211, 45, 190, 159, 76, 157, 78, 172, 213, + 78, 215, 237, 253, 255, 1, 95, 159, 135, 130, 174, 189, 52, 226, 138, 82, 157, 101, 106, 135, 194, 59, 159, 29, 251, 57, 213, 67, 205, 151, 41, 30, + 56, 118, 133, 89, 147, 111, 20, 176, 193, 112, 222, 160, 202, 90, 104, 247, 20, 137, 246, 99, 63, 176, 195, 141, 235, 66, 156, 168, 109, 137, 66, 191, + 0, 150, 180, 167, 65, 124, 248, 91, 188, 109, 213, 128, 12, 226, 200, 44, 39, 20, 175, 205, 243, 63, 190, 111, 241, 190, 232, 86, 72, 103, 85, 25, + 203, 156, 46, 58, 79, 140, 243, 184, 69, 200, 241, 106, 157, 244, 122, 2, 32, 102, 163, 91, 35, 156, 81, 198, 120, 230, 97, 156, 207, 110, 144, 55, + 216, 157, 135, 63, 245, 223, 135, 185, 121, 153, 5, 152, 158, 196, 44, 195, 226, 251, 127, 228, 121, 229, 255, 191, 227, 175, 112, 253, 149, 185, 123, 138, + 39, 242, 151, 220, 252, 223, 0, 15, 247, 26, 220, 116, 220, 120, 178, 223, 55, 253, 7, 22, 214, 192, 176, +};
diff -r 000000000000 -r 3f440c2facb0 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,88 @@ +#include "mbed.h" +#include "FT_Platform.h" +#include "HYT.h" +#include "Display.h" + +HYT SENSOR(PD6, PD7); // sda, scl [efm32hg_stk3400] +FT800 TFT(PE10, PE11, PE12, PE13, PA1, PB11); // mosi, miso, sck, ss, int, pd [efm32hg_stk3400] +AnalogIn ADC(PD4); // [efm32hg_stk3400] + +Display disp(&TFT); + +uint8_t humidity; +float flow; +int8_t temperature; + +#define HUMIDITY_CORRECTION 15 +#define TEMPERATURE_CORRECTION -1 + +/*************************************************************************************************************************/ +float calculateFlow(uint16_t resultADC) +{ + uint16_t flowVoltage; + if ((resultADC / 1000) - 32 >= 0) { + flowVoltage = (resultADC / 1000) - 32; + } else { + flowVoltage = 0; + } + + float voltageToSpeed[31] = { 0, 0, 0, 0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.3, + 0.4, 0.5, 0.6, 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.3, 2.8, 3.2, 3.9, + 4.5, 5.1, 5.8, 6.5, 7.4, 8.2, 9.1, 10 + }; + float flowSpeed = voltageToSpeed[flowVoltage]; + + return flowSpeed; +} + +/*************************************************************************************************************************/ +uint8_t calculateHumidity(uint8_t humidityFromHYT) +{ + uint8_t humidityFinal; + if (humidityFromHYT + 15 >= 100) { + humidityFinal = 100; + } else { + humidityFinal = humidityFromHYT + HUMIDITY_CORRECTION; + } + + return humidityFinal; +} + +/*************************************************************************************************************************/ +int8_t calculateTemperature(int8_t temperatureFromHYT) +{ + return temperatureFromHYT + TEMPERATURE_CORRECTION; +} + +/**************************************************************************************************************************/ +int main() +{ + disp.Calibration(); + + disp.LoadImagesAndFonts(); + disp.HandleAllBitmaps(); + + disp.showHumidity = 1; + disp.showFlow = 1; + disp.showTemperature = 1; + + // first point + SENSOR.MRCommand(); + wait_ms(100); + SENSOR.DFCommand(); + + while (1) { + SENSOR.MRCommand(); + + humidity = calculateHumidity((uint8_t) SENSOR.humidity); + flow = calculateFlow(ADC.read_u16()); + temperature = calculateTemperature((int8_t) SENSOR.temperature); + + disp.UpdateDataToDraw(humidity, temperature, flow); + disp.MainScreen(); + + disp.GetTouch(); + + SENSOR.DFCommand(); + } +}
diff -r 000000000000 -r 3f440c2facb0 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Mar 16 08:58:18 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/bad568076d81 \ No newline at end of file