Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BMP180 N5110 mbed
Diff: main.cpp
- Revision:
- 2:6b564e388747
- Parent:
- 1:1accd82f4281
- Child:
- 3:c9162dc9ba24
--- a/main.cpp Thu Apr 30 12:32:57 2015 +0000
+++ b/main.cpp Thu Apr 30 15:35:35 2015 +0000
@@ -17,6 +17,8 @@
int nx=84;
int ny=48;
int i,j;
+float temperature;
+float pressure;
void clearCells();
@@ -37,6 +39,7 @@
while(1){
if (timerTFlag){
timerTFlag=0;
+ Measurement measurement;
clearCells();
char bufferT[14];
measurement = bmp180.readValues();
@@ -52,6 +55,7 @@
while(1){
if (timerPFlag){
timerPFlag=0;
+ Measurement measurement;
clearCells();
char bufferP[14];
measurement = bmp180.readValues();
@@ -63,9 +67,48 @@
}
}
+void measurement(){
+ Measurement measurement;
+ measurement=bmp180.readValues();
+ temperature=measurement.temperature;
+ pressure=measurement.pressure;
+}
+
+void tempGraph(){
+ int j=0; //start graph on left hand side of screen
+ while(1){
+ if (timerTFlag){
+ timerTFlag=0;
+ clearCells();
+ float tempArray[84]; //create array of temperature values
+ measurement(); //read in the measured values of temperature
+ tempArray[j]=(temperature/47);
+ j++; //add one to j so that the next point plotted moves across the screen by one pixel
+ lcd.plotArray(tempArray); //plot the array
+ wait(0.1); //wait one second before plotting the next point
+ }
+ }
+}
+
+void pressGraph(){
+ int j=0;
+ while(1){
+ if (timerPFlag){
+ timerPFlag=0;
+ clearCells();
+ float pressArray[84];
+ measurement();
+ pressArray[j]=(pressure/1100);
+ j++;
+ lcd.plotArray(pressArray);
+ }
+ }
+}
+
void menu()
{
while(1) {
+ wait (0.1);
lcd.normalMode(); //normal LCD colour mode
lcd.setBrightness(0.5); //LCD backlight set to 50% brightness
if (POT>(2.0/3.0)) {
@@ -76,7 +119,7 @@
lcd.printString("Current",43,5);
if (BUT1>0.9) { //left button takes the user to the graph option
clearCells();
- //tempGraph();
+ tempGraph();
}
if (BUT2>0.9) { //right button takes the user to the current reading
clearCells();
@@ -92,7 +135,7 @@
lcd.printString("Current",43,5);
if (BUT1>0.9) {
clearCells();
- //pressGraph();
+ pressGraph();
}
if (BUT2>0.9) {
clearCells();
@@ -131,8 +174,7 @@
int main(){
lcd.init();
bmp180.init();
- timer.attach(&timerTExpired,60);
- timer.attach(&timerPExpired,1800);
- Measurement measurement;
+ timerT.attach(&timerTExpired,60);
+ timerP.attach(&timerPExpired,1800);
menu();
}
\ No newline at end of file