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.
Diff: lab7.cpp
- Revision:
- 12:bc83fa7d2de4
- Parent:
- 11:1bf881a206a4
--- a/lab7.cpp Thu Mar 08 15:17:51 2018 +0000
+++ b/lab7.cpp Fri Mar 09 16:21:46 2018 +0000
@@ -19,7 +19,7 @@
int collect_data();
-#define ARRAY_SIZE 50
+#define ARRAY_SIZE 5000
double *pressure_arr = (double *)malloc(sizeof(double) * ARRAY_SIZE);
double *temp_arr = (double *)malloc(sizeof(double) * ARRAY_SIZE);
double *pressPtr = pressure_arr;
@@ -39,11 +39,19 @@
while(1) {
// don't overflow buffer
- if(buffer_full >= ARRAY_SIZE)
- return 0;
+ if(buffer_full >= ARRAY_SIZE) {
+ printf("\n\n\tBuffer Full. Ending program.\n\n\r");
+ return(0);
+ }
+ /*int offset = 0;
+ for (int i = 0; i < buffer_full; i++) {
+ *(pressure_arr + offset) = 0;
+ *(temp_arr + offset) = 0;
+ offset += sizeof(double);
+ }*/
//printf("nooooope\n\r");
- if(startStop.read()) {
+ if(!startStop.read()) {
printf("GPIO Connectedn\r");
collect_data();
printf("done collecting\n\rarray size: %d,\t buffer fill: %d\n\r", ARRAY_SIZE, buffer_full);
@@ -296,7 +304,7 @@
int collect_data() {
int counter = 0;
// while GPIO is 1
- while(startStop.read()) {
+ while(!startStop.read()) {
// read temp and pressure data
*tempPtr = pressure_sensor.getTemperature();
*pressPtr = pressure_sensor.getPressure();