test

Dependencies:   ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259

Committer:
nikmaos
Date:
Tue Sep 01 10:52:34 2020 +0000
Revision:
7:c364201bc3ed
Parent:
3:d4b106bf3a32
1.09.2020;

Who changed what in which revision?

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