Temperature and Pressure logger.
Dependencies: BMP180 N5110 PowerControl beep mbed
main.cpp@1:d320c79324fe, 2015-05-10 (annotated)
- Committer:
- takis94
- Date:
- Sun May 10 22:37:53 2015 +0000
- Revision:
- 1:d320c79324fe
- Parent:
- 0:ec64ecaac130
- Child:
- 2:6f7b97e42fce
final
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takis94 | 0:ec64ecaac130 | 1 | /** |
takis94 | 0:ec64ecaac130 | 2 | @file main.cpp |
takis94 | 0:ec64ecaac130 | 3 | |
takis94 | 0:ec64ecaac130 | 4 | @brief Program implementation |
takis94 | 0:ec64ecaac130 | 5 | |
takis94 | 0:ec64ecaac130 | 6 | */ |
takis94 | 0:ec64ecaac130 | 7 | #include "main.h" |
takis94 | 0:ec64ecaac130 | 8 | |
takis94 | 0:ec64ecaac130 | 9 | void update() |
takis94 | 0:ec64ecaac130 | 10 | { |
takis94 | 1:d320c79324fe | 11 | if (temperature <= -20.0) { // for temperatures -20 and below |
takis94 | 0:ec64ecaac130 | 12 | |
takis94 | 1:d320c79324fe | 13 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,0); // x,y,radius,no fill |
takis94 | 1:d320c79324fe | 14 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 15 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 16 | } |
takis94 | 1:d320c79324fe | 17 | else if (temperature >-20.0 && temperature <= -10.0) { // for temperatures between -20 and -10 |
takis94 | 0:ec64ecaac130 | 18 | |
takis94 | 1:d320c79324fe | 19 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 20 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 21 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 22 | } |
takis94 | 1:d320c79324fe | 23 | else if (temperature >-10.0 && temperature <= 0.0) { // for temperatures between -10 and 0 |
takis94 | 0:ec64ecaac130 | 24 | |
takis94 | 1:d320c79324fe | 25 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 26 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 27 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 28 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 29 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 30 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 31 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 32 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 33 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 34 | } |
takis94 | 1:d320c79324fe | 35 | else if (temperature >0.0 && temperature <= 5.0) { // for temperatures between 0 and 5 |
takis94 | 0:ec64ecaac130 | 36 | |
takis94 | 1:d320c79324fe | 37 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 38 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 39 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 40 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 41 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 42 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 43 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 44 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 45 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 46 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 47 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 48 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 49 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 50 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 51 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 52 | } |
takis94 | 1:d320c79324fe | 53 | else if (temperature >5.0 && temperature <= 10.0) { // for temperatures between 5 and 10 |
takis94 | 0:ec64ecaac130 | 54 | |
takis94 | 1:d320c79324fe | 55 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 56 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 57 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 58 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 59 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 60 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 61 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 62 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 63 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 64 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 65 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 66 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 67 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 68 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 69 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 70 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 71 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 72 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 73 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 74 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 75 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 76 | } |
takis94 | 1:d320c79324fe | 77 | else if (temperature >10.0 && temperature <= 15.0) { // for temperatures between 10 and 15 |
takis94 | 0:ec64ecaac130 | 78 | |
takis94 | 1:d320c79324fe | 79 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 80 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 81 | lcd.drawRect(74,5,4,30,0); //transparent, just outline |
takis94 | 0:ec64ecaac130 | 82 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 83 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 84 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 85 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 86 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 87 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 88 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 89 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 90 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 91 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 92 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 93 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 94 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 95 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 96 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 97 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 98 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 99 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 100 | lcd.setPixel(75,28); |
takis94 | 0:ec64ecaac130 | 101 | lcd.setPixel(76,28); |
takis94 | 0:ec64ecaac130 | 102 | lcd.setPixel(77,28); |
takis94 | 0:ec64ecaac130 | 103 | lcd.setPixel(75,27); |
takis94 | 0:ec64ecaac130 | 104 | lcd.setPixel(76,27); |
takis94 | 0:ec64ecaac130 | 105 | lcd.setPixel(77,27); |
takis94 | 0:ec64ecaac130 | 106 | } |
takis94 | 1:d320c79324fe | 107 | else if (temperature >15.0 && temperature <= 20.0) { // for temperatures between 15 and 20 |
takis94 | 0:ec64ecaac130 | 108 | |
takis94 | 1:d320c79324fe | 109 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 110 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 111 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 112 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 113 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 114 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 115 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 116 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 117 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 118 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 119 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 120 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 121 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 122 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 123 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 124 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 125 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 126 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 127 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 128 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 129 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 130 | lcd.setPixel(75,28); |
takis94 | 0:ec64ecaac130 | 131 | lcd.setPixel(76,28); |
takis94 | 0:ec64ecaac130 | 132 | lcd.setPixel(77,28); |
takis94 | 0:ec64ecaac130 | 133 | lcd.setPixel(75,27); |
takis94 | 0:ec64ecaac130 | 134 | lcd.setPixel(76,27); |
takis94 | 0:ec64ecaac130 | 135 | lcd.setPixel(77,27); |
takis94 | 0:ec64ecaac130 | 136 | lcd.setPixel(75,26); |
takis94 | 0:ec64ecaac130 | 137 | lcd.setPixel(76,26); |
takis94 | 0:ec64ecaac130 | 138 | lcd.setPixel(77,26); |
takis94 | 0:ec64ecaac130 | 139 | lcd.setPixel(75,25); |
takis94 | 0:ec64ecaac130 | 140 | lcd.setPixel(76,25); |
takis94 | 0:ec64ecaac130 | 141 | lcd.setPixel(77,25); |
takis94 | 0:ec64ecaac130 | 142 | } |
takis94 | 1:d320c79324fe | 143 | else if (temperature >20.0 && temperature <= 25.0) { // for temperatures between 20 and 25 |
takis94 | 0:ec64ecaac130 | 144 | |
takis94 | 1:d320c79324fe | 145 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 146 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 147 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 148 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 149 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 150 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 151 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 152 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 153 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 154 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 155 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 156 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 157 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 158 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 159 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 160 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 161 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 162 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 163 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 164 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 165 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 166 | lcd.setPixel(75,28); |
takis94 | 0:ec64ecaac130 | 167 | lcd.setPixel(76,28); |
takis94 | 0:ec64ecaac130 | 168 | lcd.setPixel(77,28); |
takis94 | 0:ec64ecaac130 | 169 | lcd.setPixel(75,27); |
takis94 | 0:ec64ecaac130 | 170 | lcd.setPixel(76,27); |
takis94 | 0:ec64ecaac130 | 171 | lcd.setPixel(77,27); |
takis94 | 0:ec64ecaac130 | 172 | lcd.setPixel(75,26); |
takis94 | 0:ec64ecaac130 | 173 | lcd.setPixel(76,26); |
takis94 | 0:ec64ecaac130 | 174 | lcd.setPixel(77,26); |
takis94 | 0:ec64ecaac130 | 175 | lcd.setPixel(75,25); |
takis94 | 0:ec64ecaac130 | 176 | lcd.setPixel(76,25); |
takis94 | 0:ec64ecaac130 | 177 | lcd.setPixel(77,25); |
takis94 | 0:ec64ecaac130 | 178 | } |
takis94 | 1:d320c79324fe | 179 | else if (temperature >25.0 && temperature <= 30.0) { // for temperatures between 25 and 30 |
takis94 | 0:ec64ecaac130 | 180 | |
takis94 | 1:d320c79324fe | 181 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 182 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 183 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 184 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 185 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 186 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 187 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 188 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 189 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 190 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 191 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 192 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 193 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 194 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 195 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 196 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 197 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 198 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 199 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 200 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 201 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 202 | lcd.setPixel(75,28); |
takis94 | 0:ec64ecaac130 | 203 | lcd.setPixel(76,28); |
takis94 | 0:ec64ecaac130 | 204 | lcd.setPixel(77,28); |
takis94 | 0:ec64ecaac130 | 205 | lcd.setPixel(75,27); |
takis94 | 0:ec64ecaac130 | 206 | lcd.setPixel(76,27); |
takis94 | 0:ec64ecaac130 | 207 | lcd.setPixel(77,27); |
takis94 | 0:ec64ecaac130 | 208 | lcd.setPixel(75,26); |
takis94 | 0:ec64ecaac130 | 209 | lcd.setPixel(76,26); |
takis94 | 0:ec64ecaac130 | 210 | lcd.setPixel(77,26); |
takis94 | 0:ec64ecaac130 | 211 | lcd.setPixel(75,25); |
takis94 | 0:ec64ecaac130 | 212 | lcd.setPixel(76,25); |
takis94 | 0:ec64ecaac130 | 213 | lcd.setPixel(77,25); |
takis94 | 0:ec64ecaac130 | 214 | lcd.setPixel(75,24); |
takis94 | 0:ec64ecaac130 | 215 | lcd.setPixel(76,24); |
takis94 | 0:ec64ecaac130 | 216 | lcd.setPixel(77,24); |
takis94 | 0:ec64ecaac130 | 217 | lcd.setPixel(75,23); |
takis94 | 0:ec64ecaac130 | 218 | lcd.setPixel(76,23); |
takis94 | 0:ec64ecaac130 | 219 | lcd.setPixel(77,23); |
takis94 | 0:ec64ecaac130 | 220 | } |
takis94 | 1:d320c79324fe | 221 | else if (temperature >30.0 && temperature <= 35.0) { // for temperatures between 30 and 35 |
takis94 | 0:ec64ecaac130 | 222 | |
takis94 | 1:d320c79324fe | 223 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 224 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 225 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 226 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 227 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 228 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 229 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 230 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 231 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 232 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 233 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 234 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 235 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 236 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 237 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 238 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 239 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 240 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 241 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 242 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 243 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 244 | lcd.setPixel(75,28); |
takis94 | 0:ec64ecaac130 | 245 | lcd.setPixel(76,28); |
takis94 | 0:ec64ecaac130 | 246 | lcd.setPixel(77,28); |
takis94 | 0:ec64ecaac130 | 247 | lcd.setPixel(75,27); |
takis94 | 0:ec64ecaac130 | 248 | lcd.setPixel(76,27); |
takis94 | 0:ec64ecaac130 | 249 | lcd.setPixel(77,27); |
takis94 | 0:ec64ecaac130 | 250 | lcd.setPixel(75,26); |
takis94 | 0:ec64ecaac130 | 251 | lcd.setPixel(76,26); |
takis94 | 0:ec64ecaac130 | 252 | lcd.setPixel(77,26); |
takis94 | 0:ec64ecaac130 | 253 | lcd.setPixel(75,25); |
takis94 | 0:ec64ecaac130 | 254 | lcd.setPixel(76,25); |
takis94 | 0:ec64ecaac130 | 255 | lcd.setPixel(77,25); |
takis94 | 0:ec64ecaac130 | 256 | lcd.setPixel(75,24); |
takis94 | 0:ec64ecaac130 | 257 | lcd.setPixel(76,24); |
takis94 | 0:ec64ecaac130 | 258 | lcd.setPixel(77,24); |
takis94 | 0:ec64ecaac130 | 259 | lcd.setPixel(75,23); |
takis94 | 0:ec64ecaac130 | 260 | lcd.setPixel(76,23); |
takis94 | 0:ec64ecaac130 | 261 | lcd.setPixel(77,23); |
takis94 | 0:ec64ecaac130 | 262 | lcd.setPixel(75,22); |
takis94 | 0:ec64ecaac130 | 263 | lcd.setPixel(76,22); |
takis94 | 0:ec64ecaac130 | 264 | lcd.setPixel(77,22); |
takis94 | 0:ec64ecaac130 | 265 | lcd.setPixel(75,21); |
takis94 | 0:ec64ecaac130 | 266 | lcd.setPixel(76,21); |
takis94 | 0:ec64ecaac130 | 267 | lcd.setPixel(77,21); |
takis94 | 0:ec64ecaac130 | 268 | } |
takis94 | 1:d320c79324fe | 269 | else if (temperature >35.0 && temperature <= 40.0) { // for temperatures between 35 and 40 |
takis94 | 0:ec64ecaac130 | 270 | |
takis94 | 1:d320c79324fe | 271 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 272 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 273 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 274 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 275 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 276 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 277 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 278 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 279 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 280 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 281 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 282 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 283 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 284 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 285 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 286 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 287 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 288 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 289 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 290 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 291 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 292 | lcd.setPixel(75,28); |
takis94 | 0:ec64ecaac130 | 293 | lcd.setPixel(76,28); |
takis94 | 0:ec64ecaac130 | 294 | lcd.setPixel(77,28); |
takis94 | 0:ec64ecaac130 | 295 | lcd.setPixel(75,27); |
takis94 | 0:ec64ecaac130 | 296 | lcd.setPixel(76,27); |
takis94 | 0:ec64ecaac130 | 297 | lcd.setPixel(77,27); |
takis94 | 0:ec64ecaac130 | 298 | lcd.setPixel(75,26); |
takis94 | 0:ec64ecaac130 | 299 | lcd.setPixel(76,26); |
takis94 | 0:ec64ecaac130 | 300 | lcd.setPixel(77,26); |
takis94 | 0:ec64ecaac130 | 301 | lcd.setPixel(75,25); |
takis94 | 0:ec64ecaac130 | 302 | lcd.setPixel(76,25); |
takis94 | 0:ec64ecaac130 | 303 | lcd.setPixel(77,25); |
takis94 | 0:ec64ecaac130 | 304 | lcd.setPixel(75,24); |
takis94 | 0:ec64ecaac130 | 305 | lcd.setPixel(76,24); |
takis94 | 0:ec64ecaac130 | 306 | lcd.setPixel(77,24); |
takis94 | 0:ec64ecaac130 | 307 | lcd.setPixel(75,23); |
takis94 | 0:ec64ecaac130 | 308 | lcd.setPixel(76,23); |
takis94 | 0:ec64ecaac130 | 309 | lcd.setPixel(77,23); |
takis94 | 0:ec64ecaac130 | 310 | lcd.setPixel(75,22); |
takis94 | 0:ec64ecaac130 | 311 | lcd.setPixel(76,22); |
takis94 | 0:ec64ecaac130 | 312 | lcd.setPixel(77,22); |
takis94 | 0:ec64ecaac130 | 313 | lcd.setPixel(75,21); |
takis94 | 0:ec64ecaac130 | 314 | lcd.setPixel(76,21); |
takis94 | 0:ec64ecaac130 | 315 | lcd.setPixel(77,21); |
takis94 | 0:ec64ecaac130 | 316 | lcd.setPixel(75,20); |
takis94 | 0:ec64ecaac130 | 317 | lcd.setPixel(76,20); |
takis94 | 0:ec64ecaac130 | 318 | lcd.setPixel(77,20); |
takis94 | 0:ec64ecaac130 | 319 | lcd.setPixel(75,19); |
takis94 | 0:ec64ecaac130 | 320 | lcd.setPixel(76,19); |
takis94 | 0:ec64ecaac130 | 321 | lcd.setPixel(77,19); |
takis94 | 0:ec64ecaac130 | 322 | } |
takis94 | 1:d320c79324fe | 323 | else if (temperature >40.0 && temperature <= 50.0) { // for temperatures between 40 and 50 |
takis94 | 0:ec64ecaac130 | 324 | |
takis94 | 1:d320c79324fe | 325 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 326 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 327 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 328 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 329 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 330 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 331 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 332 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 333 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 334 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 335 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 336 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 337 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 338 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 339 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 340 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 341 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 342 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 343 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 344 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 345 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 346 | lcd.setPixel(75,28); |
takis94 | 0:ec64ecaac130 | 347 | lcd.setPixel(76,28); |
takis94 | 0:ec64ecaac130 | 348 | lcd.setPixel(77,28); |
takis94 | 0:ec64ecaac130 | 349 | lcd.setPixel(75,27); |
takis94 | 0:ec64ecaac130 | 350 | lcd.setPixel(76,27); |
takis94 | 0:ec64ecaac130 | 351 | lcd.setPixel(77,27); |
takis94 | 0:ec64ecaac130 | 352 | lcd.setPixel(75,26); |
takis94 | 0:ec64ecaac130 | 353 | lcd.setPixel(76,26); |
takis94 | 0:ec64ecaac130 | 354 | lcd.setPixel(77,26); |
takis94 | 0:ec64ecaac130 | 355 | lcd.setPixel(75,25); |
takis94 | 0:ec64ecaac130 | 356 | lcd.setPixel(76,25); |
takis94 | 0:ec64ecaac130 | 357 | lcd.setPixel(77,25); |
takis94 | 0:ec64ecaac130 | 358 | lcd.setPixel(75,24); |
takis94 | 0:ec64ecaac130 | 359 | lcd.setPixel(76,24); |
takis94 | 0:ec64ecaac130 | 360 | lcd.setPixel(77,24); |
takis94 | 0:ec64ecaac130 | 361 | lcd.setPixel(75,23); |
takis94 | 0:ec64ecaac130 | 362 | lcd.setPixel(76,23); |
takis94 | 0:ec64ecaac130 | 363 | lcd.setPixel(77,23); |
takis94 | 0:ec64ecaac130 | 364 | lcd.setPixel(75,22); |
takis94 | 0:ec64ecaac130 | 365 | lcd.setPixel(76,22); |
takis94 | 0:ec64ecaac130 | 366 | lcd.setPixel(77,22); |
takis94 | 0:ec64ecaac130 | 367 | lcd.setPixel(75,21); |
takis94 | 0:ec64ecaac130 | 368 | lcd.setPixel(76,21); |
takis94 | 0:ec64ecaac130 | 369 | lcd.setPixel(77,21); |
takis94 | 0:ec64ecaac130 | 370 | lcd.setPixel(75,20); |
takis94 | 0:ec64ecaac130 | 371 | lcd.setPixel(76,20); |
takis94 | 0:ec64ecaac130 | 372 | lcd.setPixel(77,20); |
takis94 | 0:ec64ecaac130 | 373 | lcd.setPixel(75,19); |
takis94 | 0:ec64ecaac130 | 374 | lcd.setPixel(76,19); |
takis94 | 0:ec64ecaac130 | 375 | lcd.setPixel(77,19); |
takis94 | 0:ec64ecaac130 | 376 | lcd.setPixel(75,18); |
takis94 | 0:ec64ecaac130 | 377 | lcd.setPixel(76,18); |
takis94 | 0:ec64ecaac130 | 378 | lcd.setPixel(77,18); |
takis94 | 0:ec64ecaac130 | 379 | lcd.setPixel(75,17); |
takis94 | 0:ec64ecaac130 | 380 | lcd.setPixel(76,17); |
takis94 | 0:ec64ecaac130 | 381 | lcd.setPixel(77,17); |
takis94 | 0:ec64ecaac130 | 382 | } |
takis94 | 1:d320c79324fe | 383 | else if (temperature >50.0 && temperature <= 65.0) { // for temperatures between 50 and 65 |
takis94 | 1:d320c79324fe | 384 | |
takis94 | 1:d320c79324fe | 385 | lcd.drawCircle(WIDTH/1.1,HEIGHT/1.2,5,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 386 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 387 | lcd.drawRect(74,5,4,30,0); // transparent, just outline |
takis94 | 0:ec64ecaac130 | 388 | lcd.setPixel(75,34); |
takis94 | 0:ec64ecaac130 | 389 | lcd.setPixel(76,34); |
takis94 | 0:ec64ecaac130 | 390 | lcd.setPixel(77,34); |
takis94 | 0:ec64ecaac130 | 391 | lcd.setPixel(75,33); |
takis94 | 0:ec64ecaac130 | 392 | lcd.setPixel(76,33); |
takis94 | 0:ec64ecaac130 | 393 | lcd.setPixel(77,33); |
takis94 | 0:ec64ecaac130 | 394 | lcd.setPixel(75,32); |
takis94 | 0:ec64ecaac130 | 395 | lcd.setPixel(76,32); |
takis94 | 0:ec64ecaac130 | 396 | lcd.setPixel(77,32); |
takis94 | 0:ec64ecaac130 | 397 | lcd.setPixel(75,31); |
takis94 | 0:ec64ecaac130 | 398 | lcd.setPixel(76,31); |
takis94 | 0:ec64ecaac130 | 399 | lcd.setPixel(77,31); |
takis94 | 0:ec64ecaac130 | 400 | lcd.setPixel(75,30); |
takis94 | 0:ec64ecaac130 | 401 | lcd.setPixel(76,30); |
takis94 | 0:ec64ecaac130 | 402 | lcd.setPixel(77,30); |
takis94 | 0:ec64ecaac130 | 403 | lcd.setPixel(75,29); |
takis94 | 0:ec64ecaac130 | 404 | lcd.setPixel(76,29); |
takis94 | 0:ec64ecaac130 | 405 | lcd.setPixel(77,29); |
takis94 | 0:ec64ecaac130 | 406 | lcd.setPixel(75,28); |
takis94 | 0:ec64ecaac130 | 407 | lcd.setPixel(76,28); |
takis94 | 0:ec64ecaac130 | 408 | lcd.setPixel(77,28); |
takis94 | 0:ec64ecaac130 | 409 | lcd.setPixel(75,27); |
takis94 | 0:ec64ecaac130 | 410 | lcd.setPixel(76,27); |
takis94 | 0:ec64ecaac130 | 411 | lcd.setPixel(77,27); |
takis94 | 0:ec64ecaac130 | 412 | lcd.setPixel(75,26); |
takis94 | 0:ec64ecaac130 | 413 | lcd.setPixel(76,26); |
takis94 | 0:ec64ecaac130 | 414 | lcd.setPixel(77,26); |
takis94 | 0:ec64ecaac130 | 415 | lcd.setPixel(75,25); |
takis94 | 0:ec64ecaac130 | 416 | lcd.setPixel(76,25); |
takis94 | 0:ec64ecaac130 | 417 | lcd.setPixel(77,25); |
takis94 | 0:ec64ecaac130 | 418 | lcd.setPixel(75,24); |
takis94 | 0:ec64ecaac130 | 419 | lcd.setPixel(76,24); |
takis94 | 0:ec64ecaac130 | 420 | lcd.setPixel(77,24); |
takis94 | 0:ec64ecaac130 | 421 | lcd.setPixel(75,23); |
takis94 | 0:ec64ecaac130 | 422 | lcd.setPixel(76,23); |
takis94 | 0:ec64ecaac130 | 423 | lcd.setPixel(77,23); |
takis94 | 0:ec64ecaac130 | 424 | lcd.setPixel(75,22); |
takis94 | 0:ec64ecaac130 | 425 | lcd.setPixel(76,22); |
takis94 | 0:ec64ecaac130 | 426 | lcd.setPixel(77,22); |
takis94 | 0:ec64ecaac130 | 427 | lcd.setPixel(75,21); |
takis94 | 0:ec64ecaac130 | 428 | lcd.setPixel(76,21); |
takis94 | 0:ec64ecaac130 | 429 | lcd.setPixel(77,21); |
takis94 | 0:ec64ecaac130 | 430 | lcd.setPixel(75,20); |
takis94 | 0:ec64ecaac130 | 431 | lcd.setPixel(76,20); |
takis94 | 0:ec64ecaac130 | 432 | lcd.setPixel(77,20); |
takis94 | 0:ec64ecaac130 | 433 | lcd.setPixel(75,19); |
takis94 | 0:ec64ecaac130 | 434 | lcd.setPixel(76,19); |
takis94 | 0:ec64ecaac130 | 435 | lcd.setPixel(77,19); |
takis94 | 0:ec64ecaac130 | 436 | lcd.setPixel(75,18); |
takis94 | 0:ec64ecaac130 | 437 | lcd.setPixel(76,18); |
takis94 | 0:ec64ecaac130 | 438 | lcd.setPixel(77,18); |
takis94 | 0:ec64ecaac130 | 439 | lcd.setPixel(75,17); |
takis94 | 0:ec64ecaac130 | 440 | lcd.setPixel(76,17); |
takis94 | 0:ec64ecaac130 | 441 | lcd.setPixel(77,17); |
takis94 | 0:ec64ecaac130 | 442 | lcd.setPixel(75,16); |
takis94 | 0:ec64ecaac130 | 443 | lcd.setPixel(76,16); |
takis94 | 0:ec64ecaac130 | 444 | lcd.setPixel(77,16); |
takis94 | 0:ec64ecaac130 | 445 | lcd.setPixel(75,15); |
takis94 | 0:ec64ecaac130 | 446 | lcd.setPixel(76,15); |
takis94 | 0:ec64ecaac130 | 447 | lcd.setPixel(77,15); |
takis94 | 0:ec64ecaac130 | 448 | } |
takis94 | 0:ec64ecaac130 | 449 | } |
takis94 | 0:ec64ecaac130 | 450 | |
takis94 | 0:ec64ecaac130 | 451 | void print() |
takis94 | 0:ec64ecaac130 | 452 | { |
takis94 | 1:d320c79324fe | 453 | if(graphTempFlag == 0 && graphPresFlag == 0 && unitsFlag == 0) { //no button is pressed or button 4 is pressed |
takis94 | 0:ec64ecaac130 | 454 | |
takis94 | 1:d320c79324fe | 455 | char buffer2[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14) |
takis94 | 1:d320c79324fe | 456 | // so can display a string of a maximum 14 characters in length |
takis94 | 1:d320c79324fe | 457 | // or create formatted strings - ensure they aren't more than 14 characters long |
takis94 | 1:d320c79324fe | 458 | float length = sprintf(buffer2,"T= %.2f C",temperature); // print formatted data to buffer |
takis94 | 1:d320c79324fe | 459 | // it is important the format specifier ensures the length will fit in the buffer |
takis94 | 1:d320c79324fe | 460 | if (length <= 14) // if string will fit on display |
takis94 | 1:d320c79324fe | 461 | lcd.printString(buffer2,0,1); // display on screen |
takis94 | 0:ec64ecaac130 | 462 | |
takis94 | 1:d320c79324fe | 463 | length = sprintf(buffer2,"P= %.2fmb",pressure); //print formatted data to buffer |
takis94 | 1:d320c79324fe | 464 | if (length <= 14){ // if string will fit on display |
takis94 | 1:d320c79324fe | 465 | lcd.printString(buffer2,0,2); // display on screen |
takis94 | 1:d320c79324fe | 466 | lcd.printString(bufferT,0,4); // display on screen |
takis94 | 1:d320c79324fe | 467 | lcd.printString(bufferD,0,5); // display on screen |
takis94 | 0:ec64ecaac130 | 468 | } |
takis94 | 0:ec64ecaac130 | 469 | lcd.drawLine(0,30,48,30,2); |
takis94 | 0:ec64ecaac130 | 470 | lcd.drawLine(48,30,48,48,2); |
takis94 | 0:ec64ecaac130 | 471 | |
takis94 | 1:d320c79324fe | 472 | update(); //update thermometer |
takis94 | 1:d320c79324fe | 473 | |
takis94 | 1:d320c79324fe | 474 | //set 0 degrees indicator |
takis94 | 0:ec64ecaac130 | 475 | lcd.setPixel(72,33); |
takis94 | 0:ec64ecaac130 | 476 | lcd.setPixel(71,33); |
takis94 | 0:ec64ecaac130 | 477 | lcd.setPixel(70,33); |
takis94 | 0:ec64ecaac130 | 478 | lcd.setPixel(69,33); |
takis94 | 0:ec64ecaac130 | 479 | lcd.printChar('0',58,34); |
takis94 | 0:ec64ecaac130 | 480 | |
takis94 | 1:d320c79324fe | 481 | //set 65 degrees indicator |
takis94 | 0:ec64ecaac130 | 482 | lcd.setPixel(72,5); |
takis94 | 0:ec64ecaac130 | 483 | lcd.setPixel(71,5); |
takis94 | 0:ec64ecaac130 | 484 | lcd.setPixel(70,5); |
takis94 | 0:ec64ecaac130 | 485 | lcd.setPixel(69,5); |
takis94 | 0:ec64ecaac130 | 486 | lcd.printChar('5',62,6); |
takis94 | 0:ec64ecaac130 | 487 | lcd.printChar('6',56,6); |
takis94 | 0:ec64ecaac130 | 488 | |
takis94 | 0:ec64ecaac130 | 489 | |
takis94 | 1:d320c79324fe | 490 | if(temperature >15 && temperature <= 35){ //good weather |
takis94 | 1:d320c79324fe | 491 | //draw a sun on screen |
takis94 | 1:d320c79324fe | 492 | lcd.drawCircle(WIDTH/1.5,HEIGHT/1.2,2,1); // x,y,radius,black fill |
takis94 | 0:ec64ecaac130 | 493 | lcd.drawLine(53,40,59,40,1); |
takis94 | 0:ec64ecaac130 | 494 | lcd.drawLine(56,37,56,43,1); |
takis94 | 0:ec64ecaac130 | 495 | lcd.drawLine(53,37,59,43,1); |
takis94 | 0:ec64ecaac130 | 496 | lcd.drawLine(59,37,53,43,1); |
takis94 | 0:ec64ecaac130 | 497 | } |
takis94 | 1:d320c79324fe | 498 | else if (temperature <= 15) { //cold weather |
takis94 | 1:d320c79324fe | 499 | //draw a rainy cloud on screen |
takis94 | 0:ec64ecaac130 | 500 | lcd.setPixel(57,37); |
takis94 | 0:ec64ecaac130 | 501 | lcd.setPixel(56,37); |
takis94 | 0:ec64ecaac130 | 502 | lcd.setPixel(56,36); |
takis94 | 0:ec64ecaac130 | 503 | lcd.setPixel(55,37); |
takis94 | 0:ec64ecaac130 | 504 | lcd.setPixel(58,42); |
takis94 | 0:ec64ecaac130 | 505 | lcd.setPixel(58,38); |
takis94 | 0:ec64ecaac130 | 506 | lcd.setPixel(58,37); |
takis94 | 0:ec64ecaac130 | 507 | lcd.setPixel(54,44); |
takis94 | 0:ec64ecaac130 | 508 | lcd.setPixel(59,44); |
takis94 | 0:ec64ecaac130 | 509 | lcd.setPixel(60,47); |
takis94 | 0:ec64ecaac130 | 510 | lcd.setPixel(56,45); |
takis94 | 0:ec64ecaac130 | 511 | lcd.setPixel(61,45); |
takis94 | 1:d320c79324fe | 512 | lcd.drawCircle(WIDTH/1.5,HEIGHT/1.2,2,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 513 | lcd.drawCircle(WIDTH/1.4,HEIGHT/1.2,2,1); // x,y,radius,black fill |
takis94 | 0:ec64ecaac130 | 514 | } |
takis94 | 1:d320c79324fe | 515 | else { //hot weather |
takis94 | 1:d320c79324fe | 516 | //draw a bigger sun on screen |
takis94 | 1:d320c79324fe | 517 | lcd.drawCircle(WIDTH/1.5,HEIGHT/1.2,2,1); // x,y,radius,black fill |
takis94 | 0:ec64ecaac130 | 518 | lcd.drawLine(52,40,60,40,1); |
takis94 | 0:ec64ecaac130 | 519 | lcd.drawLine(56,36,56,44,1); |
takis94 | 0:ec64ecaac130 | 520 | lcd.drawLine(53,37,59,43,1); |
takis94 | 0:ec64ecaac130 | 521 | lcd.drawLine(59,37,53,43,1); |
takis94 | 0:ec64ecaac130 | 522 | } |
takis94 | 0:ec64ecaac130 | 523 | |
takis94 | 0:ec64ecaac130 | 524 | |
takis94 | 1:d320c79324fe | 525 | } else if(graphTempFlag == 0 && graphPresFlag == 0 && unitsFlag) { //button3 pressed |
takis94 | 0:ec64ecaac130 | 526 | |
takis94 | 1:d320c79324fe | 527 | char buffer2[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14) |
takis94 | 1:d320c79324fe | 528 | // so can display a string of a maximum 14 characters in length |
takis94 | 1:d320c79324fe | 529 | // or create formatted strings - ensure they aren't more than 14 characters long |
takis94 | 1:d320c79324fe | 530 | float length = sprintf(buffer2,"T= %.2f K",temperature+273.15); // print formatted data to buffer |
takis94 | 1:d320c79324fe | 531 | // it is important the format specifier ensures the length will fit in the buffer |
takis94 | 1:d320c79324fe | 532 | if (length <= 14){ // if string will fit on display |
takis94 | 1:d320c79324fe | 533 | lcd.printString(buffer2,0,1); // display on screen |
takis94 | 0:ec64ecaac130 | 534 | } |
takis94 | 1:d320c79324fe | 535 | length = sprintf(buffer2,"P= %.2f b",pressure/1000); // print formatted data to buffer |
takis94 | 1:d320c79324fe | 536 | if (length <= 14){ // if string will fit on display |
takis94 | 0:ec64ecaac130 | 537 | |
takis94 | 1:d320c79324fe | 538 | lcd.printString(buffer2,0,2); // display on screen |
takis94 | 1:d320c79324fe | 539 | lcd.printString(bufferT,0,4); // display on screen |
takis94 | 1:d320c79324fe | 540 | lcd.printString(bufferD,0,5); // display on screen |
takis94 | 0:ec64ecaac130 | 541 | } |
takis94 | 0:ec64ecaac130 | 542 | lcd.drawLine(0,30,48,30,2); |
takis94 | 0:ec64ecaac130 | 543 | lcd.drawLine(48,30,48,48,2); |
takis94 | 1:d320c79324fe | 544 | |
takis94 | 1:d320c79324fe | 545 | update(); //update thermometer |
takis94 | 0:ec64ecaac130 | 546 | |
takis94 | 1:d320c79324fe | 547 | //set 273.15K indicator |
takis94 | 0:ec64ecaac130 | 548 | lcd.setPixel(72,33); |
takis94 | 0:ec64ecaac130 | 549 | lcd.setPixel(71,33); |
takis94 | 0:ec64ecaac130 | 550 | lcd.setPixel(70,33); |
takis94 | 0:ec64ecaac130 | 551 | lcd.setPixel(69,33); |
takis94 | 0:ec64ecaac130 | 552 | lcd.printString("273",46,34); |
takis94 | 0:ec64ecaac130 | 553 | |
takis94 | 1:d320c79324fe | 554 | //set 338.15K indicator |
takis94 | 0:ec64ecaac130 | 555 | lcd.setPixel(72,5); |
takis94 | 0:ec64ecaac130 | 556 | lcd.setPixel(71,5); |
takis94 | 0:ec64ecaac130 | 557 | lcd.setPixel(70,5); |
takis94 | 0:ec64ecaac130 | 558 | lcd.setPixel(69,5); |
takis94 | 0:ec64ecaac130 | 559 | lcd.printString("338",50,6); |
takis94 | 0:ec64ecaac130 | 560 | |
takis94 | 1:d320c79324fe | 561 | } else if(graphTempFlag && graphPresFlag == 0 && unitsFlag == 0) { //if button is pressed |
takis94 | 0:ec64ecaac130 | 562 | |
takis94 | 1:d320c79324fe | 563 | char buffer3[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14) |
takis94 | 1:d320c79324fe | 564 | // so can display a string of a maximum 14 characters in length |
takis94 | 1:d320c79324fe | 565 | // or create formatted strings - ensure they aren't more than 14 characters long |
takis94 | 1:d320c79324fe | 566 | float tave; //store average temperature |
takis94 | 1:d320c79324fe | 567 | float t_sum=0; //store sum of temperatures |
takis94 | 1:d320c79324fe | 568 | float t_count=0; //store position in the array |
takis94 | 0:ec64ecaac130 | 569 | |
takis94 | 0:ec64ecaac130 | 570 | for (int ind = 0; ind<84; ind++) { |
takis94 | 0:ec64ecaac130 | 571 | if (array[ind] > 0) { |
takis94 | 0:ec64ecaac130 | 572 | t_sum = t_sum + array[ind]*65; |
takis94 | 0:ec64ecaac130 | 573 | t_count++; |
takis94 | 0:ec64ecaac130 | 574 | } |
takis94 | 0:ec64ecaac130 | 575 | } |
takis94 | 0:ec64ecaac130 | 576 | tave = t_sum/t_count; |
takis94 | 1:d320c79324fe | 577 | float length3 = sprintf(buffer3,"Tave = %.2f C",tave); // print formatted data to buffer |
takis94 | 1:d320c79324fe | 578 | // it is important the format specifier ensures the length will fit in the buffer |
takis94 | 1:d320c79324fe | 579 | if (length3 <= 14){ // if string will fit on display |
takis94 | 1:d320c79324fe | 580 | lcd.printString(buffer3,0,1); // display on screen |
takis94 | 0:ec64ecaac130 | 581 | } |
takis94 | 0:ec64ecaac130 | 582 | if(temperature >15 && temperature <= 35){ |
takis94 | 1:d320c79324fe | 583 | lcd.printString(" Good Weather",0,2); //print string |
takis94 | 0:ec64ecaac130 | 584 | } |
takis94 | 0:ec64ecaac130 | 585 | else if (temperature <= 15) |
takis94 | 1:d320c79324fe | 586 | lcd.printString(" Cold Weather",0,2); //print string |
takis94 | 0:ec64ecaac130 | 587 | else { |
takis94 | 1:d320c79324fe | 588 | lcd.printString(" Hot Weather",0,2); //print string |
takis94 | 0:ec64ecaac130 | 589 | } |
takis94 | 0:ec64ecaac130 | 590 | |
takis94 | 1:d320c79324fe | 591 | } else if(graphTempFlag == 0 && graphPresFlag && unitsFlag == 0) { //button2 pressed |
takis94 | 0:ec64ecaac130 | 592 | |
takis94 | 1:d320c79324fe | 593 | char buffer4[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14) |
takis94 | 1:d320c79324fe | 594 | // so can display a string of a maximum 14 characters in length |
takis94 | 1:d320c79324fe | 595 | // or create formatted strings - ensure they aren't more than 14 characters long |
takis94 | 1:d320c79324fe | 596 | float pave; //store average pressure |
takis94 | 1:d320c79324fe | 597 | float p_sum=0; //store sum of presuures |
takis94 | 1:d320c79324fe | 598 | float p_count=0; //store position in the array2 |
takis94 | 0:ec64ecaac130 | 599 | |
takis94 | 0:ec64ecaac130 | 600 | for (int ind = 0; ind<84; ind++) { |
takis94 | 0:ec64ecaac130 | 601 | if (array2[ind] > 0) { |
takis94 | 0:ec64ecaac130 | 602 | p_sum = p_sum + array2[ind]*1100; |
takis94 | 0:ec64ecaac130 | 603 | p_count++; |
takis94 | 0:ec64ecaac130 | 604 | } |
takis94 | 0:ec64ecaac130 | 605 | } |
takis94 | 0:ec64ecaac130 | 606 | pave = p_sum/p_count; |
takis94 | 1:d320c79324fe | 607 | float length4 = sprintf(buffer4,"Pave=%.2fmb",pave); // print formatted data to buffer |
takis94 | 1:d320c79324fe | 608 | // it is important the format specifier ensures the length will fit in the buffer |
takis94 | 1:d320c79324fe | 609 | if (length4 <= 14) { // if string will fit on display |
takis94 | 1:d320c79324fe | 610 | lcd.printString(buffer4,0,1); // display on screen |
takis94 | 0:ec64ecaac130 | 611 | } |
takis94 | 0:ec64ecaac130 | 612 | if(pressure >999){ |
takis94 | 1:d320c79324fe | 613 | lcd.printString("Clear Weather",0,2); //print string |
takis94 | 0:ec64ecaac130 | 614 | } |
takis94 | 0:ec64ecaac130 | 615 | else if(pressure <= 999 && pressure >700){ |
takis94 | 1:d320c79324fe | 616 | lcd.printString(" Windy/Cloudy",0,2); //print string |
takis94 | 0:ec64ecaac130 | 617 | } |
takis94 | 0:ec64ecaac130 | 618 | else |
takis94 | 1:d320c79324fe | 619 | lcd.printString("Rainy Weather",0,2); //print string |
takis94 | 0:ec64ecaac130 | 620 | } |
takis94 | 0:ec64ecaac130 | 621 | } |
takis94 | 0:ec64ecaac130 | 622 | |
takis94 | 0:ec64ecaac130 | 623 | //ISR |
takis94 | 0:ec64ecaac130 | 624 | void timerExpiredReading() |
takis94 | 0:ec64ecaac130 | 625 | { |
takis94 | 1:d320c79324fe | 626 | readingFlag = 1; //set flag to 1 |
takis94 | 0:ec64ecaac130 | 627 | } |
takis94 | 0:ec64ecaac130 | 628 | void timerExpiredTime() |
takis94 | 0:ec64ecaac130 | 629 | { |
takis94 | 1:d320c79324fe | 630 | timerFlag = 1; //set flag to 1 |
takis94 | 0:ec64ecaac130 | 631 | } |
takis94 | 0:ec64ecaac130 | 632 | void timeExpiredFiles() |
takis94 | 0:ec64ecaac130 | 633 | { |
takis94 | 1:d320c79324fe | 634 | timerFilesFlag = 1; //set flag to 1 |
takis94 | 0:ec64ecaac130 | 635 | } |
takis94 | 0:ec64ecaac130 | 636 | void buttonTempPressed() |
takis94 | 0:ec64ecaac130 | 637 | { |
takis94 | 1:d320c79324fe | 638 | graphTempFlag = !graphTempFlag; //toggle flag |
takis94 | 0:ec64ecaac130 | 639 | } |
takis94 | 0:ec64ecaac130 | 640 | void buttonPresPressed() |
takis94 | 0:ec64ecaac130 | 641 | { |
takis94 | 1:d320c79324fe | 642 | graphPresFlag = !graphPresFlag; //toggle flag |
takis94 | 0:ec64ecaac130 | 643 | } |
takis94 | 0:ec64ecaac130 | 644 | void buttonUnitsPressed() |
takis94 | 0:ec64ecaac130 | 645 | { |
takis94 | 1:d320c79324fe | 646 | unitsFlag = !unitsFlag; //toggle flag |
takis94 | 0:ec64ecaac130 | 647 | } |
takis94 | 0:ec64ecaac130 | 648 | void timerExpiredClear() |
takis94 | 0:ec64ecaac130 | 649 | { |
takis94 | 1:d320c79324fe | 650 | clearFlag = 1; //set flag to 1 |
takis94 | 0:ec64ecaac130 | 651 | } |
takis94 | 0:ec64ecaac130 | 652 | int main() |
takis94 | 0:ec64ecaac130 | 653 | { |
takis94 | 1:d320c79324fe | 654 | pc.baud(9600); //set baud rate |
takis94 | 1:d320c79324fe | 655 | // first need to initialise display |
takis94 | 0:ec64ecaac130 | 656 | lcd.init(); |
takis94 | 1:d320c79324fe | 657 | // initiliase barometer |
takis94 | 0:ec64ecaac130 | 658 | bmp180.init(); |
takis94 | 1:d320c79324fe | 659 | serial.attach(&serialISR); // attach serial ISR |
takis94 | 1:d320c79324fe | 660 | Measurement measurement; // measurement structure declared in BMP180 class |
takis94 | 1:d320c79324fe | 661 | PHY_PowerDown(); //power down the Ethernet |
takis94 | 1:d320c79324fe | 662 | timerClearScreen.attach(&timerExpiredClear,0.2); //call ISR every 0.2 sec |
takis94 | 1:d320c79324fe | 663 | timerReading.attach(&timerExpiredReading,10.0); //call ISR every 10 sec |
takis94 | 1:d320c79324fe | 664 | timerFiles.attach(&timeExpiredFiles,10.0); //write data to file every 10 sec |
takis94 | 1:d320c79324fe | 665 | //set_time(1431012720); // initialise time to 1st January 1970 |
takis94 | 1:d320c79324fe | 666 | timer.attach(&timerExpiredTime,1.0); //attach timer |
takis94 | 0:ec64ecaac130 | 667 | |
takis94 | 1:d320c79324fe | 668 | green = 0; //set LED initially to 0 |
takis94 | 1:d320c79324fe | 669 | red = 0; //set LED initially to 0 |
takis94 | 1:d320c79324fe | 670 | lcd.setBrightness(ain/3.2); //set brightness according to the pot voltage |
takis94 | 1:d320c79324fe | 671 | |
takis94 | 1:d320c79324fe | 672 | button.rise(&buttonTempPressed); //change the button state |
takis94 | 1:d320c79324fe | 673 | button2.rise(&buttonPresPressed); //change the button state |
takis94 | 1:d320c79324fe | 674 | button3.rise(&buttonUnitsPressed); //change the button state |
takis94 | 0:ec64ecaac130 | 675 | |
takis94 | 1:d320c79324fe | 676 | lcd.clear(); //clear display |
takis94 | 1:d320c79324fe | 677 | lcd.refresh(); //refresh display |
takis94 | 1:d320c79324fe | 678 | lcd.printString("WeatherStation",1,1); //print string |
takis94 | 1:d320c79324fe | 679 | lcd.printString(" by",1,2); //print string |
takis94 | 1:d320c79324fe | 680 | lcd.printString(" Panagiotis",1,3); //print string |
takis94 | 1:d320c79324fe | 681 | lcd.printString(" Rodosthenous",1,4); //print string |
takis94 | 1:d320c79324fe | 682 | lcd.printString("* * * * * * *",1,0); //print string |
takis94 | 1:d320c79324fe | 683 | lcd.printString("* * * * * * *",1,5); //print string |
takis94 | 1:d320c79324fe | 684 | //Display to lcd the above details |
takis94 | 1:d320c79324fe | 685 | wait(3); //3 sec delay |
takis94 | 1:d320c79324fe | 686 | lcd.clear(); //clear display |
takis94 | 1:d320c79324fe | 687 | lcd.refresh(); //refresh display |
takis94 | 1:d320c79324fe | 688 | |
takis94 | 1:d320c79324fe | 689 | lcd.printString(" University",1,1); //print string |
takis94 | 1:d320c79324fe | 690 | lcd.printString(" of",1,2); //print string |
takis94 | 1:d320c79324fe | 691 | lcd.printString(" Leeds",1,3); //print string |
takis94 | 1:d320c79324fe | 692 | lcd.drawCircle(WIDTH/2,HEIGHT/1.2,4,1); // x,y,radius,black fill |
takis94 | 1:d320c79324fe | 693 | //draw sun |
takis94 | 1:d320c79324fe | 694 | lcd.setPixel(46,36); |
takis94 | 1:d320c79324fe | 695 | lcd.setPixel(47,35); |
takis94 | 1:d320c79324fe | 696 | lcd.setPixel(37,45); |
takis94 | 1:d320c79324fe | 697 | lcd.setPixel(38,44); |
takis94 | 1:d320c79324fe | 698 | lcd.setPixel(46,44); |
takis94 | 1:d320c79324fe | 699 | lcd.setPixel(47,45); |
takis94 | 1:d320c79324fe | 700 | lcd.setPixel(37,35); |
takis94 | 1:d320c79324fe | 701 | lcd.setPixel(38,36); |
takis94 | 1:d320c79324fe | 702 | //origin x,y,width,height,type |
takis94 | 1:d320c79324fe | 703 | lcd.drawRect(1,1,81,45,0); // transparent, just outline |
takis94 | 1:d320c79324fe | 704 | lcd.drawLine(35,40,49,40,1); |
takis94 | 1:d320c79324fe | 705 | lcd.drawLine(42,33,42,47,1); |
takis94 | 1:d320c79324fe | 706 | lcd.inverseMode(); //inverse mode ON |
takis94 | 1:d320c79324fe | 707 | wait(3); //3 sec delay |
takis94 | 1:d320c79324fe | 708 | lcd.clear(); //clear display |
takis94 | 1:d320c79324fe | 709 | lcd.refresh(); //refresh display |
takis94 | 1:d320c79324fe | 710 | lcd.normalMode(); //normal mode ON |
takis94 | 1:d320c79324fe | 711 | |
takis94 | 1:d320c79324fe | 712 | buzzer.beep(1000,0.5); //beep the buzzer |
takis94 | 0:ec64ecaac130 | 713 | |
takis94 | 0:ec64ecaac130 | 714 | while(1) { |
takis94 | 0:ec64ecaac130 | 715 | |
takis94 | 0:ec64ecaac130 | 716 | if(clearFlag){ |
takis94 | 1:d320c79324fe | 717 | clearFlag = 0; //set flag to 0 |
takis94 | 1:d320c79324fe | 718 | lcd.clear(); //clear display |
takis94 | 1:d320c79324fe | 719 | lcd.refresh(); //refresh display |
takis94 | 0:ec64ecaac130 | 720 | } |
takis94 | 0:ec64ecaac130 | 721 | if(readingFlag) { |
takis94 | 0:ec64ecaac130 | 722 | readingFlag = 0; |
takis94 | 1:d320c79324fe | 723 | // read values (T in Celsius and P in mb) and print over serial port |
takis94 | 0:ec64ecaac130 | 724 | measurement = bmp180.readValues(); |
takis94 | 0:ec64ecaac130 | 725 | temperature = measurement.temperature; |
takis94 | 0:ec64ecaac130 | 726 | pressure = measurement.pressure; |
takis94 | 0:ec64ecaac130 | 727 | serial.printf("T = %.2f C\nP = %.2f mb\n",measurement.temperature,measurement.pressure); //print measurements to serial |
takis94 | 0:ec64ecaac130 | 728 | |
takis94 | 0:ec64ecaac130 | 729 | if(i == 84) { |
takis94 | 0:ec64ecaac130 | 730 | for(int n = 0; n <= 82; n++) { |
takis94 | 0:ec64ecaac130 | 731 | array[n] = array[n+1]; |
takis94 | 0:ec64ecaac130 | 732 | } |
takis94 | 0:ec64ecaac130 | 733 | for(int z = 0; z <= 82; z++) { |
takis94 | 0:ec64ecaac130 | 734 | array2[z] = array2[z+1]; |
takis94 | 0:ec64ecaac130 | 735 | } |
takis94 | 0:ec64ecaac130 | 736 | i = 83; |
takis94 | 0:ec64ecaac130 | 737 | } |
takis94 | 1:d320c79324fe | 738 | array[i] = temperature/65; //store temperature to array |
takis94 | 1:d320c79324fe | 739 | array2[i] = pressure/1100; //store pressure to array |
takis94 | 0:ec64ecaac130 | 740 | i++; |
takis94 | 0:ec64ecaac130 | 741 | } |
takis94 | 0:ec64ecaac130 | 742 | if(timerFlag) { |
takis94 | 1:d320c79324fe | 743 | timerFlag = 0; //set flag to 0 |
takis94 | 1:d320c79324fe | 744 | time_t seconds = time(NULL); // get current time |
takis94 | 1:d320c79324fe | 745 | // format time into a string (time and date) |
takis94 | 0:ec64ecaac130 | 746 | strftime(bufferT, 14 , "%T", localtime(&seconds)); |
takis94 | 0:ec64ecaac130 | 747 | strftime(bufferD, 14 , "%D", localtime(&seconds)); |
takis94 | 1:d320c79324fe | 748 | // print over serial |
takis94 | 1:d320c79324fe | 749 | serial.printf("Time = %s\n",bufferT); //print to pc |
takis94 | 0:ec64ecaac130 | 750 | } |
takis94 | 1:d320c79324fe | 751 | if (setTimeFlag) { // if updated time has been sent |
takis94 | 1:d320c79324fe | 752 | setTimeFlag = 0; // clear flag |
takis94 | 1:d320c79324fe | 753 | setTime(); // update time |
takis94 | 0:ec64ecaac130 | 754 | } |
takis94 | 0:ec64ecaac130 | 755 | if(graphTempFlag) { |
takis94 | 1:d320c79324fe | 756 | // values must be in range 0.0 - 1.0 |
takis94 | 0:ec64ecaac130 | 757 | lcd.plotArray(array); |
takis94 | 1:d320c79324fe | 758 | lcd.normalMode(); // normal colour mode back |
takis94 | 1:d320c79324fe | 759 | button2.rise(NULL); //disable interrupt |
takis94 | 0:ec64ecaac130 | 760 | } else |
takis94 | 1:d320c79324fe | 761 | button2.rise(&buttonPresPressed); //enable interrupt |
takis94 | 0:ec64ecaac130 | 762 | |
takis94 | 0:ec64ecaac130 | 763 | if(graphPresFlag) { |
takis94 | 1:d320c79324fe | 764 | // values must be in range 0.0 - 1.0 |
takis94 | 0:ec64ecaac130 | 765 | lcd.plotArray(array2); |
takis94 | 1:d320c79324fe | 766 | lcd.normalMode(); // normal colour mode back |
takis94 | 1:d320c79324fe | 767 | button.rise(NULL); //disable interrupt |
takis94 | 0:ec64ecaac130 | 768 | } else |
takis94 | 1:d320c79324fe | 769 | button.rise(&buttonTempPressed); //enable interrupt |
takis94 | 0:ec64ecaac130 | 770 | |
takis94 | 0:ec64ecaac130 | 771 | if(temperature >= 35) { |
takis94 | 1:d320c79324fe | 772 | buzzer.beep(1000,0.5); //beep the buzzer if the temp is higher than a predetermined value |
takis94 | 0:ec64ecaac130 | 773 | } |
takis94 | 0:ec64ecaac130 | 774 | if(temperature >= 22 && temperature < 30) { |
takis94 | 1:d320c79324fe | 775 | green = 1; //light the LED if the temp is in the specific range |
takis94 | 0:ec64ecaac130 | 776 | } else |
takis94 | 1:d320c79324fe | 777 | green = 0; //turn off the LED |
takis94 | 0:ec64ecaac130 | 778 | |
takis94 | 0:ec64ecaac130 | 779 | if(button4 == 1) { |
takis94 | 1:d320c79324fe | 780 | graphTempFlag = 0; //set flag to 0 |
takis94 | 1:d320c79324fe | 781 | graphPresFlag = 0; //set flag to 0 |
takis94 | 1:d320c79324fe | 782 | unitsFlag = 0; //set flag to 0 |
takis94 | 0:ec64ecaac130 | 783 | } |
takis94 | 1:d320c79324fe | 784 | if(switch_logging == 1) { //if switch is high |
takis94 | 0:ec64ecaac130 | 785 | |
takis94 | 0:ec64ecaac130 | 786 | if(timerFilesFlag) { |
takis94 | 1:d320c79324fe | 787 | timerFilesFlag = 0; //set flag to 0 |
takis94 | 0:ec64ecaac130 | 788 | writeDataToFile(temperature,bufferT,pressure); //call function to write data to file |
takis94 | 1:d320c79324fe | 789 | red = 1; //light the red LED |
takis94 | 0:ec64ecaac130 | 790 | } |
takis94 | 1:d320c79324fe | 791 | } else red = 0; //turn off the LED |
takis94 | 0:ec64ecaac130 | 792 | |
takis94 | 0:ec64ecaac130 | 793 | // Set Brightness |
takis94 | 1:d320c79324fe | 794 | lcd.setBrightness(ain/3.2); //set brightness according to the pot voltage |
takis94 | 0:ec64ecaac130 | 795 | |
takis94 | 1:d320c79324fe | 796 | print(); //call print function |
takis94 | 0:ec64ecaac130 | 797 | |
takis94 | 1:d320c79324fe | 798 | Sleep(); //put the processor on sleep mode |
takis94 | 0:ec64ecaac130 | 799 | } |
takis94 | 0:ec64ecaac130 | 800 | } |
takis94 | 0:ec64ecaac130 | 801 | void setTime() |
takis94 | 0:ec64ecaac130 | 802 | { |
takis94 | 1:d320c79324fe | 803 | // print time for debugging |
takis94 | 0:ec64ecaac130 | 804 | serial.printf("set_time - %s",rxString); |
takis94 | 1:d320c79324fe | 805 | // atoi() converts a string to an integer |
takis94 | 0:ec64ecaac130 | 806 | int time = atoi(rxString); |
takis94 | 1:d320c79324fe | 807 | // update the time |
takis94 | 0:ec64ecaac130 | 808 | set_time(time); |
takis94 | 0:ec64ecaac130 | 809 | } |
takis94 | 0:ec64ecaac130 | 810 | void serialISR() |
takis94 | 0:ec64ecaac130 | 811 | { |
takis94 | 1:d320c79324fe | 812 | // when a serial interrupt occurs, read rx string into buffer |
takis94 | 0:ec64ecaac130 | 813 | serial.gets(rxString,16); |
takis94 | 1:d320c79324fe | 814 | // set flag |
takis94 | 0:ec64ecaac130 | 815 | setTimeFlag = 1; |
takis94 | 0:ec64ecaac130 | 816 | } |
takis94 | 0:ec64ecaac130 | 817 | void writeDataToFile(float tempereture,char* time,float pressure) |
takis94 | 0:ec64ecaac130 | 818 | { |
takis94 | 1:d320c79324fe | 819 | leds = 15; // turn on LEDs for feedback |
takis94 | 1:d320c79324fe | 820 | FILE *fp = fopen("/local/log.csv", "a"); // open 'log.csv' for appending |
takis94 | 1:d320c79324fe | 821 | // if the file doesn't exist it is created, if it exists, data is appended to the end |
takis94 | 1:d320c79324fe | 822 | fprintf(fp,"%s , %.2f, %.2f\n",time,tempereture,pressure); // print string to file |
takis94 | 1:d320c79324fe | 823 | fclose(fp); // close file |
takis94 | 1:d320c79324fe | 824 | leds = 0; // turn off LEDs to signify file access has finished |
takis94 | 0:ec64ecaac130 | 825 | } |