Keiarash Zoughi's Multi-Sensor for weather detection.

Dependencies:   BMP180 N5110 mbed

Committer:
el13kz
Date:
Thu May 07 16:02:05 2015 +0000
Revision:
4:47b0473fa81b
Parent:
2:635c58eb70fb
Child:
5:e75537898d23
post button solving

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el13kz 0:771a5148e8e7 1 #include "mbed.h"
el13kz 0:771a5148e8e7 2 #include "N5110.h"
el13kz 0:771a5148e8e7 3 #include "BMP180.h"
el13kz 0:771a5148e8e7 4
el13kz 0:771a5148e8e7 5 #define PI 3.14159265359
el13kz 2:635c58eb70fb 6
el13kz 2:635c58eb70fb 7 //LCD inputs
el13kz 2:635c58eb70fb 8 N5110 lcd(p7,p8,p9,p10,p11,p13,p26);
el13kz 2:635c58eb70fb 9
el13kz 2:635c58eb70fb 10 //serial port for debugging
el13kz 2:635c58eb70fb 11 Serial serial(USBTX,USBRX);
el13kz 2:635c58eb70fb 12
el13kz 2:635c58eb70fb 13 //LED outputs
el13kz 0:771a5148e8e7 14 BusOut leds(LED4,LED3,LED2,LED1); // LEDs for display
el13kz 0:771a5148e8e7 15
el13kz 2:635c58eb70fb 16
el13kz 2:635c58eb70fb 17 //select button
el13kz 0:771a5148e8e7 18 DigitalIn pushbutton1(p19);
el13kz 2:635c58eb70fb 19
el13kz 2:635c58eb70fb 20
el13kz 2:635c58eb70fb 21 //barometer sensor input
el13kz 0:771a5148e8e7 22 BMP180 bmp180(p28,p27); // SDA, SCL
el13kz 2:635c58eb70fb 23
el13kz 2:635c58eb70fb 24 //warning LED
el13kz 2:635c58eb70fb 25 PwmOut Redled(p24);
el13kz 2:635c58eb70fb 26
el13kz 2:635c58eb70fb 27 //globals
el13kz 0:771a5148e8e7 28 int selectedOption = 0;
el13kz 0:771a5148e8e7 29 int buttonPressed = 0;
el13kz 0:771a5148e8e7 30
el13kz 2:635c58eb70fb 31 //boundary conditions - screen
el13kz 2:635c58eb70fb 32 int cells[84][48];
el13kz 2:635c58eb70fb 33
el13kz 4:47b0473fa81b 34
el13kz 4:47b0473fa81b 35 void check(){
el13kz 4:47b0473fa81b 36 lcd.clear();
el13kz 4:47b0473fa81b 37 Redled.period(0.02); // set PWM period to 20ms
el13kz 4:47b0473fa81b 38
el13kz 4:47b0473fa81b 39 Measurement measurement; // measurement structure declared in BMP180 class
el13kz 4:47b0473fa81b 40
el13kz 4:47b0473fa81b 41
el13kz 4:47b0473fa81b 42 // read values (T in Celsius and P in mb) and print over serial port
el13kz 4:47b0473fa81b 43 measurement = bmp180.readValues();
el13kz 4:47b0473fa81b 44 serial.printf("T = %.2f C P = %.2f mb\n",measurement.temperature,measurement.pressure);
el13kz 4:47b0473fa81b 45
el13kz 4:47b0473fa81b 46 // so can display a string of a maximum 14 characters in length
el13kz 4:47b0473fa81b 47 // or create formatted strings - ensure they aren't more than 14 characters long
el13kz 4:47b0473fa81b 48 int temperature = measurement.temperature;
el13kz 4:47b0473fa81b 49 // display on screen
el13kz 4:47b0473fa81b 50 //
el13kz 4:47b0473fa81b 51 float pressure = measurement.pressure; // same idea with floats
el13kz 4:47b0473fa81b 52
el13kz 4:47b0473fa81b 53
el13kz 4:47b0473fa81b 54
el13kz 4:47b0473fa81b 55 if(measurement.temperature > 30 ){
el13kz 4:47b0473fa81b 56
el13kz 4:47b0473fa81b 57 lcd.printString("temperature high!",1,1);
el13kz 4:47b0473fa81b 58
el13kz 4:47b0473fa81b 59 Redled=1.0;
el13kz 4:47b0473fa81b 60
el13kz 4:47b0473fa81b 61 wait(3); }
el13kz 4:47b0473fa81b 62
el13kz 4:47b0473fa81b 63 if(measurement.temperature < 3){
el13kz 4:47b0473fa81b 64
el13kz 4:47b0473fa81b 65 lcd.printString("temperature low!",1,1);
el13kz 4:47b0473fa81b 66
el13kz 4:47b0473fa81b 67 Redled= 1.0;
el13kz 4:47b0473fa81b 68
el13kz 4:47b0473fa81b 69 wait(3); }
el13kz 4:47b0473fa81b 70
el13kz 4:47b0473fa81b 71 else { lcd.printString("temperature ok!",1,1);
el13kz 4:47b0473fa81b 72 wait(3);
el13kz 4:47b0473fa81b 73 }
el13kz 4:47b0473fa81b 74 }
el13kz 4:47b0473fa81b 75
el13kz 4:47b0473fa81b 76
el13kz 4:47b0473fa81b 77
el13kz 4:47b0473fa81b 78
el13kz 4:47b0473fa81b 79
el13kz 4:47b0473fa81b 80
el13kz 4:47b0473fa81b 81
el13kz 4:47b0473fa81b 82
el13kz 2:635c58eb70fb 83 //shows pressure reading and temperature
el13kz 0:771a5148e8e7 84 void measurement()
el13kz 4:47b0473fa81b 85 {lcd.clear();
el13kz 4:47b0473fa81b 86
el13kz 0:771a5148e8e7 87 Measurement measurement; // measurement structure declared in BMP180 class
el13kz 0:771a5148e8e7 88 while(1) {
el13kz 0:771a5148e8e7 89
el13kz 0:771a5148e8e7 90 // read values (T in Celsius and P in mb) and print over serial port
el13kz 0:771a5148e8e7 91 measurement = bmp180.readValues();
el13kz 0:771a5148e8e7 92 serial.printf("T = %.2f C P = %.2f mb\n",measurement.temperature,measurement.pressure);
el13kz 0:771a5148e8e7 93
el13kz 0:771a5148e8e7 94 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)
el13kz 0:771a5148e8e7 95 // so can display a string of a maximum 14 characters in length
el13kz 0:771a5148e8e7 96 // or create formatted strings - ensure they aren't more than 14 characters long
el13kz 0:771a5148e8e7 97 int temperature = measurement.temperature;
el13kz 0:771a5148e8e7 98 int length = sprintf(buffer,"T = %2d C",temperature); // print formatted data to buffer
el13kz 0:771a5148e8e7 99 // it is important the format specifier ensures the length will fit in the buffer
el13kz 0:771a5148e8e7 100 if (length <= 14) // if string will fit on display
el13kz 0:771a5148e8e7 101 lcd.printString(buffer,0,1); // display on screen
el13kz 0:771a5148e8e7 102 //
el13kz 0:771a5148e8e7 103 float pressure = measurement.pressure; // same idea with floats
el13kz 0:771a5148e8e7 104 length = sprintf(buffer,"P = %.2f mb",pressure);
el13kz 0:771a5148e8e7 105 if (length <= 14)
el13kz 0:771a5148e8e7 106 lcd.printString(buffer,0,2);
el13kz 0:771a5148e8e7 107 }
el13kz 0:771a5148e8e7 108 }
el13kz 0:771a5148e8e7 109
el13kz 4:47b0473fa81b 110 void temperature(){
el13kz 4:47b0473fa81b 111 lcd.clear();
el13kz 0:771a5148e8e7 112
el13kz 4:47b0473fa81b 113 Measurement measurement; // measurement structure declared in BMP180 class
el13kz 4:47b0473fa81b 114 while(1) {
el13kz 4:47b0473fa81b 115
el13kz 4:47b0473fa81b 116 // read values (T in Celsius and P in mb) and print over serial port
el13kz 4:47b0473fa81b 117 measurement = bmp180.readValues();
el13kz 4:47b0473fa81b 118 serial.printf("T = %.2f C P = %.2f mb\n",measurement.temperature,measurement.pressure);
el13kz 4:47b0473fa81b 119
el13kz 4:47b0473fa81b 120 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)
el13kz 4:47b0473fa81b 121 // so can display a string of a maximum 14 characters in length
el13kz 4:47b0473fa81b 122 // or create formatted strings - ensure they aren't more than 14 characters long
el13kz 4:47b0473fa81b 123 int temperature = measurement.temperature;
el13kz 4:47b0473fa81b 124 int length = sprintf(buffer,"T = %2d C",temperature); // print formatted data to buffer
el13kz 4:47b0473fa81b 125 // it is important the format specifier ensures the length will fit in the buffer
el13kz 4:47b0473fa81b 126 if (length <= 14) // if string will fit on display
el13kz 4:47b0473fa81b 127 lcd.printString(buffer,0,1); //
el13kz 4:47b0473fa81b 128
el13kz 4:47b0473fa81b 129 }
el13kz 4:47b0473fa81b 130 }
el13kz 4:47b0473fa81b 131
el13kz 4:47b0473fa81b 132 void pressure(){
el13kz 4:47b0473fa81b 133
el13kz 4:47b0473fa81b 134 lcd.clear();
el13kz 4:47b0473fa81b 135
el13kz 4:47b0473fa81b 136 Measurement measurement; // measurement structure declared in BMP180 class
el13kz 4:47b0473fa81b 137 while(1) {
el13kz 4:47b0473fa81b 138
el13kz 4:47b0473fa81b 139 // read values (T in Celsius and P in mb) and print over serial port
el13kz 4:47b0473fa81b 140 measurement = bmp180.readValues();
el13kz 4:47b0473fa81b 141 serial.printf("T = %.2f C P = %.2f mb\n",measurement.temperature,measurement.pressure);
el13kz 4:47b0473fa81b 142
el13kz 4:47b0473fa81b 143 char buffer[14]; // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)
el13kz 4:47b0473fa81b 144 // so can display a string of a maximum 14 characters in length
el13kz 4:47b0473fa81b 145 // or create formatted strings - ensure they aren't more than 14 characters long
el13kz 4:47b0473fa81b 146
el13kz 4:47b0473fa81b 147 //
el13kz 4:47b0473fa81b 148 float pressure = measurement.pressure; // same idea with floats
el13kz 4:47b0473fa81b 149 length = sprintf(buffer,"P = %.2f mb",pressure);
el13kz 4:47b0473fa81b 150 if (length <= 14)
el13kz 4:47b0473fa81b 151 lcd.printString(buffer,0,2);
el13kz 4:47b0473fa81b 152
el13kz 4:47b0473fa81b 153
el13kz 4:47b0473fa81b 154
el13kz 4:47b0473fa81b 155
el13kz 4:47b0473fa81b 156 void altitude(){ // creating a new reading from the current ones, this appoximates the altitude in metres.
el13kz 4:47b0473fa81b 157
el13kz 4:47b0473fa81b 158 lcd.clear();
el13kz 4:47b0473fa81b 159
el13kz 4:47b0473fa81b 160 Measurement measurement; // measurement structure declared in BMP180 class
el13kz 4:47b0473fa81b 161
el13kz 4:47b0473fa81b 162 while(1){
el13kz 4:47b0473fa81b 163 // read values (T in Celsius and P in mb) and print over serial port
el13kz 4:47b0473fa81b 164 measurement = bmp180.readValues();
el13kz 4:47b0473fa81b 165 char buffer[14];
el13kz 4:47b0473fa81b 166 int temperature = measurement.temperature;
el13kz 4:47b0473fa81b 167 float pressure = measurement.pressure; // same idea with floats
el13kz 4:47b0473fa81b 168
el13kz 4:47b0473fa81b 169 float altitude = -(log(pressure/1013.25)*1.38e-23*temperature)/(9.81*28.95);
el13kz 4:47b0473fa81b 170 serial.printf("A = %.2f m",altitude);
el13kz 4:47b0473fa81b 171 int length = sprintf(buffer,"A = %.2f m",altitude); // print formatted data to buffer
el13kz 4:47b0473fa81b 172 // it is important the format specifier ensures the length will fit in the buffer
el13kz 4:47b0473fa81b 173 if (length <= 14) // if string wi
el13kz 4:47b0473fa81b 174 lcd.printString(buffer,0,1); // display on screen
el13kz 4:47b0473fa81b 175
el13kz 4:47b0473fa81b 176
el13kz 4:47b0473fa81b 177
el13kz 4:47b0473fa81b 178
el13kz 4:47b0473fa81b 179 }
el13kz 4:47b0473fa81b 180
el13kz 4:47b0473fa81b 181 }
el13kz 2:635c58eb70fb 182 //pushbutton - 0
el13kz 0:771a5148e8e7 183
el13kz 2:635c58eb70fb 184 //plots graph of temperature point by point
el13kz 0:771a5148e8e7 185 void graph()
el13kz 4:47b0473fa81b 186 {lcd.clear();
el13kz 4:47b0473fa81b 187
el13kz 0:771a5148e8e7 188 Measurement measurement; // measurement structure declared in BMP180 class
el13kz 0:771a5148e8e7 189 int i = 0;
el13kz 0:771a5148e8e7 190 float graph[84]= {0};
el13kz 0:771a5148e8e7 191 while(1) {
el13kz 0:771a5148e8e7 192
el13kz 0:771a5148e8e7 193 // read values (T in Celsius and P in mb) and print over serial port
el13kz 0:771a5148e8e7 194 measurement = bmp180.readValues();
el13kz 0:771a5148e8e7 195 //serial.printf("T = %.2f C P = %.2f mb\n",measurement.temperature,measurement.pressure);
el13kz 0:771a5148e8e7 196
el13kz 0:771a5148e8e7 197 // so can display a string of a maximum 14 characters in length
el13kz 0:771a5148e8e7 198 // or create formatted strings - ensure they aren't more than 14 characters long
el13kz 0:771a5148e8e7 199 int temperature = measurement.temperature;
el13kz 0:771a5148e8e7 200 // int length = sprintf(buffer,"T = %2d C",temperature); // print formatted data to buffer
el13kz 0:771a5148e8e7 201 // it is important the format specifier ensures the length will fit in the buffer
el13kz 0:771a5148e8e7 202 // if (length <= 14) // if string will fit on display
el13kz 0:771a5148e8e7 203 // lcd.printString(buffer,0,1); // display on screen
el13kz 0:771a5148e8e7 204 //
el13kz 0:771a5148e8e7 205 // float pressure = measurement.pressure; // same idea with floats
el13kz 0:771a5148e8e7 206 // length = sprintf(buffer,"P = %.2f mb",pressure);
el13kz 0:771a5148e8e7 207 // if (length <= 14)
el13kz 0:771a5148e8e7 208 // lcd.printString(buffer,0,2);
el13kz 0:771a5148e8e7 209
el13kz 0:771a5148e8e7 210 graph[i]= temperature ;
el13kz 0:771a5148e8e7 211 lcd.plotArray(graph);
el13kz 0:771a5148e8e7 212 wait(0.1); // short delay until next reading
el13kz 0:771a5148e8e7 213 i++;
el13kz 0:771a5148e8e7 214 if (i>83) {
el13kz 0:771a5148e8e7 215 i=0;
el13kz 0:771a5148e8e7 216 lcd.clear();
el13kz 0:771a5148e8e7 217 }
el13kz 0:771a5148e8e7 218 }
el13kz 0:771a5148e8e7 219 }
el13kz 0:771a5148e8e7 220
el13kz 4:47b0473fa81b 221
el13kz 4:47b0473fa81b 222
el13kz 4:47b0473fa81b 223
el13kz 4:47b0473fa81b 224
el13kz 4:47b0473fa81b 225 void measurementsScreen()
el13kz 4:47b0473fa81b 226 {lcd.clear();
el13kz 4:47b0473fa81b 227 lcd.printString("Hold Button!",1,1);//select measure menu
el13kz 4:47b0473fa81b 228 wait(1);
el13kz 4:47b0473fa81b 229 lcd.clear();
el13kz 0:771a5148e8e7 230 selectedOption = 0;
el13kz 0:771a5148e8e7 231
el13kz 4:47b0473fa81b 232 while(1) {
el13kz 0:771a5148e8e7 233
el13kz 2:635c58eb70fb 234 lcd.drawRect(70,6,10,10,1);
el13kz 2:635c58eb70fb 235 lcd.drawRect(70,21,10,10,0);
el13kz 0:771a5148e8e7 236
el13kz 4:47b0473fa81b 237 lcd.printString("temperature",1,1);
el13kz 2:635c58eb70fb 238 lcd.printString(">",62,1);
el13kz 2:635c58eb70fb 239 selectedOption = 1;
el13kz 4:47b0473fa81b 240 if (pushbutton1)
el13kz 4:47b0473fa81b 241 break;
el13kz 0:771a5148e8e7 242 wait(2);
el13kz 0:771a5148e8e7 243 lcd.clear();
el13kz 0:771a5148e8e7 244
el13kz 2:635c58eb70fb 245 lcd.drawRect(70,6,10,10,0);
el13kz 2:635c58eb70fb 246 lcd.drawRect(70,21,10,10,1);
el13kz 4:47b0473fa81b 247 lcd.printString("altitude",1,3);
el13kz 2:635c58eb70fb 248 lcd.printString(">",62,3);
el13kz 2:635c58eb70fb 249 selectedOption = 2;
el13kz 4:47b0473fa81b 250 if (pushbutton1)
el13kz 4:47b0473fa81b 251 break;
el13kz 4:47b0473fa81b 252 wait(2);
el13kz 4:47b0473fa81b 253 lcd.clear();
el13kz 0:771a5148e8e7 254
el13kz 4:47b0473fa81b 255 lcd.drawRect(70,6,10,10,0);
el13kz 4:47b0473fa81b 256 lcd.drawRect(70,21,10,10,1);
el13kz 4:47b0473fa81b 257 lcd.printString("pressure",1,3);
el13kz 4:47b0473fa81b 258 lcd.printString(">",62,3);
el13kz 4:47b0473fa81b 259 selectedOption = 2;
el13kz 4:47b0473fa81b 260 if (pushbutton1)
el13kz 4:47b0473fa81b 261 break;
el13kz 0:771a5148e8e7 262 wait(2);
el13kz 0:771a5148e8e7 263 lcd.clear();
el13kz 2:635c58eb70fb 264
el13kz 2:635c58eb70fb 265 }
el13kz 2:635c58eb70fb 266
el13kz 2:635c58eb70fb 267 if(selectedOption == 1) {
el13kz 0:771a5148e8e7 268
el13kz 4:47b0473fa81b 269 pressure();
el13kz 2:635c58eb70fb 270 }
el13kz 2:635c58eb70fb 271
el13kz 2:635c58eb70fb 272 if(selectedOption == 2) {
el13kz 2:635c58eb70fb 273
el13kz 4:47b0473fa81b 274 temperature();
el13kz 2:635c58eb70fb 275
el13kz 2:635c58eb70fb 276 }
el13kz 4:47b0473fa81b 277
el13kz 4:47b0473fa81b 278 if(selectedOption == 3) {
el13kz 4:47b0473fa81b 279
el13kz 4:47b0473fa81b 280 altitude();
el13kz 4:47b0473fa81b 281 }
el13kz 4:47b0473fa81b 282
el13kz 4:47b0473fa81b 283
el13kz 0:771a5148e8e7 284 }
el13kz 0:771a5148e8e7 285
el13kz 0:771a5148e8e7 286 void introScreen()
el13kz 0:771a5148e8e7 287 {
el13kz 0:771a5148e8e7 288
el13kz 0:771a5148e8e7 289 lcd.printString("Welcome to",15,1);
el13kz 0:771a5148e8e7 290 lcd.printString("Keiarash's",20,2);
el13kz 0:771a5148e8e7 291 lcd.printString("Multi-Sensor",6,3);
el13kz 2:635c58eb70fb 292 Redled= 1.0;
el13kz 0:771a5148e8e7 293
el13kz 0:771a5148e8e7 294
el13kz 0:771a5148e8e7 295 }
el13kz 0:771a5148e8e7 296
el13kz 4:47b0473fa81b 297
el13kz 4:47b0473fa81b 298 void extrasScreen()
el13kz 4:47b0473fa81b 299 {lcd.clear();
el13kz 4:47b0473fa81b 300 lcd.printString("Hold Button!",1,1);//select measure menu
el13kz 4:47b0473fa81b 301 wait(1);
el13kz 4:47b0473fa81b 302 lcd.clear();
el13kz 4:47b0473fa81b 303 selectedOption = 0;
el13kz 4:47b0473fa81b 304
el13kz 4:47b0473fa81b 305 while(1) {
el13kz 4:47b0473fa81b 306
el13kz 4:47b0473fa81b 307 lcd.drawRect(70,6,10,10,1);
el13kz 4:47b0473fa81b 308 lcd.drawRect(70,21,10,10,0);
el13kz 4:47b0473fa81b 309
el13kz 4:47b0473fa81b 310 lcd.printString("check",1,1);
el13kz 4:47b0473fa81b 311 lcd.printString(">",62,1);
el13kz 4:47b0473fa81b 312 selectedOption = 1;
el13kz 4:47b0473fa81b 313 if (pushbutton1)
el13kz 4:47b0473fa81b 314 break;
el13kz 4:47b0473fa81b 315 wait(2);
el13kz 4:47b0473fa81b 316 lcd.clear();
el13kz 4:47b0473fa81b 317
el13kz 4:47b0473fa81b 318 lcd.drawRect(70,6,10,10,0);
el13kz 4:47b0473fa81b 319 lcd.drawRect(70,21,10,10,1);
el13kz 4:47b0473fa81b 320 lcd.printString("go back",1,3);
el13kz 4:47b0473fa81b 321 lcd.printString(">",62,3);
el13kz 4:47b0473fa81b 322 selectedOption = 2;
el13kz 4:47b0473fa81b 323 if (pushbutton1)
el13kz 4:47b0473fa81b 324 break;
el13kz 4:47b0473fa81b 325 wait(2);
el13kz 4:47b0473fa81b 326 lcd.clear();
el13kz 4:47b0473fa81b 327
el13kz 4:47b0473fa81b 328 }
el13kz 4:47b0473fa81b 329
el13kz 4:47b0473fa81b 330 if(selectedOption == 1) {
el13kz 4:47b0473fa81b 331
el13kz 4:47b0473fa81b 332 lcd.clear();
el13kz 4:47b0473fa81b 333 }
el13kz 4:47b0473fa81b 334
el13kz 4:47b0473fa81b 335 if(selectedOption == 2) {
el13kz 4:47b0473fa81b 336
el13kz 4:47b0473fa81b 337 lcd.clear();
el13kz 4:47b0473fa81b 338
el13kz 4:47b0473fa81b 339 }
el13kz 4:47b0473fa81b 340 }
el13kz 4:47b0473fa81b 341
el13kz 4:47b0473fa81b 342
el13kz 4:47b0473fa81b 343
el13kz 0:771a5148e8e7 344 void mainScreen()
el13kz 0:771a5148e8e7 345 {
el13kz 4:47b0473fa81b 346
el13kz 4:47b0473fa81b 347 lcd.printString("Hold Button!",1,1);//select measure menu
el13kz 4:47b0473fa81b 348
el13kz 4:47b0473fa81b 349 wait(1);
el13kz 4:47b0473fa81b 350 lcd.clear();
el13kz 4:47b0473fa81b 351
el13kz 0:771a5148e8e7 352 selectedOption = 0;
el13kz 0:771a5148e8e7 353
el13kz 4:47b0473fa81b 354 while(1) {//initialse pushbutton as 0
el13kz 2:635c58eb70fb 355
el13kz 2:635c58eb70fb 356 //check boxes-options to be selected
el13kz 2:635c58eb70fb 357 lcd.drawRect(70,6,10,10,1);//check box 1
el13kz 2:635c58eb70fb 358 lcd.drawRect(70,21,10,10,0);//check box 2
el13kz 2:635c58eb70fb 359 lcd.drawRect(70,37,10,10,0);//check box 3
el13kz 0:771a5148e8e7 360
el13kz 2:635c58eb70fb 361 //option titles-appropriate to check boxes
el13kz 4:47b0473fa81b 362 lcd.printString("extras",1,1);//select measure menu
el13kz 4:47b0473fa81b 363 lcd.printString("graph",1,3);//select settings menu
el13kz 4:47b0473fa81b 364 lcd.printString("measure",1,5);//select grpah plot
el13kz 2:635c58eb70fb 365 lcd.printString(">",62,1);//pointer
el13kz 0:771a5148e8e7 366 selectedOption = 1;
el13kz 4:47b0473fa81b 367 if (pushbutton1)
el13kz 4:47b0473fa81b 368 break;
el13kz 0:771a5148e8e7 369
el13kz 0:771a5148e8e7 370 wait(2);
el13kz 0:771a5148e8e7 371 lcd.clear();
el13kz 0:771a5148e8e7 372
el13kz 0:771a5148e8e7 373 lcd.drawRect(70,6,10,10,0);
el13kz 0:771a5148e8e7 374 lcd.drawRect(70,21,10,10,1);
el13kz 0:771a5148e8e7 375 lcd.drawRect(70,37,10,10,0);
el13kz 0:771a5148e8e7 376
el13kz 0:771a5148e8e7 377
el13kz 4:47b0473fa81b 378 lcd.printString("extras",1,1);
el13kz 4:47b0473fa81b 379 lcd.printString("graph",1,3);
el13kz 4:47b0473fa81b 380 lcd.printString("measure",1,5);
el13kz 0:771a5148e8e7 381 lcd.printString(">",62,3);
el13kz 0:771a5148e8e7 382 selectedOption = 2;
el13kz 4:47b0473fa81b 383 if (pushbutton1)
el13kz 4:47b0473fa81b 384 break;
el13kz 4:47b0473fa81b 385
el13kz 0:771a5148e8e7 386
el13kz 0:771a5148e8e7 387 wait(2);
el13kz 0:771a5148e8e7 388 lcd.clear();
el13kz 0:771a5148e8e7 389
el13kz 0:771a5148e8e7 390 lcd.drawRect(70,6,10,10,0);
el13kz 0:771a5148e8e7 391 lcd.drawRect(70,21,10,10,0);
el13kz 0:771a5148e8e7 392 lcd.drawRect(70,37,10,10,1);
el13kz 0:771a5148e8e7 393
el13kz 0:771a5148e8e7 394
el13kz 4:47b0473fa81b 395 lcd.printString("extras",1,1);
el13kz 4:47b0473fa81b 396 lcd.printString("graph",1,3);
el13kz 4:47b0473fa81b 397 lcd.printString("measure",1,5);
el13kz 0:771a5148e8e7 398 lcd.printString(">",62,5);
el13kz 0:771a5148e8e7 399 selectedOption = 3;
el13kz 4:47b0473fa81b 400 if (pushbutton1)
el13kz 4:47b0473fa81b 401 break;
el13kz 4:47b0473fa81b 402
el13kz 0:771a5148e8e7 403
el13kz 0:771a5148e8e7 404 wait(2);
el13kz 0:771a5148e8e7 405 lcd.clear();
el13kz 0:771a5148e8e7 406
el13kz 0:771a5148e8e7 407
el13kz 0:771a5148e8e7 408 }
el13kz 2:635c58eb70fb 409
el13kz 2:635c58eb70fb 410 if(selectedOption == 1) {
el13kz 2:635c58eb70fb 411
el13kz 4:47b0473fa81b 412 measurementsScreen();
el13kz 2:635c58eb70fb 413 }
el13kz 2:635c58eb70fb 414
el13kz 2:635c58eb70fb 415 if(selectedOption == 2) {
el13kz 2:635c58eb70fb 416
el13kz 4:47b0473fa81b 417 extrasScreen();
el13kz 2:635c58eb70fb 418 }
el13kz 2:635c58eb70fb 419
el13kz 2:635c58eb70fb 420 if(selectedOption == 3) {
el13kz 2:635c58eb70fb 421
el13kz 2:635c58eb70fb 422 graph();
el13kz 2:635c58eb70fb 423 }
el13kz 0:771a5148e8e7 424 }
el13kz 0:771a5148e8e7 425
el13kz 0:771a5148e8e7 426
el13kz 0:771a5148e8e7 427
el13kz 0:771a5148e8e7 428
el13kz 0:771a5148e8e7 429
el13kz 0:771a5148e8e7 430
el13kz 0:771a5148e8e7 431
el13kz 2:635c58eb70fb 432
el13kz 2:635c58eb70fb 433
el13kz 4:47b0473fa81b 434
el13kz 2:635c58eb70fb 435
el13kz 2:635c58eb70fb 436 //main loop
el13kz 0:771a5148e8e7 437 int main()
el13kz 0:771a5148e8e7 438 {
el13kz 2:635c58eb70fb 439 pushbutton1.mode(PullUp);//initial value 0
el13kz 0:771a5148e8e7 440 // initiliase barometer
el13kz 0:771a5148e8e7 441 bmp180.init();
el13kz 2:635c58eb70fb 442
el13kz 0:771a5148e8e7 443 lcd.init();
el13kz 0:771a5148e8e7 444 introScreen();
el13kz 0:771a5148e8e7 445 wait(3);
el13kz 2:635c58eb70fb 446 Redled =0;
el13kz 0:771a5148e8e7 447 lcd.clear();
el13kz 0:771a5148e8e7 448 mainScreen();
el13kz 0:771a5148e8e7 449
el13kz 2:635c58eb70fb 450 while(1) {
el13kz 4:47b0473fa81b 451 introScreen();
el13kz 4:47b0473fa81b 452 wait(3);
el13kz 4:47b0473fa81b 453 Redled =0;
el13kz 4:47b0473fa81b 454 lcd.clear();
el13kz 4:47b0473fa81b 455 mainScreen();
el13kz 4:47b0473fa81b 456
el13kz 4:47b0473fa81b 457
el13kz 4:47b0473fa81b 458
el13kz 2:635c58eb70fb 459 }
el13kz 2:635c58eb70fb 460 }