Riverdi 70

Dependencies:   mbed HYT FT813

Committer:
vitlog
Date:
Thu Jun 18 13:18:02 2020 +0000
Revision:
0:e46c1282b39f
Riverdi EVE 70

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vitlog 0:e46c1282b39f 1 #include "display.h"
vitlog 0:e46c1282b39f 2
vitlog 0:e46c1282b39f 3 /**************************************************************************************************************************
vitlog 0:e46c1282b39f 4 ************************** Display real-time humidity *********************************************************************
vitlog 0:e46c1282b39f 5 **************************************************************************************************************************/
vitlog 0:e46c1282b39f 6 void Display::CurrentHumidity(float humidity)
vitlog 0:e46c1282b39f 7 {
vitlog 0:e46c1282b39f 8 // accelerator for x-axis data output
vitlog 0:e46c1282b39f 9 char accelerator = 6;
vitlog 0:e46c1282b39f 10 // create string including current humididty and " %"
vitlog 0:e46c1282b39f 11 CreateStringTempHum(humidityStr, humidity, 0);
vitlog 0:e46c1282b39f 12 // write the new scalable (* 1.5) data to the next available array position
vitlog 0:e46c1282b39f 13 currentHumidity_Y[currentHumidity_X] = (char)(humidity * 1.5);
vitlog 0:e46c1282b39f 14
vitlog 0:e46c1282b39f 15 // start FT800 display list
vitlog 0:e46c1282b39f 16 StartDL();
vitlog 0:e46c1282b39f 17
vitlog 0:e46c1282b39f 18 // draw bottom color for graph line
vitlog 0:e46c1282b39f 19 (*_TFT).DL(COLOR_RGB(200, 200, 200));
vitlog 0:e46c1282b39f 20 (*_TFT).DL(BEGIN(EDGE_STRIP_B));
vitlog 0:e46c1282b39f 21 for (int i = 0; i < 68; i++) {
vitlog 0:e46c1282b39f 22 if (currentHumidity_Y[i] != 0 && i <= currentHumidity_X) {
vitlog 0:e46c1282b39f 23 (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (220 - currentHumidity_Y[i]) * 16));
vitlog 0:e46c1282b39f 24 }
vitlog 0:e46c1282b39f 25 }
vitlog 0:e46c1282b39f 26
vitlog 0:e46c1282b39f 27 // draw horisontal grid for humidity (0 .. 100)
vitlog 0:e46c1282b39f 28 HorisontalGrid_CurrentHumidity();
vitlog 0:e46c1282b39f 29
vitlog 0:e46c1282b39f 30 // draw main graph line
vitlog 0:e46c1282b39f 31 (*_TFT).DL(COLOR_RGB(9, 0, 63));
vitlog 0:e46c1282b39f 32 (*_TFT).DL(BEGIN(POINTS));
vitlog 0:e46c1282b39f 33 (*_TFT).DL(POINT_SIZE(25));
vitlog 0:e46c1282b39f 34 for (int i = 0; i < 68; i++) {
vitlog 0:e46c1282b39f 35 if (currentHumidity_Y[i] != 0 && (i < currentHumidity_X || i >= currentHumidity_X + 13)) {
vitlog 0:e46c1282b39f 36 (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (222 - currentHumidity_Y[i]) * 16));
vitlog 0:e46c1282b39f 37 }
vitlog 0:e46c1282b39f 38 }
vitlog 0:e46c1282b39f 39
vitlog 0:e46c1282b39f 40 // draw subtitle for main graph line
vitlog 0:e46c1282b39f 41 (*_TFT).DL(COLOR_RGB(255, 255, 255));
vitlog 0:e46c1282b39f 42 (*_TFT).DL(BEGIN(RECTS));
vitlog 0:e46c1282b39f 43 (*_TFT).DL(VERTEX2II((currentHumidity_X * accelerator + 40) + 25, (200 - currentHumidity_Y[currentHumidity_X]), 0, 0));
vitlog 0:e46c1282b39f 44 (*_TFT).DL(VERTEX2II((currentHumidity_X * accelerator + 40), (177 - currentHumidity_Y[currentHumidity_X]), 0, 0));
vitlog 0:e46c1282b39f 45 (*_TFT).DL(COLOR_RGB(255, 0, 0));
vitlog 0:e46c1282b39f 46 (*_TFT).Text((currentHumidity_X * accelerator + 30), (180 - currentHumidity_Y[currentHumidity_X] - 7), 28, 0, humidityStr);
vitlog 0:e46c1282b39f 47 (*_TFT).DL(BEGIN(LINES));
vitlog 0:e46c1282b39f 48 (*_TFT).DL(LINE_WIDTH(8));
vitlog 0:e46c1282b39f 49 (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 15) * 16, (220 - currentHumidity_Y[currentHumidity_X]) * 16));
vitlog 0:e46c1282b39f 50 (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 35) * 16, (200 - currentHumidity_Y[currentHumidity_X]) * 16));
vitlog 0:e46c1282b39f 51 (*_TFT).DL(COLOR_RGB(255, 30, 33));
vitlog 0:e46c1282b39f 52 (*_TFT).DL(BEGIN(POINTS));
vitlog 0:e46c1282b39f 53 (*_TFT).DL(POINT_SIZE(33));
vitlog 0:e46c1282b39f 54 (*_TFT).DL(VERTEX2F((currentHumidity_X * accelerator + 15) * 16, (220 - currentHumidity_Y[currentHumidity_X]) * 16));
vitlog 0:e46c1282b39f 55 (*_TFT).DL(END());
vitlog 0:e46c1282b39f 56
vitlog 0:e46c1282b39f 57 // write main title
vitlog 0:e46c1282b39f 58 (*_TFT).DL(COLOR_RGB(0, 0, 0));
vitlog 0:e46c1282b39f 59 (*_TFT).Text(15, 15, 30, 0, "Current humidity, rH");
vitlog 0:e46c1282b39f 60
vitlog 0:e46c1282b39f 61 // clean the space under the plot, create link to the main menu
vitlog 0:e46c1282b39f 62 (*_TFT).DL(SCISSOR_XY(15, 222));
vitlog 0:e46c1282b39f 63 (*_TFT).DL(SCISSOR_SIZE(420, 53));
vitlog 0:e46c1282b39f 64 (*_TFT).Gradient(0, 256, 0xFFFFFF, 450, 16, 0xFFFFFF);
vitlog 0:e46c1282b39f 65 MainMenuReference();
vitlog 0:e46c1282b39f 66
vitlog 0:e46c1282b39f 67 // finish FT801 display list
vitlog 0:e46c1282b39f 68 FinishDL();
vitlog 0:e46c1282b39f 69
vitlog 0:e46c1282b39f 70 // manage the index for array
vitlog 0:e46c1282b39f 71 if (currentHumidity_X >= 68) {
vitlog 0:e46c1282b39f 72 currentHumidity_X = 0;
vitlog 0:e46c1282b39f 73 } else {
vitlog 0:e46c1282b39f 74 currentHumidity_X ++;
vitlog 0:e46c1282b39f 75 }
vitlog 0:e46c1282b39f 76 if (pressedButton == MENU_PRESS) {
vitlog 0:e46c1282b39f 77 for (int i = 0; i < 68; i++) {
vitlog 0:e46c1282b39f 78 currentHumidity_Y[i] = 0;
vitlog 0:e46c1282b39f 79 currentHumidity_X = 0;
vitlog 0:e46c1282b39f 80 }
vitlog 0:e46c1282b39f 81 }
vitlog 0:e46c1282b39f 82 }
vitlog 0:e46c1282b39f 83
vitlog 0:e46c1282b39f 84 /**************************************************************************************************************************
vitlog 0:e46c1282b39f 85 ************************** Display real-time temperature ******************************************************************
vitlog 0:e46c1282b39f 86 **************************************************************************************************************************/
vitlog 0:e46c1282b39f 87 void Display::CurrentTemperature(float temperature)
vitlog 0:e46c1282b39f 88 {
vitlog 0:e46c1282b39f 89 // accelerator for x-axis data output
vitlog 0:e46c1282b39f 90 char accelerator = 6;
vitlog 0:e46c1282b39f 91 // create string including current temperature with decimal mark and " С"
vitlog 0:e46c1282b39f 92 CreateStringTempHum(temperatureStr, temperature, 1);
vitlog 0:e46c1282b39f 93 // write the new scalable (* 0.88 + 45) data to the next available array position
vitlog 0:e46c1282b39f 94 currentTemperature_Y[currentTemperature_X] = (char)(temperature * 0.88 + 45);
vitlog 0:e46c1282b39f 95
vitlog 0:e46c1282b39f 96 // start FT800 display list
vitlog 0:e46c1282b39f 97 StartDL();
vitlog 0:e46c1282b39f 98
vitlog 0:e46c1282b39f 99 // draw bottom color for graph line
vitlog 0:e46c1282b39f 100 (*_TFT).DL(COLOR_RGB(200, 177, 199));
vitlog 0:e46c1282b39f 101 (*_TFT).DL(BEGIN(EDGE_STRIP_B));
vitlog 0:e46c1282b39f 102 for (int i = 0; i < 68; i++) {
vitlog 0:e46c1282b39f 103 if (currentTemperature_Y[i] != 0 && i <= currentTemperature_X) {
vitlog 0:e46c1282b39f 104 (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (220 - currentTemperature_Y[i]) * 16));
vitlog 0:e46c1282b39f 105 }
vitlog 0:e46c1282b39f 106 }
vitlog 0:e46c1282b39f 107
vitlog 0:e46c1282b39f 108 // draw horisontal grid for temperature (-50 .. +125)
vitlog 0:e46c1282b39f 109 HorisontalGrid_CurrentTemp();
vitlog 0:e46c1282b39f 110
vitlog 0:e46c1282b39f 111 // draw main graph line
vitlog 0:e46c1282b39f 112 (*_TFT).DL(COLOR_RGB(9, 0, 63));
vitlog 0:e46c1282b39f 113 (*_TFT).DL(BEGIN(POINTS));
vitlog 0:e46c1282b39f 114 (*_TFT).DL(POINT_SIZE(25));
vitlog 0:e46c1282b39f 115 for (int i = 0; i < 68; i++) {
vitlog 0:e46c1282b39f 116 if (currentTemperature_Y[i] != 0 && (i < currentTemperature_X || i >= currentTemperature_X + 13)) {
vitlog 0:e46c1282b39f 117 (*_TFT).DL(VERTEX2F((i * accelerator + 15) * 16, (222 - currentTemperature_Y[i]) * 16));
vitlog 0:e46c1282b39f 118 }
vitlog 0:e46c1282b39f 119 }
vitlog 0:e46c1282b39f 120
vitlog 0:e46c1282b39f 121 // draw subtitle for main graph line
vitlog 0:e46c1282b39f 122 (*_TFT).DL(COLOR_RGB(255, 255, 255));
vitlog 0:e46c1282b39f 123 (*_TFT).DL(BEGIN(RECTS));
vitlog 0:e46c1282b39f 124 (*_TFT).DL(VERTEX2II((currentTemperature_X * accelerator + 40) + 25, (200 - currentTemperature_Y[currentTemperature_X]), 0, 0));
vitlog 0:e46c1282b39f 125 (*_TFT).DL(VERTEX2II((currentTemperature_X * accelerator + 40), (177 - currentTemperature_Y[currentTemperature_X]), 0, 0));
vitlog 0:e46c1282b39f 126 (*_TFT).DL(COLOR_RGB(255, 0, 0));
vitlog 0:e46c1282b39f 127 (*_TFT).Text((currentTemperature_X * accelerator + 25), (173 - currentTemperature_Y[currentTemperature_X]), 28, 0, temperatureStr);
vitlog 0:e46c1282b39f 128 (*_TFT).DL(BEGIN(LINES));
vitlog 0:e46c1282b39f 129 (*_TFT).DL(LINE_WIDTH(8));
vitlog 0:e46c1282b39f 130 (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 15) * 16, (220 - currentTemperature_Y[currentTemperature_X]) * 16));
vitlog 0:e46c1282b39f 131 (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 35) * 16, (200 - currentTemperature_Y[currentTemperature_X]) * 16));
vitlog 0:e46c1282b39f 132 (*_TFT).DL(COLOR_RGB(255, 30, 33));
vitlog 0:e46c1282b39f 133 (*_TFT).DL(BEGIN(POINTS));
vitlog 0:e46c1282b39f 134 (*_TFT).DL(POINT_SIZE(33));
vitlog 0:e46c1282b39f 135 (*_TFT).DL(VERTEX2F((currentTemperature_X * accelerator + 15) * 16, (220 - currentTemperature_Y[currentTemperature_X]) * 16));
vitlog 0:e46c1282b39f 136 (*_TFT).DL(END());
vitlog 0:e46c1282b39f 137
vitlog 0:e46c1282b39f 138 // write main title
vitlog 0:e46c1282b39f 139 (*_TFT).DL(COLOR_RGB(0, 0, 0));
vitlog 0:e46c1282b39f 140 (*_TFT).Text(15, 15, 30, 0, "Current temperature");
vitlog 0:e46c1282b39f 141
vitlog 0:e46c1282b39f 142 // clean the space under the plot, create link to the main menu
vitlog 0:e46c1282b39f 143 (*_TFT).DL(SCISSOR_XY(15, 225));
vitlog 0:e46c1282b39f 144 (*_TFT).DL(SCISSOR_SIZE(420, 53));
vitlog 0:e46c1282b39f 145 (*_TFT).Gradient(0, 256, 0xFFFFFF, 450, 16, 0xFFFFFF);
vitlog 0:e46c1282b39f 146 MainMenuReference();
vitlog 0:e46c1282b39f 147
vitlog 0:e46c1282b39f 148 // finish FT801 display list
vitlog 0:e46c1282b39f 149 FinishDL();
vitlog 0:e46c1282b39f 150
vitlog 0:e46c1282b39f 151 // manage the index for array
vitlog 0:e46c1282b39f 152 if (currentTemperature_X >= 68) {
vitlog 0:e46c1282b39f 153 currentTemperature_X = 0;
vitlog 0:e46c1282b39f 154 } else {
vitlog 0:e46c1282b39f 155 currentTemperature_X ++;
vitlog 0:e46c1282b39f 156 }
vitlog 0:e46c1282b39f 157 if (pressedButton == MENU_PRESS) {
vitlog 0:e46c1282b39f 158 for (int i = 0; i < 68; i++) {
vitlog 0:e46c1282b39f 159 currentTemperature_Y[i] = 0;
vitlog 0:e46c1282b39f 160 currentTemperature_X = 0;
vitlog 0:e46c1282b39f 161 }
vitlog 0:e46c1282b39f 162 }
vitlog 0:e46c1282b39f 163 }
vitlog 0:e46c1282b39f 164