Keiarash Zoughi's Multi-Sensor for weather detection.
Dependencies: BMP180 N5110 mbed
main.cpp@11:5c824de44b2c, 2015-05-12 (annotated)
- Committer:
- el13kz
- Date:
- Tue May 12 22:04:45 2015 +0000
- Revision:
- 11:5c824de44b2c
- Parent:
- 10:d62ac368381c
Final Version1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el13kz | 10:d62ac368381c | 1 | |
el13kz | 10:d62ac368381c | 2 | /** |
el13kz | 10:d62ac368381c | 3 | @file main.cpp |
el13kz | 10:d62ac368381c | 4 | |
el13kz | 10:d62ac368381c | 5 | @brief Program implementation |
el13kz | 10:d62ac368381c | 6 | @brief multi sensor device |
el13kz | 10:d62ac368381c | 7 | @author Keiarash Zoughi |
el13kz | 10:d62ac368381c | 8 | @date May 2015 |
el13kz | 10:d62ac368381c | 9 | */ |
el13kz | 10:d62ac368381c | 10 | |
el13kz | 10:d62ac368381c | 11 | |
el13kz | 0:771a5148e8e7 | 12 | #include "mbed.h" |
el13kz | 0:771a5148e8e7 | 13 | #include "N5110.h" |
el13kz | 0:771a5148e8e7 | 14 | #include "BMP180.h" |
el13kz | 10:d62ac368381c | 15 | #include "main.h" |
el13kz | 10:d62ac368381c | 16 | |
el13kz | 0:771a5148e8e7 | 17 | |
el13kz | 0:771a5148e8e7 | 18 | #define PI 3.14159265359 |
el13kz | 2:635c58eb70fb | 19 | |
el13kz | 2:635c58eb70fb | 20 | |
el13kz | 10:d62ac368381c | 21 | |
el13kz | 2:635c58eb70fb | 22 | |
el13kz | 10:d62ac368381c | 23 | void checkt()///checks the temp |
el13kz | 6:07133c44d3eb | 24 | { |
el13kz | 4:47b0473fa81b | 25 | lcd.clear(); |
el13kz | 4:47b0473fa81b | 26 | |
el13kz | 10:d62ac368381c | 27 | Measurement measurement; /// measurement structure declared in BMP180 class |
el13kz | 6:07133c44d3eb | 28 | |
el13kz | 4:47b0473fa81b | 29 | |
el13kz | 10:d62ac368381c | 30 | // /read values (T in Celsius and P in mb) and print over serial port |
el13kz | 6:07133c44d3eb | 31 | measurement = bmp180.readValues(); |
el13kz | 6:07133c44d3eb | 32 | serial.printf("T = %.2f C P = %.2f mb\n",measurement.temperature,measurement.pressure); |
el13kz | 4:47b0473fa81b | 33 | |
el13kz | 10:d62ac368381c | 34 | /// so can display a string of a maximum 14 characters in length |
el13kz | 10:d62ac368381c | 35 | // /or create formatted strings - ensure they aren't more than 14 characters long |
el13kz | 6:07133c44d3eb | 36 | float temperature = measurement.temperature; |
el13kz | 10:d62ac368381c | 37 | /// display on screen |
el13kz | 7:c39d54bdff28 | 38 | char buffer[14]; // each charact |
el13kz | 10:d62ac368381c | 39 | int length = sprintf(buffer,"T = %.2f C",temperature); /// print formatted data to buffer |
el13kz | 10:d62ac368381c | 40 | /// it is important the format specifier ensures the length will fit in the buffer |
el13kz | 10:d62ac368381c | 41 | if (length <= 14) /// if string will fit on display |
el13kz | 10:d62ac368381c | 42 | lcd.printString(buffer,0,5); /// display on screen |
el13kz | 7:c39d54bdff28 | 43 | |
el13kz | 7:c39d54bdff28 | 44 | |
el13kz | 4:47b0473fa81b | 45 | |
el13kz | 6:07133c44d3eb | 46 | if(temperature > 30.0 ) { |
el13kz | 4:47b0473fa81b | 47 | |
el13kz | 10:d62ac368381c | 48 | lcd.printString("TEMP IS HIGH!",0,1); //boundaries |
el13kz | 7:c39d54bdff28 | 49 | Redled=1.0; |
el13kz | 4:47b0473fa81b | 50 | |
el13kz | 4:47b0473fa81b | 51 | |
el13kz | 4:47b0473fa81b | 52 | |
el13kz | 6:07133c44d3eb | 53 | } else if(temperature < 3.0) { |
el13kz | 4:47b0473fa81b | 54 | |
el13kz | 10:d62ac368381c | 55 | lcd.printString("TEMP IS LOW!",0,1); |
el13kz | 6:07133c44d3eb | 56 | Redled= 1.0; |
el13kz | 6:07133c44d3eb | 57 | |
el13kz | 4:47b0473fa81b | 58 | |
el13kz | 6:07133c44d3eb | 59 | } else { |
el13kz | 10:d62ac368381c | 60 | lcd.printString("TEMP IS OK!",0,1); |
el13kz | 7:c39d54bdff28 | 61 | Redled = 0.0; |
el13kz | 6:07133c44d3eb | 62 | } |
el13kz | 7:c39d54bdff28 | 63 | |
el13kz | 7:c39d54bdff28 | 64 | |
el13kz | 6:07133c44d3eb | 65 | wait(3); |
el13kz | 7:c39d54bdff28 | 66 | lcd.clear(); |
el13kz | 7:c39d54bdff28 | 67 | |
el13kz | 7:c39d54bdff28 | 68 | |
el13kz | 4:47b0473fa81b | 69 | } |
el13kz | 4:47b0473fa81b | 70 | |
el13kz | 10:d62ac368381c | 71 | void checka()///checks the altitude |
el13kz | 10:d62ac368381c | 72 | { |
el13kz | 9:5ebf44c85f77 | 73 | lcd.clear(); |
el13kz | 10:d62ac368381c | 74 | |
el13kz | 10:d62ac368381c | 75 | Measurement measurement; /// measurement structure declared in BMP180 class |
el13kz | 9:5ebf44c85f77 | 76 | |
el13kz | 9:5ebf44c85f77 | 77 | |
el13kz | 10:d62ac368381c | 78 | /// read values (T in Celsius and P in mb) and print over serial port |
el13kz | 10:d62ac368381c | 79 | measurement = bmp180.readValues(); |
el13kz | 10:d62ac368381c | 80 | char buffer[14]; |
el13kz | 10:d62ac368381c | 81 | int temperature = measurement.temperature; |
el13kz | 10:d62ac368381c | 82 | float pressure = measurement.pressure; /// same idea with floats |
el13kz | 4:47b0473fa81b | 83 | |
el13kz | 10:d62ac368381c | 84 | float altitude = -(log(pressure/1013.25)*1.38e-23*(273+temperature))/(9.81*28.95); |
el13kz | 10:d62ac368381c | 85 | /** |
el13kz | 10:d62ac368381c | 86 | @param pressure |
el13kz | 10:d62ac368381c | 87 | @param temperature |
el13kz | 10:d62ac368381c | 88 | @returns the anser of equation and defines as altitude |
el13kz | 10:d62ac368381c | 89 | */ |
el13kz | 10:d62ac368381c | 90 | |
el13kz | 10:d62ac368381c | 91 | |
el13kz | 10:d62ac368381c | 92 | serial.printf("A = %.2f m",altitude); |
el13kz | 10:d62ac368381c | 93 | int length = sprintf(buffer,"A = %.2f m",altitude); // print formatted data to buffer |
el13kz | 10:d62ac368381c | 94 | /// it is important the format specifier ensures the length will fit in the buffer |
el13kz | 10:d62ac368381c | 95 | if (length <= 14) |
el13kz | 10:d62ac368381c | 96 | lcd.printString(buffer,0,5); |
el13kz | 4:47b0473fa81b | 97 | |
el13kz | 4:47b0473fa81b | 98 | |
el13kz | 10:d62ac368381c | 99 | if(altitude > 1800.0 ) { |
el13kz | 4:47b0473fa81b | 100 | |
el13kz | 10:d62ac368381c | 101 | lcd.printString("ALTITUDE IS HIGH!",0,1); ///boundaries |
el13kz | 10:d62ac368381c | 102 | Redled=1.0; |
el13kz | 9:5ebf44c85f77 | 103 | |
el13kz | 9:5ebf44c85f77 | 104 | } |
el13kz | 4:47b0473fa81b | 105 | |
el13kz | 4:47b0473fa81b | 106 | |
el13kz | 7:c39d54bdff28 | 107 | |
el13kz | 10:d62ac368381c | 108 | else { |
el13kz | 10:d62ac368381c | 109 | lcd.printString("ALTITUDE OK!",0,1); |
el13kz | 10:d62ac368381c | 110 | Redled = 0.0; |
el13kz | 10:d62ac368381c | 111 | } |
el13kz | 10:d62ac368381c | 112 | |
el13kz | 10:d62ac368381c | 113 | |
el13kz | 10:d62ac368381c | 114 | wait(3); |
el13kz | 10:d62ac368381c | 115 | lcd.clear(); |
el13kz | 10:d62ac368381c | 116 | |
el13kz | 10:d62ac368381c | 117 | |
el13kz | 10:d62ac368381c | 118 | } |
el13kz | 4:47b0473fa81b | 119 | |
el13kz | 10:d62ac368381c | 120 | |
el13kz | 10:d62ac368381c | 121 | void pie(){ |
el13kz | 10:d62ac368381c | 122 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 123 | |
el13kz | 10:d62ac368381c | 124 | Measurement measurement; /// measurement structure declared in BMP180 class |
el13kz | 10:d62ac368381c | 125 | t5.start(); |
el13kz | 10:d62ac368381c | 126 | while(t5.read()<10) { // if timer reaches point, tehn breaks loop, stopped at resetted at the end |
el13kz | 10:d62ac368381c | 127 | |
el13kz | 10:d62ac368381c | 128 | |
el13kz | 10:d62ac368381c | 129 | /// read values (T in Celsius and P in mb) and print over serial port |
el13kz | 0:771a5148e8e7 | 130 | measurement = bmp180.readValues(); |
el13kz | 10:d62ac368381c | 131 | serial.printf("T = %.2f C ",measurement.temperature); |
el13kz | 0:771a5148e8e7 | 132 | |
el13kz | 10:d62ac368381c | 133 | |
el13kz | 10:d62ac368381c | 134 | /// so can display a string of a maximum 14 characters in length |
el13kz | 10:d62ac368381c | 135 | /// or create formatted strings - ensure they aren't more than 14 characters long |
el13kz | 10:d62ac368381c | 136 | int z = pow(measurement.temperature,2)/30; |
el13kz | 10:d62ac368381c | 137 | /** |
el13kz | 10:d62ac368381c | 138 | @param measurement.temperature |
el13kz | 10:d62ac368381c | 139 | @returns value of equation as int z |
el13kz | 10:d62ac368381c | 140 | @brief in order to scale temperature in proportion to the screen |
el13kz | 10:d62ac368381c | 141 | */ |
el13kz | 10:d62ac368381c | 142 | |
el13kz | 10:d62ac368381c | 143 | |
el13kz | 10:d62ac368381c | 144 | lcd.drawCircle(42,24,22,0); /// x,y,radius,transparent with outline |
el13kz | 10:d62ac368381c | 145 | for (int x = 0; x < WIDTH ; x+=10) { |
el13kz | 10:d62ac368381c | 146 | /// x0,y0,x1,y1,type 0-white,1-black,2-dotted |
el13kz | 10:d62ac368381c | 147 | lcd.drawLine(42,24,62,z,1); |
el13kz | 10:d62ac368381c | 148 | lcd.drawLine(42,24,62,34,1); |
el13kz | 10:d62ac368381c | 149 | lcd.printString("T",1,3); |
el13kz | 10:d62ac368381c | 150 | lcd.printString("1/V",64,3); |
el13kz | 10:d62ac368381c | 151 | |
el13kz | 10:d62ac368381c | 152 | lcd.clear(); |
el13kz | 10:d62ac368381c | 153 | lcd.printString("T",1,3); |
el13kz | 10:d62ac368381c | 154 | lcd.printString("1/V",64,3); |
el13kz | 10:d62ac368381c | 155 | |
el13kz | 10:d62ac368381c | 156 | lcd.drawCircle(42,24,22,0); /// x,y,radius,transparent with outline |
el13kz | 10:d62ac368381c | 157 | |
el13kz | 0:771a5148e8e7 | 158 | } |
el13kz | 10:d62ac368381c | 159 | |
el13kz | 10:d62ac368381c | 160 | |
el13kz | 10:d62ac368381c | 161 | |
el13kz | 0:771a5148e8e7 | 162 | } |
el13kz | 10:d62ac368381c | 163 | t5.stop(); |
el13kz | 10:d62ac368381c | 164 | t5.reset(); |
el13kz | 10:d62ac368381c | 165 | |
el13kz | 10:d62ac368381c | 166 | lcd.clear(); |
el13kz | 10:d62ac368381c | 167 | } |
el13kz | 10:d62ac368381c | 168 | |
el13kz | 10:d62ac368381c | 169 | |
el13kz | 10:d62ac368381c | 170 | ///shows pressure reading and temperature |
el13kz | 10:d62ac368381c | 171 | |
el13kz | 0:771a5148e8e7 | 172 | |
el13kz | 6:07133c44d3eb | 173 | void temperature() |
el13kz | 6:07133c44d3eb | 174 | { |
el13kz | 6:07133c44d3eb | 175 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 176 | |
el13kz | 10:d62ac368381c | 177 | Measurement measurement; /// measurement structure declared in BMP180 class |
el13kz | 9:5ebf44c85f77 | 178 | t1.start(); |
el13kz | 10:d62ac368381c | 179 | while(t1.read()<5) { /// if timer reaches point, tehn breaks loop, stopped at resetted at the end |
el13kz | 10:d62ac368381c | 180 | |
el13kz | 4:47b0473fa81b | 181 | |
el13kz | 10:d62ac368381c | 182 | /// read values (T in Celsius and P in mb) and print over serial port |
el13kz | 4:47b0473fa81b | 183 | measurement = bmp180.readValues(); |
el13kz | 4:47b0473fa81b | 184 | serial.printf("T = %.2f C P = %.2f mb\n",measurement.temperature,measurement.pressure); |
el13kz | 4:47b0473fa81b | 185 | |
el13kz | 4:47b0473fa81b | 186 | char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14) |
el13kz | 10:d62ac368381c | 187 | /// so can display a string of a maximum 14 characters in length |
el13kz | 4:47b0473fa81b | 188 | // or create formatted strings - ensure they aren't more than 14 characters long |
el13kz | 4:47b0473fa81b | 189 | int temperature = measurement.temperature; |
el13kz | 4:47b0473fa81b | 190 | int length = sprintf(buffer,"T = %2d C",temperature); // print formatted data to buffer |
el13kz | 10:d62ac368381c | 191 | /// it is important the format specifier ensures the length will fit in the buffer |
el13kz | 4:47b0473fa81b | 192 | if (length <= 14) // if string will fit on display |
el13kz | 6:07133c44d3eb | 193 | lcd.printString(buffer,0,1); // |
el13kz | 6:07133c44d3eb | 194 | |
el13kz | 10:d62ac368381c | 195 | |
el13kz | 10:d62ac368381c | 196 | |
el13kz | 10:d62ac368381c | 197 | lcd.drawLine(42,40,42,18,1); |
el13kz | 10:d62ac368381c | 198 | lcd.drawLine(47,40,47,18,1); ///the whole thing is a thermometer |
el13kz | 10:d62ac368381c | 199 | lcd.drawLine(42,40,44,40,1); |
el13kz | 10:d62ac368381c | 200 | lcd.drawLine(42,35,44,35,1); |
el13kz | 10:d62ac368381c | 201 | lcd.drawLine(42,30,44,30,1); |
el13kz | 10:d62ac368381c | 202 | lcd.drawLine(42,25,44,25,1); |
el13kz | 10:d62ac368381c | 203 | lcd.drawLine(42,20,44,20,1); |
el13kz | 10:d62ac368381c | 204 | lcd.setPixel(41,41); |
el13kz | 10:d62ac368381c | 205 | lcd.setPixel(48,41); |
el13kz | 10:d62ac368381c | 206 | lcd.setPixel(40,42); |
el13kz | 10:d62ac368381c | 207 | lcd.setPixel(49,42); |
el13kz | 10:d62ac368381c | 208 | lcd.setPixel(41,43); |
el13kz | 10:d62ac368381c | 209 | lcd.setPixel(48,43); |
el13kz | 10:d62ac368381c | 210 | lcd.setPixel(42,44); |
el13kz | 10:d62ac368381c | 211 | lcd.setPixel(47,44); |
el13kz | 10:d62ac368381c | 212 | lcd.drawLine(42,44,47,44,1); |
el13kz | 10:d62ac368381c | 213 | |
el13kz | 10:d62ac368381c | 214 | /** |
el13kz | 10:d62ac368381c | 215 | @param draw line from two points/sets pixel |
el13kz | 10:d62ac368381c | 216 | @returns line is drawn/pixel is set |
el13kz | 10:d62ac368381c | 217 | */ |
el13kz | 10:d62ac368381c | 218 | |
el13kz | 10:d62ac368381c | 219 | lcd.refresh(); |
el13kz | 10:d62ac368381c | 220 | |
el13kz | 10:d62ac368381c | 221 | |
el13kz | 10:d62ac368381c | 222 | |
el13kz | 10:d62ac368381c | 223 | |
el13kz | 10:d62ac368381c | 224 | |
el13kz | 6:07133c44d3eb | 225 | } |
el13kz | 9:5ebf44c85f77 | 226 | t1.stop(); |
el13kz | 10:d62ac368381c | 227 | t1.reset(); |
el13kz | 10:d62ac368381c | 228 | |
el13kz | 10:d62ac368381c | 229 | |
el13kz | 8:956a130ebdf5 | 230 | lcd.clear(); |
el13kz | 9:5ebf44c85f77 | 231 | |
el13kz | 4:47b0473fa81b | 232 | } |
el13kz | 4:47b0473fa81b | 233 | |
el13kz | 6:07133c44d3eb | 234 | void pressure() |
el13kz | 6:07133c44d3eb | 235 | { |
el13kz | 6:07133c44d3eb | 236 | lcd.clear(); |
el13kz | 4:47b0473fa81b | 237 | |
el13kz | 4:47b0473fa81b | 238 | Measurement measurement; // measurement structure declared in BMP180 class |
el13kz | 8:956a130ebdf5 | 239 | |
el13kz | 9:5ebf44c85f77 | 240 | t2.start(); |
el13kz | 8:956a130ebdf5 | 241 | |
el13kz | 10:d62ac368381c | 242 | while(t2.read()<5) { // if timer reaches point, tehn breaks loop, stopped at resetted at the end |
el13kz | 10:d62ac368381c | 243 | |
el13kz | 4:47b0473fa81b | 244 | |
el13kz | 4:47b0473fa81b | 245 | // read values (T in Celsius and P in mb) and print over serial port |
el13kz | 4:47b0473fa81b | 246 | measurement = bmp180.readValues(); |
el13kz | 4:47b0473fa81b | 247 | serial.printf("T = %.2f C P = %.2f mb\n",measurement.temperature,measurement.pressure); |
el13kz | 4:47b0473fa81b | 248 | |
el13kz | 4:47b0473fa81b | 249 | char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14) |
el13kz | 4:47b0473fa81b | 250 | // so can display a string of a maximum 14 characters in length |
el13kz | 4:47b0473fa81b | 251 | // or create formatted strings - ensure they aren't more than 14 characters long |
el13kz | 6:07133c44d3eb | 252 | |
el13kz | 4:47b0473fa81b | 253 | // |
el13kz | 4:47b0473fa81b | 254 | float pressure = measurement.pressure; // same idea with floats |
el13kz | 5:e75537898d23 | 255 | int length = sprintf(buffer,"P = %.2f mb",pressure); |
el13kz | 4:47b0473fa81b | 256 | if (length <= 14) |
el13kz | 8:956a130ebdf5 | 257 | lcd.printString(buffer,0,1); |
el13kz | 10:d62ac368381c | 258 | |
el13kz | 10:d62ac368381c | 259 | |
el13kz | 10:d62ac368381c | 260 | lcd.drawLine(42,38,42,48,1); |
el13kz | 10:d62ac368381c | 261 | lcd.drawLine(47,33,57,33,1); |
el13kz | 10:d62ac368381c | 262 | lcd.drawLine(42,27,42,17,1); |
el13kz | 10:d62ac368381c | 263 | lcd.drawLine(37,33,27,33,1); |
el13kz | 10:d62ac368381c | 264 | lcd.drawRect(27,17,30,30,0); // transparent, just outline |
el13kz | 10:d62ac368381c | 265 | lcd.drawLine(40,38,44,38,1); |
el13kz | 10:d62ac368381c | 266 | lcd.drawLine(47,31,47,35,1);//pressure box shape |
el13kz | 10:d62ac368381c | 267 | lcd.drawLine(40,27,44,27,1); |
el13kz | 10:d62ac368381c | 268 | lcd.drawLine(37,31,37,35,1); |
el13kz | 10:d62ac368381c | 269 | /** |
el13kz | 10:d62ac368381c | 270 | @param draw line from two points/sets pixel |
el13kz | 10:d62ac368381c | 271 | @returns line is drawn/pixel is set |
el13kz | 10:d62ac368381c | 272 | */ |
el13kz | 6:07133c44d3eb | 273 | } |
el13kz | 9:5ebf44c85f77 | 274 | t2.stop(); |
el13kz | 10:d62ac368381c | 275 | t2.reset(); |
el13kz | 10:d62ac368381c | 276 | |
el13kz | 10:d62ac368381c | 277 | |
el13kz | 8:956a130ebdf5 | 278 | lcd.clear(); |
el13kz | 8:956a130ebdf5 | 279 | |
el13kz | 5:e75537898d23 | 280 | } |
el13kz | 4:47b0473fa81b | 281 | |
el13kz | 4:47b0473fa81b | 282 | |
el13kz | 4:47b0473fa81b | 283 | |
el13kz | 6:07133c44d3eb | 284 | void altitude() // creating a new reading from the current ones, this appoximates the altitude in metres. |
el13kz | 6:07133c44d3eb | 285 | { |
el13kz | 4:47b0473fa81b | 286 | |
el13kz | 6:07133c44d3eb | 287 | lcd.clear(); |
el13kz | 4:47b0473fa81b | 288 | |
el13kz | 4:47b0473fa81b | 289 | Measurement measurement; // measurement structure declared in BMP180 class |
el13kz | 6:07133c44d3eb | 290 | |
el13kz | 8:956a130ebdf5 | 291 | |
el13kz | 9:5ebf44c85f77 | 292 | t3.start(); |
el13kz | 8:956a130ebdf5 | 293 | |
el13kz | 10:d62ac368381c | 294 | while(t3.read()<5) { // if timer reaches point, tehn breaks loop, stopped at resetted at the end |
el13kz | 10:d62ac368381c | 295 | |
el13kz | 4:47b0473fa81b | 296 | // read values (T in Celsius and P in mb) and print over serial port |
el13kz | 4:47b0473fa81b | 297 | measurement = bmp180.readValues(); |
el13kz | 4:47b0473fa81b | 298 | char buffer[14]; |
el13kz | 4:47b0473fa81b | 299 | int temperature = measurement.temperature; |
el13kz | 4:47b0473fa81b | 300 | float pressure = measurement.pressure; // same idea with floats |
el13kz | 4:47b0473fa81b | 301 | |
el13kz | 10:d62ac368381c | 302 | float altitude = -(log(pressure/1013.25)*1.38e-23*(273+temperature))/(9.81*28.95); |
el13kz | 10:d62ac368381c | 303 | /** |
el13kz | 10:d62ac368381c | 304 | @param pressure |
el13kz | 10:d62ac368381c | 305 | @param temperature |
el13kz | 10:d62ac368381c | 306 | @returns the anser of equation and defines as altitude |
el13kz | 10:d62ac368381c | 307 | */ |
el13kz | 10:d62ac368381c | 308 | |
el13kz | 10:d62ac368381c | 309 | |
el13kz | 6:07133c44d3eb | 310 | serial.printf("A = %.2f m",altitude); |
el13kz | 6:07133c44d3eb | 311 | int length = sprintf(buffer,"A = %.2f m",altitude); // print formatted data to buffer |
el13kz | 4:47b0473fa81b | 312 | // it is important the format specifier ensures the length will fit in the buffer |
el13kz | 6:07133c44d3eb | 313 | if (length <= 14) // if string wi |
el13kz | 4:47b0473fa81b | 314 | lcd.printString(buffer,0,1); // display on screen |
el13kz | 4:47b0473fa81b | 315 | |
el13kz | 4:47b0473fa81b | 316 | |
el13kz | 9:5ebf44c85f77 | 317 | lcd.drawLine(4,48,24,28,1); |
el13kz | 9:5ebf44c85f77 | 318 | lcd.drawLine(24,28,44,48,1); |
el13kz | 10:d62ac368381c | 319 | lcd.drawLine(34,38,44,28,1); // sketch of two mountains using pythagoras |
el13kz | 9:5ebf44c85f77 | 320 | lcd.drawLine(44,28,64,48,1); |
el13kz | 10:d62ac368381c | 321 | /** |
el13kz | 10:d62ac368381c | 322 | @param draw line from two points/sets pixel |
el13kz | 10:d62ac368381c | 323 | @returns line is drawn/pixel is set |
el13kz | 10:d62ac368381c | 324 | */ |
el13kz | 4:47b0473fa81b | 325 | |
el13kz | 4:47b0473fa81b | 326 | |
el13kz | 6:07133c44d3eb | 327 | } |
el13kz | 9:5ebf44c85f77 | 328 | t3.stop(); |
el13kz | 10:d62ac368381c | 329 | t3.reset(); |
el13kz | 10:d62ac368381c | 330 | |
el13kz | 8:956a130ebdf5 | 331 | lcd.clear(); |
el13kz | 4:47b0473fa81b | 332 | |
el13kz | 4:47b0473fa81b | 333 | } |
el13kz | 2:635c58eb70fb | 334 | //pushbutton - 0 |
el13kz | 0:771a5148e8e7 | 335 | |
el13kz | 2:635c58eb70fb | 336 | //plots graph of temperature point by point |
el13kz | 0:771a5148e8e7 | 337 | void graph() |
el13kz | 6:07133c44d3eb | 338 | { |
el13kz | 6:07133c44d3eb | 339 | lcd.clear(); |
el13kz | 4:47b0473fa81b | 340 | |
el13kz | 0:771a5148e8e7 | 341 | Measurement measurement; // measurement structure declared in BMP180 class |
el13kz | 0:771a5148e8e7 | 342 | int i = 0; |
el13kz | 0:771a5148e8e7 | 343 | float graph[84]= {0}; |
el13kz | 7:c39d54bdff28 | 344 | |
el13kz | 7:c39d54bdff28 | 345 | |
el13kz | 9:5ebf44c85f77 | 346 | t4.start(); |
el13kz | 10:d62ac368381c | 347 | while(t4.read()<15) { // if timer reaches point, tehn breaks loop, stopped at resetted at the end |
el13kz | 10:d62ac368381c | 348 | |
el13kz | 0:771a5148e8e7 | 349 | |
el13kz | 0:771a5148e8e7 | 350 | // read values (T in Celsius and P in mb) and print over serial port |
el13kz | 0:771a5148e8e7 | 351 | measurement = bmp180.readValues(); |
el13kz | 0:771a5148e8e7 | 352 | |
el13kz | 0:771a5148e8e7 | 353 | int temperature = measurement.temperature; |
el13kz | 10:d62ac368381c | 354 | /** |
el13kz | 10:d62ac368381c | 355 | @brief the temperature changed to integer value |
el13kz | 10:d62ac368381c | 356 | */ |
el13kz | 0:771a5148e8e7 | 357 | |
el13kz | 0:771a5148e8e7 | 358 | graph[i]= temperature ; |
el13kz | 0:771a5148e8e7 | 359 | lcd.plotArray(graph); |
el13kz | 10:d62ac368381c | 360 | /** |
el13kz | 10:d62ac368381c | 361 | @brief plots the graph using the array |
el13kz | 10:d62ac368381c | 362 | */ |
el13kz | 10:d62ac368381c | 363 | |
el13kz | 10:d62ac368381c | 364 | wait(0.1); |
el13kz | 10:d62ac368381c | 365 | /** |
el13kz | 10:d62ac368381c | 366 | @param delay |
el13kz | 10:d62ac368381c | 367 | @brief allows time till next reading |
el13kz | 10:d62ac368381c | 368 | */ |
el13kz | 10:d62ac368381c | 369 | |
el13kz | 10:d62ac368381c | 370 | |
el13kz | 0:771a5148e8e7 | 371 | i++; |
el13kz | 0:771a5148e8e7 | 372 | if (i>83) { |
el13kz | 0:771a5148e8e7 | 373 | i=0; |
el13kz | 0:771a5148e8e7 | 374 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 375 | } |
el13kz | 0:771a5148e8e7 | 376 | } |
el13kz | 8:956a130ebdf5 | 377 | |
el13kz | 9:5ebf44c85f77 | 378 | t4.stop(); |
el13kz | 10:d62ac368381c | 379 | t4.reset(); |
el13kz | 8:956a130ebdf5 | 380 | |
el13kz | 8:956a130ebdf5 | 381 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 382 | } |
el13kz | 0:771a5148e8e7 | 383 | |
el13kz | 6:07133c44d3eb | 384 | |
el13kz | 8:956a130ebdf5 | 385 | |
el13kz | 8:956a130ebdf5 | 386 | |
el13kz | 7:c39d54bdff28 | 387 | void graphScreen(){ |
el13kz | 7:c39d54bdff28 | 388 | |
el13kz | 7:c39d54bdff28 | 389 | lcd.clear(); |
el13kz | 10:d62ac368381c | 390 | lcd.printString("Hold Button!",6,2);//select measure menu |
el13kz | 10:d62ac368381c | 391 | wait(2); |
el13kz | 7:c39d54bdff28 | 392 | lcd.clear(); |
el13kz | 9:5ebf44c85f77 | 393 | selectedOption1 = 0; |
el13kz | 7:c39d54bdff28 | 394 | |
el13kz | 7:c39d54bdff28 | 395 | while(1) { |
el13kz | 7:c39d54bdff28 | 396 | |
el13kz | 7:c39d54bdff28 | 397 | lcd.drawRect(70,6,10,10,1); |
el13kz | 7:c39d54bdff28 | 398 | lcd.drawRect(70,21,10,10,0); |
el13kz | 7:c39d54bdff28 | 399 | lcd.drawRect(70,37,10,10,0);//check box 3 |
el13kz | 7:c39d54bdff28 | 400 | lcd.printString("line graph",1,1); |
el13kz | 7:c39d54bdff28 | 401 | lcd.printString("pie chart",1,3); |
el13kz | 7:c39d54bdff28 | 402 | lcd.printString("go back",1,5); |
el13kz | 10:d62ac368381c | 403 | /** |
el13kz | 10:d62ac368381c | 404 | @Brief sets the first scene of menu |
el13kz | 10:d62ac368381c | 405 | */ |
el13kz | 10:d62ac368381c | 406 | |
el13kz | 10:d62ac368381c | 407 | |
el13kz | 7:c39d54bdff28 | 408 | lcd.printString(">",62,1); |
el13kz | 9:5ebf44c85f77 | 409 | selectedOption1 = 1; |
el13kz | 7:c39d54bdff28 | 410 | if (pushbutton1) |
el13kz | 7:c39d54bdff28 | 411 | break; |
el13kz | 7:c39d54bdff28 | 412 | wait(2); |
el13kz | 7:c39d54bdff28 | 413 | lcd.clear(); |
el13kz | 7:c39d54bdff28 | 414 | |
el13kz | 7:c39d54bdff28 | 415 | lcd.drawRect(70,6,10,10,0); |
el13kz | 7:c39d54bdff28 | 416 | lcd.drawRect(70,21,10,10,1); |
el13kz | 7:c39d54bdff28 | 417 | lcd.drawRect(70,37,10,10,0);//check box 3 |
el13kz | 7:c39d54bdff28 | 418 | lcd.printString("line graph",1,1); |
el13kz | 8:956a130ebdf5 | 419 | lcd.printString("pie chart",1,3); |
el13kz | 7:c39d54bdff28 | 420 | |
el13kz | 8:956a130ebdf5 | 421 | lcd.printString("go back",1,5); |
el13kz | 7:c39d54bdff28 | 422 | lcd.printString(">",62,3); |
el13kz | 9:5ebf44c85f77 | 423 | selectedOption1 = 2; |
el13kz | 7:c39d54bdff28 | 424 | if (pushbutton1) |
el13kz | 7:c39d54bdff28 | 425 | break; |
el13kz | 7:c39d54bdff28 | 426 | wait(2); |
el13kz | 7:c39d54bdff28 | 427 | lcd.clear(); |
el13kz | 7:c39d54bdff28 | 428 | |
el13kz | 7:c39d54bdff28 | 429 | lcd.drawRect(70,6,10,10,0); |
el13kz | 7:c39d54bdff28 | 430 | lcd.drawRect(70,21,10,10,0); |
el13kz | 7:c39d54bdff28 | 431 | lcd.drawRect(70,37,10,10,1);//check box 3 |
el13kz | 7:c39d54bdff28 | 432 | lcd.printString("line graph",1,1); |
el13kz | 7:c39d54bdff28 | 433 | lcd.printString("pie chart",1,3); |
el13kz | 7:c39d54bdff28 | 434 | lcd.printString("go back",1,5); |
el13kz | 7:c39d54bdff28 | 435 | lcd.printString(">",62,5); |
el13kz | 9:5ebf44c85f77 | 436 | selectedOption1 = 3; |
el13kz | 7:c39d54bdff28 | 437 | if (pushbutton1) |
el13kz | 7:c39d54bdff28 | 438 | break; |
el13kz | 7:c39d54bdff28 | 439 | wait(2); |
el13kz | 7:c39d54bdff28 | 440 | lcd.clear(); |
el13kz | 7:c39d54bdff28 | 441 | |
el13kz | 7:c39d54bdff28 | 442 | } |
el13kz | 7:c39d54bdff28 | 443 | |
el13kz | 10:d62ac368381c | 444 | if(selectedOption1 == 1) { //selected option is tied to a certain output depending on its value |
el13kz | 7:c39d54bdff28 | 445 | |
el13kz | 7:c39d54bdff28 | 446 | lcd.clear(); |
el13kz | 7:c39d54bdff28 | 447 | } |
el13kz | 7:c39d54bdff28 | 448 | |
el13kz | 9:5ebf44c85f77 | 449 | if(selectedOption1 == 2) { |
el13kz | 7:c39d54bdff28 | 450 | |
el13kz | 7:c39d54bdff28 | 451 | graph(); |
el13kz | 7:c39d54bdff28 | 452 | |
el13kz | 7:c39d54bdff28 | 453 | } |
el13kz | 7:c39d54bdff28 | 454 | |
el13kz | 9:5ebf44c85f77 | 455 | if(selectedOption1 == 3) { |
el13kz | 7:c39d54bdff28 | 456 | |
el13kz | 9:5ebf44c85f77 | 457 | pie(); |
el13kz | 7:c39d54bdff28 | 458 | } |
el13kz | 7:c39d54bdff28 | 459 | |
el13kz | 7:c39d54bdff28 | 460 | |
el13kz | 7:c39d54bdff28 | 461 | } |
el13kz | 4:47b0473fa81b | 462 | |
el13kz | 4:47b0473fa81b | 463 | |
el13kz | 4:47b0473fa81b | 464 | |
el13kz | 4:47b0473fa81b | 465 | void measurementsScreen() |
el13kz | 6:07133c44d3eb | 466 | { |
el13kz | 6:07133c44d3eb | 467 | lcd.clear(); |
el13kz | 10:d62ac368381c | 468 | lcd.printString("Hold Button!",6,2);//select measure menu |
el13kz | 10:d62ac368381c | 469 | wait(2); |
el13kz | 6:07133c44d3eb | 470 | lcd.clear(); |
el13kz | 9:5ebf44c85f77 | 471 | selectedOption2 = 0; |
el13kz | 0:771a5148e8e7 | 472 | |
el13kz | 4:47b0473fa81b | 473 | while(1) { |
el13kz | 0:771a5148e8e7 | 474 | |
el13kz | 2:635c58eb70fb | 475 | lcd.drawRect(70,6,10,10,1); |
el13kz | 2:635c58eb70fb | 476 | lcd.drawRect(70,21,10,10,0); |
el13kz | 5:e75537898d23 | 477 | lcd.drawRect(70,37,10,10,0);//check box 3 |
el13kz | 5:e75537898d23 | 478 | lcd.printString("temperature",1,1); |
el13kz | 6:07133c44d3eb | 479 | lcd.printString("altitude",1,3); |
el13kz | 5:e75537898d23 | 480 | lcd.printString("pressure",1,5); |
el13kz | 10:d62ac368381c | 481 | /** |
el13kz | 10:d62ac368381c | 482 | @Brief sets the first scene of menu |
el13kz | 10:d62ac368381c | 483 | */ |
el13kz | 2:635c58eb70fb | 484 | lcd.printString(">",62,1); |
el13kz | 9:5ebf44c85f77 | 485 | selectedOption2 = 1; |
el13kz | 6:07133c44d3eb | 486 | if (pushbutton1) |
el13kz | 4:47b0473fa81b | 487 | break; |
el13kz | 0:771a5148e8e7 | 488 | wait(2); |
el13kz | 0:771a5148e8e7 | 489 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 490 | |
el13kz | 2:635c58eb70fb | 491 | lcd.drawRect(70,6,10,10,0); |
el13kz | 2:635c58eb70fb | 492 | lcd.drawRect(70,21,10,10,1); |
el13kz | 6:07133c44d3eb | 493 | lcd.drawRect(70,37,10,10,0);//check box 3 |
el13kz | 5:e75537898d23 | 494 | lcd.printString("temperature",1,1); |
el13kz | 5:e75537898d23 | 495 | lcd.printString("pressure",1,5); |
el13kz | 5:e75537898d23 | 496 | |
el13kz | 4:47b0473fa81b | 497 | lcd.printString("altitude",1,3); |
el13kz | 2:635c58eb70fb | 498 | lcd.printString(">",62,3); |
el13kz | 9:5ebf44c85f77 | 499 | selectedOption2 = 2; |
el13kz | 6:07133c44d3eb | 500 | if (pushbutton1) |
el13kz | 4:47b0473fa81b | 501 | break; |
el13kz | 4:47b0473fa81b | 502 | wait(2); |
el13kz | 4:47b0473fa81b | 503 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 504 | |
el13kz | 5:e75537898d23 | 505 | lcd.drawRect(70,6,10,10,0); |
el13kz | 5:e75537898d23 | 506 | lcd.drawRect(70,21,10,10,0); |
el13kz | 5:e75537898d23 | 507 | lcd.drawRect(70,37,10,10,1);//check box 3 |
el13kz | 6:07133c44d3eb | 508 | lcd.printString("temperature",1,1); |
el13kz | 6:07133c44d3eb | 509 | lcd.printString("altitude",1,3); |
el13kz | 5:e75537898d23 | 510 | lcd.printString("pressure",1,5); |
el13kz | 5:e75537898d23 | 511 | lcd.printString(">",62,5); |
el13kz | 9:5ebf44c85f77 | 512 | selectedOption2 = 3; |
el13kz | 6:07133c44d3eb | 513 | if (pushbutton1) |
el13kz | 4:47b0473fa81b | 514 | break; |
el13kz | 0:771a5148e8e7 | 515 | wait(2); |
el13kz | 0:771a5148e8e7 | 516 | lcd.clear(); |
el13kz | 2:635c58eb70fb | 517 | |
el13kz | 2:635c58eb70fb | 518 | } |
el13kz | 2:635c58eb70fb | 519 | |
el13kz | 10:d62ac368381c | 520 | if(selectedOption2 == 1) {//selected option is tied to a certain output depending on its value |
el13kz | 10:d62ac368381c | 521 | |
el13kz | 0:771a5148e8e7 | 522 | |
el13kz | 4:47b0473fa81b | 523 | pressure(); |
el13kz | 2:635c58eb70fb | 524 | } |
el13kz | 2:635c58eb70fb | 525 | |
el13kz | 9:5ebf44c85f77 | 526 | if(selectedOption2 == 2) { |
el13kz | 2:635c58eb70fb | 527 | |
el13kz | 4:47b0473fa81b | 528 | temperature(); |
el13kz | 2:635c58eb70fb | 529 | |
el13kz | 2:635c58eb70fb | 530 | } |
el13kz | 4:47b0473fa81b | 531 | |
el13kz | 9:5ebf44c85f77 | 532 | if(selectedOption2 == 3) { |
el13kz | 4:47b0473fa81b | 533 | |
el13kz | 4:47b0473fa81b | 534 | altitude(); |
el13kz | 4:47b0473fa81b | 535 | } |
el13kz | 4:47b0473fa81b | 536 | |
el13kz | 4:47b0473fa81b | 537 | |
el13kz | 0:771a5148e8e7 | 538 | } |
el13kz | 0:771a5148e8e7 | 539 | |
el13kz | 0:771a5148e8e7 | 540 | void introScreen() |
el13kz | 0:771a5148e8e7 | 541 | { |
el13kz | 0:771a5148e8e7 | 542 | |
el13kz | 10:d62ac368381c | 543 | lcd.printString("Welcome to",11,1); |
el13kz | 10:d62ac368381c | 544 | lcd.printString("Keiarash's",12,2); |
el13kz | 10:d62ac368381c | 545 | lcd.printString("Multi Sensor",7,3); |
el13kz | 6:07133c44d3eb | 546 | Redled= 1.0; |
el13kz | 10:d62ac368381c | 547 | |
el13kz | 10:d62ac368381c | 548 | for(int i = 0; i < 84 ; i+=6) { //checkerboard |
el13kz | 10:d62ac368381c | 549 | for (int j = 0; j < 48 ; j+=6) { |
el13kz | 10:d62ac368381c | 550 | lcd.setPixel(i,j); |
el13kz | 0:771a5148e8e7 | 551 | |
el13kz | 10:d62ac368381c | 552 | /** |
el13kz | 10:d62ac368381c | 553 | @param set the pixel at designated i,j point |
el13kz | 10:d62ac368381c | 554 | @return pixel is set |
el13kz | 10:d62ac368381c | 555 | */ |
el13kz | 10:d62ac368381c | 556 | |
el13kz | 10:d62ac368381c | 557 | } |
el13kz | 10:d62ac368381c | 558 | } |
el13kz | 10:d62ac368381c | 559 | lcd.refresh(); |
el13kz | 10:d62ac368381c | 560 | |
el13kz | 10:d62ac368381c | 561 | t6.start(); |
el13kz | 10:d62ac368381c | 562 | |
el13kz | 10:d62ac368381c | 563 | while(t6.read()<3){ // if timer reaches point, tehn breaks loop, stopped at resetted at the end |
el13kz | 10:d62ac368381c | 564 | |
el13kz | 10:d62ac368381c | 565 | lcd.inverseMode();//inverse used to make flashy effect |
el13kz | 10:d62ac368381c | 566 | wait(0.5); |
el13kz | 10:d62ac368381c | 567 | lcd.normalMode(); |
el13kz | 10:d62ac368381c | 568 | wait(0.5); |
el13kz | 10:d62ac368381c | 569 | } |
el13kz | 10:d62ac368381c | 570 | |
el13kz | 10:d62ac368381c | 571 | t6.stop(); |
el13kz | 10:d62ac368381c | 572 | t6.reset(); |
el13kz | 0:771a5148e8e7 | 573 | |
el13kz | 0:771a5148e8e7 | 574 | } |
el13kz | 0:771a5148e8e7 | 575 | |
el13kz | 4:47b0473fa81b | 576 | |
el13kz | 4:47b0473fa81b | 577 | void extrasScreen() |
el13kz | 6:07133c44d3eb | 578 | { |
el13kz | 6:07133c44d3eb | 579 | lcd.clear(); |
el13kz | 6:07133c44d3eb | 580 | lcd.printString("Hold Button!",6,2);//select measure menu |
el13kz | 10:d62ac368381c | 581 | wait(2); |
el13kz | 6:07133c44d3eb | 582 | lcd.clear(); |
el13kz | 9:5ebf44c85f77 | 583 | selectedOption3 = 0; |
el13kz | 4:47b0473fa81b | 584 | |
el13kz | 4:47b0473fa81b | 585 | while(1) { |
el13kz | 4:47b0473fa81b | 586 | |
el13kz | 10:d62ac368381c | 587 | |
el13kz | 4:47b0473fa81b | 588 | lcd.drawRect(70,6,10,10,1); |
el13kz | 4:47b0473fa81b | 589 | lcd.drawRect(70,21,10,10,0); |
el13kz | 10:d62ac368381c | 590 | lcd.drawRect(70,37,10,10,0);//check box 3 |
el13kz | 10:d62ac368381c | 591 | lcd.printString("check temp",1,1); |
el13kz | 10:d62ac368381c | 592 | lcd.printString("check alt",1,3); |
el13kz | 10:d62ac368381c | 593 | lcd.printString("go back",1,5); |
el13kz | 10:d62ac368381c | 594 | /** |
el13kz | 10:d62ac368381c | 595 | @Brief sets the first scene of menu |
el13kz | 10:d62ac368381c | 596 | */ |
el13kz | 4:47b0473fa81b | 597 | lcd.printString(">",62,1); |
el13kz | 9:5ebf44c85f77 | 598 | selectedOption3 = 1; |
el13kz | 6:07133c44d3eb | 599 | if (pushbutton1) |
el13kz | 4:47b0473fa81b | 600 | break; |
el13kz | 4:47b0473fa81b | 601 | wait(2); |
el13kz | 4:47b0473fa81b | 602 | lcd.clear(); |
el13kz | 4:47b0473fa81b | 603 | |
el13kz | 4:47b0473fa81b | 604 | lcd.drawRect(70,6,10,10,0); |
el13kz | 4:47b0473fa81b | 605 | lcd.drawRect(70,21,10,10,1); |
el13kz | 10:d62ac368381c | 606 | lcd.drawRect(70,37,10,10,0);//check box 3 |
el13kz | 10:d62ac368381c | 607 | lcd.printString("check temp",1,1); |
el13kz | 10:d62ac368381c | 608 | lcd.printString("check alt",1,3); |
el13kz | 10:d62ac368381c | 609 | lcd.printString("go back",1,5); |
el13kz | 4:47b0473fa81b | 610 | lcd.printString(">",62,3); |
el13kz | 9:5ebf44c85f77 | 611 | selectedOption3 = 2; |
el13kz | 6:07133c44d3eb | 612 | if (pushbutton1) |
el13kz | 4:47b0473fa81b | 613 | break; |
el13kz | 4:47b0473fa81b | 614 | wait(2); |
el13kz | 4:47b0473fa81b | 615 | lcd.clear(); |
el13kz | 10:d62ac368381c | 616 | |
el13kz | 10:d62ac368381c | 617 | lcd.drawRect(70,6,10,10,0); |
el13kz | 10:d62ac368381c | 618 | lcd.drawRect(70,21,10,10,0); |
el13kz | 10:d62ac368381c | 619 | lcd.drawRect(70,37,10,10,1);//check box 3 |
el13kz | 10:d62ac368381c | 620 | lcd.printString("check temp",1,1); |
el13kz | 10:d62ac368381c | 621 | lcd.printString("check alt",1,3); |
el13kz | 10:d62ac368381c | 622 | lcd.printString("go back",1,5); |
el13kz | 10:d62ac368381c | 623 | lcd.printString(">",62,5); |
el13kz | 10:d62ac368381c | 624 | selectedOption3 = 3; |
el13kz | 10:d62ac368381c | 625 | if (pushbutton1) |
el13kz | 10:d62ac368381c | 626 | break; |
el13kz | 10:d62ac368381c | 627 | wait(2); |
el13kz | 10:d62ac368381c | 628 | lcd.clear(); |
el13kz | 10:d62ac368381c | 629 | |
el13kz | 4:47b0473fa81b | 630 | |
el13kz | 4:47b0473fa81b | 631 | } |
el13kz | 4:47b0473fa81b | 632 | |
el13kz | 10:d62ac368381c | 633 | if(selectedOption3 == 1) {// using the same method as mainscreen, if the option is the one in the loop, then it will go to that function |
el13kz | 4:47b0473fa81b | 634 | |
el13kz | 4:47b0473fa81b | 635 | lcd.clear(); |
el13kz | 4:47b0473fa81b | 636 | } |
el13kz | 4:47b0473fa81b | 637 | |
el13kz | 10:d62ac368381c | 638 | if(selectedOption3 == 2) {//selected option is tied to a certain output depending on its value |
el13kz | 4:47b0473fa81b | 639 | |
el13kz | 10:d62ac368381c | 640 | |
el13kz | 10:d62ac368381c | 641 | checkt(); |
el13kz | 4:47b0473fa81b | 642 | |
el13kz | 4:47b0473fa81b | 643 | } |
el13kz | 10:d62ac368381c | 644 | |
el13kz | 10:d62ac368381c | 645 | |
el13kz | 10:d62ac368381c | 646 | if(selectedOption3 == 3) { |
el13kz | 10:d62ac368381c | 647 | |
el13kz | 10:d62ac368381c | 648 | checka(); |
el13kz | 10:d62ac368381c | 649 | |
el13kz | 10:d62ac368381c | 650 | } |
el13kz | 10:d62ac368381c | 651 | |
el13kz | 4:47b0473fa81b | 652 | } |
el13kz | 4:47b0473fa81b | 653 | |
el13kz | 4:47b0473fa81b | 654 | |
el13kz | 4:47b0473fa81b | 655 | |
el13kz | 0:771a5148e8e7 | 656 | void mainScreen() |
el13kz | 0:771a5148e8e7 | 657 | { |
el13kz | 7:c39d54bdff28 | 658 | lcd.clear(); |
el13kz | 6:07133c44d3eb | 659 | lcd.printString("Hold Button!",6,2);//select measure menu |
el13kz | 4:47b0473fa81b | 660 | |
el13kz | 10:d62ac368381c | 661 | wait(2); |
el13kz | 6:07133c44d3eb | 662 | lcd.clear(); |
el13kz | 6:07133c44d3eb | 663 | |
el13kz | 9:5ebf44c85f77 | 664 | selectedOption4 = 0; |
el13kz | 0:771a5148e8e7 | 665 | |
el13kz | 4:47b0473fa81b | 666 | while(1) {//initialse pushbutton as 0 |
el13kz | 6:07133c44d3eb | 667 | |
el13kz | 2:635c58eb70fb | 668 | //check boxes-options to be selected |
el13kz | 2:635c58eb70fb | 669 | lcd.drawRect(70,6,10,10,1);//check box 1 |
el13kz | 2:635c58eb70fb | 670 | lcd.drawRect(70,21,10,10,0);//check box 2 |
el13kz | 2:635c58eb70fb | 671 | lcd.drawRect(70,37,10,10,0);//check box 3 |
el13kz | 10:d62ac368381c | 672 | /** |
el13kz | 10:d62ac368381c | 673 | @Brief sets the first scene of menu |
el13kz | 10:d62ac368381c | 674 | */ |
el13kz | 2:635c58eb70fb | 675 | //option titles-appropriate to check boxes |
el13kz | 4:47b0473fa81b | 676 | lcd.printString("extras",1,1);//select measure menu |
el13kz | 4:47b0473fa81b | 677 | lcd.printString("graph",1,3);//select settings menu |
el13kz | 10:d62ac368381c | 678 | lcd.printString("measure",1,5);//select graph plot |
el13kz | 2:635c58eb70fb | 679 | lcd.printString(">",62,1);//pointer |
el13kz | 9:5ebf44c85f77 | 680 | selectedOption4 = 1; |
el13kz | 4:47b0473fa81b | 681 | if (pushbutton1) |
el13kz | 4:47b0473fa81b | 682 | break; |
el13kz | 0:771a5148e8e7 | 683 | |
el13kz | 0:771a5148e8e7 | 684 | wait(2); |
el13kz | 0:771a5148e8e7 | 685 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 686 | |
el13kz | 0:771a5148e8e7 | 687 | lcd.drawRect(70,6,10,10,0); |
el13kz | 0:771a5148e8e7 | 688 | lcd.drawRect(70,21,10,10,1); |
el13kz | 0:771a5148e8e7 | 689 | lcd.drawRect(70,37,10,10,0); |
el13kz | 0:771a5148e8e7 | 690 | |
el13kz | 0:771a5148e8e7 | 691 | |
el13kz | 4:47b0473fa81b | 692 | lcd.printString("extras",1,1); |
el13kz | 4:47b0473fa81b | 693 | lcd.printString("graph",1,3); |
el13kz | 4:47b0473fa81b | 694 | lcd.printString("measure",1,5); |
el13kz | 0:771a5148e8e7 | 695 | lcd.printString(">",62,3); |
el13kz | 9:5ebf44c85f77 | 696 | selectedOption4 = 2; |
el13kz | 6:07133c44d3eb | 697 | if (pushbutton1) |
el13kz | 4:47b0473fa81b | 698 | break; |
el13kz | 4:47b0473fa81b | 699 | |
el13kz | 0:771a5148e8e7 | 700 | |
el13kz | 0:771a5148e8e7 | 701 | wait(2); |
el13kz | 0:771a5148e8e7 | 702 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 703 | |
el13kz | 0:771a5148e8e7 | 704 | lcd.drawRect(70,6,10,10,0); |
el13kz | 0:771a5148e8e7 | 705 | lcd.drawRect(70,21,10,10,0); |
el13kz | 0:771a5148e8e7 | 706 | lcd.drawRect(70,37,10,10,1); |
el13kz | 0:771a5148e8e7 | 707 | |
el13kz | 0:771a5148e8e7 | 708 | |
el13kz | 4:47b0473fa81b | 709 | lcd.printString("extras",1,1); |
el13kz | 4:47b0473fa81b | 710 | lcd.printString("graph",1,3); |
el13kz | 4:47b0473fa81b | 711 | lcd.printString("measure",1,5); |
el13kz | 0:771a5148e8e7 | 712 | lcd.printString(">",62,5); |
el13kz | 9:5ebf44c85f77 | 713 | selectedOption4 = 3; |
el13kz | 6:07133c44d3eb | 714 | if (pushbutton1) |
el13kz | 4:47b0473fa81b | 715 | break; |
el13kz | 4:47b0473fa81b | 716 | |
el13kz | 0:771a5148e8e7 | 717 | |
el13kz | 0:771a5148e8e7 | 718 | wait(2); |
el13kz | 0:771a5148e8e7 | 719 | lcd.clear(); |
el13kz | 0:771a5148e8e7 | 720 | |
el13kz | 0:771a5148e8e7 | 721 | |
el13kz | 0:771a5148e8e7 | 722 | } |
el13kz | 2:635c58eb70fb | 723 | |
el13kz | 10:d62ac368381c | 724 | if(selectedOption4 == 1) { //if these options are at their value, then it will go to corresponding menu |
el13kz | 2:635c58eb70fb | 725 | |
el13kz | 4:47b0473fa81b | 726 | measurementsScreen(); |
el13kz | 2:635c58eb70fb | 727 | } |
el13kz | 2:635c58eb70fb | 728 | |
el13kz | 9:5ebf44c85f77 | 729 | if(selectedOption4 == 2) { |
el13kz | 2:635c58eb70fb | 730 | |
el13kz | 4:47b0473fa81b | 731 | extrasScreen(); |
el13kz | 2:635c58eb70fb | 732 | } |
el13kz | 2:635c58eb70fb | 733 | |
el13kz | 9:5ebf44c85f77 | 734 | if(selectedOption4 == 3) { |
el13kz | 2:635c58eb70fb | 735 | |
el13kz | 7:c39d54bdff28 | 736 | graphScreen(); |
el13kz | 2:635c58eb70fb | 737 | } |
el13kz | 0:771a5148e8e7 | 738 | } |
el13kz | 0:771a5148e8e7 | 739 | |
el13kz | 0:771a5148e8e7 | 740 | |
el13kz | 0:771a5148e8e7 | 741 | int main() |
el13kz | 10:d62ac368381c | 742 | { Redled.period(0.02); // set PWM period to 20m //pwm |
el13kz | 10:d62ac368381c | 743 | pushbutton1.mode(PullUp);//initial value 0 //set button to pullup, singe it is connected to gnd |
el13kz | 0:771a5148e8e7 | 744 | // initiliase barometer |
el13kz | 0:771a5148e8e7 | 745 | bmp180.init(); |
el13kz | 6:07133c44d3eb | 746 | |
el13kz | 0:771a5148e8e7 | 747 | lcd.init(); |
el13kz | 0:771a5148e8e7 | 748 | introScreen(); |
el13kz | 10:d62ac368381c | 749 | |
el13kz | 10:d62ac368381c | 750 | /** |
el13kz | 10:d62ac368381c | 751 | @brief calls introScreen function |
el13kz | 10:d62ac368381c | 752 | */ |
el13kz | 10:d62ac368381c | 753 | |
el13kz | 10:d62ac368381c | 754 | |
el13kz | 10:d62ac368381c | 755 | wait(1); |
el13kz | 10:d62ac368381c | 756 | Redled =0; //turn led off |
el13kz | 9:5ebf44c85f77 | 757 | |
el13kz | 6:07133c44d3eb | 758 | |
el13kz | 9:5ebf44c85f77 | 759 | while(1) { |
el13kz | 9:5ebf44c85f77 | 760 | |
el13kz | 9:5ebf44c85f77 | 761 | lcd.clear(); |
el13kz | 10:d62ac368381c | 762 | lcd.printString("MAIN MENU...",6,2); //tells user where they are going |
el13kz | 10:d62ac368381c | 763 | /** |
el13kz | 10:d62ac368381c | 764 | @param prints string |
el13kz | 10:d62ac368381c | 765 | @return shows string |
el13kz | 10:d62ac368381c | 766 | @brief helps user navigate |
el13kz | 10:d62ac368381c | 767 | */ |
el13kz | 10:d62ac368381c | 768 | |
el13kz | 9:5ebf44c85f77 | 769 | wait(2); |
el13kz | 10:d62ac368381c | 770 | /** |
el13kz | 10:d62ac368381c | 771 | @param delay given amount of seconds |
el13kz | 10:d62ac368381c | 772 | @brief allows string to stay on string for user to see |
el13kz | 10:d62ac368381c | 773 | */ |
el13kz | 10:d62ac368381c | 774 | |
el13kz | 9:5ebf44c85f77 | 775 | mainScreen(); |
el13kz | 9:5ebf44c85f77 | 776 | |
el13kz | 6:07133c44d3eb | 777 | |
el13kz | 10:d62ac368381c | 778 | } |
el13kz | 6:07133c44d3eb | 779 | |
el13kz | 10:d62ac368381c | 780 | sleep(); |
el13kz | 2:635c58eb70fb | 781 | } |
el13kz | 10:d62ac368381c | 782 |