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: ADXL362 MPL3115A2 mbed
Revision 4:eb81ef9e1621, committed 2018-04-05
- Comitter:
- jackclar
- Date:
- Thu Apr 05 14:43:37 2018 +0000
- Parent:
- 3:cbd71da3ccd4
- Commit message:
- Lab 9;
Changed in this revision
| ATParser.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ATParser.lib Thu Apr 05 14:43:37 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/teams/components/code/ATParser/#6b8190f55d83
--- a/main.cpp Fri Mar 09 01:11:50 2018 +0000
+++ b/main.cpp Thu Apr 05 14:43:37 2018 +0000
@@ -2,10 +2,14 @@
#include "MPL3115A2.h"
#include <string>
#include <math.h>
+#include <ATParser.h>
+#include "BufferedSerial.h"
-Serial pc(SERIAL_TX, SERIAL_RX);
+//Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut myled(LED1);
DigitalOut powerpin(PA_8); // GPIO pin
+BufferedSerial pc(SERIAL_TX, SERIAL_RX);
+BufferedSerial device(PA_9, PA_10);
// Selects SDA as I2C1_SDA on pin PB_7
// Selects SCL on I2C1_SCL on pin PB_6
@@ -22,8 +26,14 @@
myled = 0;
char c;
powerpin = 0;
+ ATParser at = ATParser(device, "\r\n", 256, 2000, false);
+ char buffer[100];
+ pc.baud(115200);
+ device.baud(115200);
double alt1 = pressure_sensor.getAltitude(), alt2; // initial alt
-
+
+ mpl3115_reg_print( 0, 0);
+
while ((id=pressure_sensor.getID())!=0xC4)// wait for the sensor to connect
{
wait(1);
@@ -31,22 +41,13 @@
while(1)
{
- if(powerpin) // if the GPIO pin is pulled high
+ if(pc.getc() == 's') // if the GPIO pin is pulled high
{
myled != myled;
//turn on and off led at 1Hz
p=pressure_sensor.getPressure();
t=pressure_sensor.getTemperature();
- alt2=pressure_sensor.getAltitude();
- v = (alt2 - alt1)/ 1.1;
- // velocity is just distance / time
- // we measured the time to be 1.1 seconds between readings
- // this is as fast as it will go because of the library we were given
- pc.printf("velocity = %f\n\r", v);
- alt1 = alt2;
-
- pc.printf("%f %f\n\r", t, p);
- cnt++;
+ at.send("Hello");
}
else
{