A Weather station designed to read the values of temperature and pressure from the sensor (BMP180), data displayed via a nokia N5110 display.
Dependencies: BMP180 N5110 PowerControl mbed
Diff: Barometer.cpp
- Revision:
- 26:c0d8d2f68406
- Parent:
- 25:fa65a9cc78f0
- Child:
- 27:06fbad36c15e
--- a/Barometer.cpp Sat May 09 15:38:36 2015 +0000 +++ b/Barometer.cpp Mon May 11 10:12:22 2015 +0000 @@ -198,10 +198,12 @@ thresholdCheck(); strncpy(buffer1, bufferTime, 14); strncpy(buffer2, bufferDate, 14); - strncpy(buffer3, bufferT, 14); - strncpy(buffer4, bufferP, 14); + sprintf (buffer3, "T: %s", bufferT); + sprintf (buffer4, "P: %s", bufferP); + //strncpy(buffer3, bufferT, 14); +// strncpy(buffer4, bufferP, 14); int dispaly = sprintf (buffer5, "");//convert integer to buffer str - int dispaly1 = sprintf (buffer0, "");//convert integer to buffer str + int dispaly1 = sprintf (buffer0, " Live Data");//convert integer to buffer str display(); } yellowLED = 0; @@ -265,7 +267,7 @@ //send the arrays above to the local file saveToFile(temperatureSent,pressureSent,timeSent,dateSent); - //serial.printf ("sent temp %s\nsent pressure %s\nsent time %s\nsent date %s\n",temperatureSent,pressureSent,timeSent,dateSent); + serial.printf ("sent temperatures %s\nsent pressures %s\nsent time %s\nsent date %s\n",temperatureSent,pressureSent,timeSent,dateSent); //reads the saved data back from the local file @@ -273,7 +275,7 @@ fscanf (pFileb, "%s\n %s\n %s\n %s\n", temperatureRecieved,pressureRecieved,timeRecieved,dateRecieved); fclose (pFileb); - //serial.printf ("rec temp %s\nrec pressure %s\nrec time %s\nrec date %s\n",temperatureRecieved,pressureRecieved,timeRecieved,dateRecieved); + serial.printf ("recieved temperatures %s\nrecieved pressure %s\nrecieved time %s\nrecieved date %s\n",temperatureRecieved,pressureRecieved,timeRecieved,dateRecieved); //seperates the array into tokens(seperated after the delimiter , ) @@ -316,8 +318,8 @@ for (k = 0 ; k<p ; k++) { // loops through the arrays - // printf("arrayT = %lf\n",arrayT[k]); - // printf("arrayP = %lf\n",arrayP[k]); + printf("seperated temperature array = %lf\n",arrayT[k]); + printf("seperated pressure array = %lf\n",arrayP[k]); if (unitFlag==1 || unitFlag==2 ) { //c @@ -455,7 +457,7 @@ void thresholdCheck() { if (thresholdAlarmFlag) { - thresholdAlarmFlag = 1; + thresholdAlarmFlag = 0; if (int(temperature) <= fsmH[0].output) { //if the current temp is less than the set threshold while (1) { redLED = 0 ; @@ -469,7 +471,7 @@ for (int i=0; i<=11; i++) { buzzer.period(1/(frequency[i])); // set PWM period buzzer=0.5; // set duty cycle - //wait(0.5); // hold for beat period + wait(0.5); // hold for beat period redLED = 1 ; if (button3Flag) { buzzer = 0 ; @@ -493,7 +495,7 @@ for (int i=0; i<=11; i++) { buzzer.period(1/(frequency[i])); // set PWM period buzzer=0.5; // set duty cycle - //wait(0.5); // hold for beat period + wait(0.5); // hold for beat period redLED = 1 ; if (button3Flag) { buzzer = 0 ; @@ -574,12 +576,12 @@ - int display0 = sprintf (buffer0, " Back Save");//convert integer to buffer str + int display0 = sprintf (buffer0, "Set thresholds");//convert integer to buffer str int display1 = sprintf (buffer1, "");//convert integer to buffer str int display2 = sprintf (buffer2, "");//convert integer to buffer str int display3 = sprintf (buffer3, ">>%s %d", fsmH[state].title,fsmH[state].output);//convert integer to buffer str int display4 = sprintf (buffer4, "");//convert integer to buffer str - int display5 = sprintf (buffer5, "");//convert integer to buffer str + int display5 = sprintf (buffer5, " Back Save");//convert integer to buffer str display(); @@ -715,12 +717,12 @@ loggerData(); - int display0 = sprintf (buffer0, " Back Save");//convert integer to buffer str + int display0 = sprintf (buffer0, "Set Alarm");//convert integer to buffer str int display1 = sprintf (buffer1, "");//convert integer to buffer str int display2 = sprintf (buffer2, "" );//convert integer to buffer str int display3 = sprintf (buffer3, ">>%s %d", fsmC[state].title,fsmC[state].output);//convert integer to buffer str int display4 = sprintf (buffer4, "" );//convert integer to buffer str - int display5 = sprintf (buffer5, "" );//convert integer to buffer str + int display5 = sprintf (buffer5, " Back Save" );//convert integer to buffer str @@ -819,12 +821,12 @@ powerSaverCheck(); updateTime(); loggerData(); - int display0 = sprintf (buffer0, " Back Next"); + int display0 = sprintf (buffer0, " Alarms"); int display1 = sprintf (buffer1, ""); int display2 = sprintf (buffer2, ""); int display3 = sprintf (buffer3, ">>%s", fsmF[state].title); int display4 = sprintf (buffer4, ""); - int display5 = sprintf (buffer5, ""); + int display5 = sprintf (buffer5, " Back Next"); display(); @@ -884,7 +886,7 @@ powerSaverCheck(); updateTime(); loggerData(); - sprintf (buffer0, " Back Save"); + sprintf (buffer0, ""); sprintf (buffer1, ""); sprintf (buffer2, "Data Logger"); sprintf (buffer3, ">>%s", fsmE[state].title); @@ -893,7 +895,7 @@ } else { // if the power saver is off it doesnt show the time sprintf (buffer4, ""); } - sprintf (buffer5, ""); + sprintf (buffer5, " Back Save"); display(); @@ -961,7 +963,7 @@ powerSaverCheck(); updateTime(); loggerData(); - sprintf (buffer0, " Back Save"); + sprintf (buffer0, ""); sprintf (buffer1, ""); sprintf (buffer2, "Power Saver"); sprintf (buffer3, ">>%s", fsmE[state].title); @@ -970,7 +972,7 @@ } else { // if the power saver is off it dowsnt show the time sprintf (buffer4, ""); } - sprintf (buffer5, ""); + sprintf (buffer5, "Back Save"); display(); @@ -1055,12 +1057,12 @@ updateTime(); loggerData(); - sprintf (buffer0, " Back Save");//convert integer to buffer str + sprintf (buffer0, "Set Units");//convert integer to buffer str sprintf (buffer1, "");//convert integer to buffer str sprintf (buffer2, "");//convert integer to buffer str sprintf (buffer3, ">>%s", fsmD[state].title);//convert integer to buffer str sprintf (buffer4, "");//convert integer to buffer str - sprintf (buffer5, "");//convert integer to buffer str + sprintf (buffer5, " Back Save");//convert integer to buffer str unitFlag = fsmD[state].output; @@ -1101,12 +1103,12 @@ updateTime(); loggerData(); - sprintf (buffer0, " Back Save");//convert integer to buffer str + sprintf (buffer0, "Set Time/Date");//convert integer to buffer str sprintf (buffer1, ""); sprintf (buffer2, ""); sprintf (buffer3, ">>%s %d", fsmC[state].title,fsmC[state].output);//convert integer to buffer str sprintf (buffer4, ""); - sprintf (buffer5, ""); + sprintf (buffer5, "Back Save"); display(); @@ -1304,6 +1306,7 @@ button2.rise(&button2Pressed); button3.rise(&button3Pressed); button4.rise(&button4Pressed); + debounce.start(); /// Set frequency at 40kHz for the leds redLED.period_us(25);