test program for MPL3115A2
Dependencies: C12832 LM75B MPL3115A2 mbed
Diff: main.cpp
- Revision:
- 2:ef315a40af7b
- Parent:
- 1:4870f310b921
- Child:
- 3:cb376fbf96dd
--- a/main.cpp Thu May 18 06:32:59 2017 +0000
+++ b/main.cpp Wed Nov 22 09:27:32 2017 +0000
@@ -1,20 +1,31 @@
#include "mbed.h"
+#include "LM75B.h"
#include "MSS.h"
#include "MPL3115A2.h"
#define MPL3115A2_I2C_ADDRESS (0x60)
+Serial pc(USBTX,USBRX);
+
+#include "C12832.h"
+C12832 lcd(p5, p7, p6, p8, p11);
+LM75B sensor(p28,p27);
+MPL3115A2 mpl(PIN_SDA, PIN_SCL, MPL3115A2_I2C_ADDRESS) ;
+
int main() {
double alt, bar, temp ;
- MPL3115A2 mpl(PIN_SDA, PIN_SCL, MPL3115A2_I2C_ADDRESS) ;
+ mpl.setBarIn((unsigned short)(101800/2));
- printf("=== test MPL3115A2 for %s (%s) ===\n",BOARD_NAME, __DATE__) ;
- printf("Altitude(m), Pressure(hPa), Temperature(c)\n") ;
+ sensor.open();
while(1) {
alt = mpl.getAltitude() ;
bar = mpl.getPressure() ;
temp = mpl.getTemperature() ;
- printf("%6.2f, %6.2f, %6.2f\n",alt, bar, temp) ;
+ lcd.cls();
+ lcd.locate(0,1);
+ lcd.printf("ALTI, BAR, TEMP",alt, bar, temp) ;
+ lcd.locate(0,10);
+ lcd.printf("%5.2f, %5.2f, %5.2f %5.3f",alt, bar, temp,sensor.temp()) ;
wait(1) ;
}
}