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: X_NUCLEO_IKS01A1-f255a2c75ecb mbed-rtos mbed
Revision 7:ed4a10ebe720, committed 2016-05-15
- Comitter:
- Jacinta
- Date:
- Sun May 15 22:07:10 2016 +0000
- Parent:
- 6:d388428956b2
- Child:
- 9:ce395d75c0df
- Commit message:
- .......
Changed in this revision
--- a/main.cpp Sun May 15 14:34:31 2016 +0000
+++ b/main.cpp Sun May 15 22:07:10 2016 +0000
@@ -20,9 +20,9 @@
struct tm t = {t.tm_hour = 0};
std::vector<log_data> v;
-UserMethods u;
-ExpansionBoard e;
int n = 0;
+UserMethods u(v, n);
+ExpansionBoard e(v, n);
Thread *logThread;
Thread *getThread;
--- a/main.h Sun May 15 14:34:31 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-class main
-{
- public:
- vector<log_data> v;
- int n;
-};
-
-#endif
\ No newline at end of file
--- a/sensor.cpp Sun May 15 14:34:31 2016 +0000
+++ b/sensor.cpp Sun May 15 22:07:10 2016 +0000
@@ -3,9 +3,10 @@
#include <vector>
#include "sensor.h"
#include "userMethods.h"
-#include "main.h"
Mail<log_data, QUEUESIZE> ExpansionBoard::mail_box;
+vector<log_data> * ExpansionBoard::v;
+int * ExpansionBoard::n;
//This is the producer
void ExpansionBoard::sampleData() {
@@ -42,8 +43,7 @@
}
void ExpansionBoard::getData(const void*){
- main m;
- vector<log_data> v = m.v;
+
while(true){
//Block on queue if no data is available
osEvent event = mail_box.get();
@@ -52,7 +52,7 @@
if (event.status == osEventMail) {
// Successful, store log_data
log_data* temp = (log_data*) event.value.p;
- v.push_back(*temp);
+ v->push_back(*temp);
mail_box.free(temp);
printf("GET value stored and freed up mail_box\n");
}
@@ -77,8 +77,9 @@
return str;
}
-ExpansionBoard::ExpansionBoard(): T(15.0f)
-{
+ExpansionBoard::ExpansionBoard(vector<log_data> vector, int num): T(15.0f) {
+ v = &vector;
+ n = #
/* Retrieve the composing elements of the expansion board */
uint8_t id;
printf("Initialising expansion board...\n\r");
--- a/sensor.h Sun May 15 14:34:31 2016 +0000
+++ b/sensor.h Sun May 15 22:07:10 2016 +0000
@@ -1,5 +1,6 @@
#ifndef EXPANSIONBOARD_H
#define EXPANSIONBOARD_H
+
#include "rtos.h"
#include "log.h"
#include "x_nucleo_iks01a1.h"
@@ -22,12 +23,14 @@
class ExpansionBoard
{
public:
- ExpansionBoard();
+ ExpansionBoard(vector<log_data> vector, int num);
static void sampleData();
static void getData(const void*);
static Mail<log_data, QUEUESIZE> mail_box;
static char *ExpansionBoard::printDouble(char* str, double v, int decimalDigits);
- float T; //Default sampling rate, specified in specs
+ float T; //Default sampling rate, specified in specs
+ static vector<log_data> * v;
+ static int * n;
};
#endif
\ No newline at end of file
--- a/userMethods.cpp Sun May 15 14:34:31 2016 +0000
+++ b/userMethods.cpp Sun May 15 22:07:10 2016 +0000
@@ -4,12 +4,12 @@
#include <ctime>
#include <stdexcept>
#include <vector>
-#include "main.h"
+
+vector<log_data> * UserMethods::v;
+int * UserMethods::n;
void UserMethods::readAllData(const void*) {
- main m;
-
- vector<log_data> v = m.v;
+ vector<log_data> vector = *v;
printf("Entered in readAllData");
//TODO Serial not working
@@ -19,25 +19,29 @@
//.csv header
printf("Sample_Date,HTS221_Temp,LPS25H_Press,HTS221_Hum\n\r");
- for(int i = 0; i < v.size(); i++)
+ for(int i = 0; i < vector.size(); i++)
//TODO Add time here and read n
//.csv friendly format for logging
- printf("%s,%7s°C,%smbar,%s%%\n\r", ctime(&v[i].date), ExpansionBoard::printDouble(buffer, v[i].tempCelsius, 2),
- ExpansionBoard::printDouble(buffer, v[i].pressure, 2), ExpansionBoard::printDouble(buffer, v[i].humidity, 2));
+ printf("%s,%7s°C,%smbar,%s%%\n\r", ctime(&vector[i].date), ExpansionBoard::printDouble(buffer, vector[i].tempCelsius, 2),
+ ExpansionBoard::printDouble(buffer, vector[i].pressure, 2), ExpansionBoard::printDouble(buffer, vector[i].humidity, 2));
}
void UserMethods::readNData(const void*) {
- main m;
- vector<log_data> v = m.v;
- int n = m.n;
+ vector<log_data> vector = *v;
+ int num = *n;
//Serial pc(USBTX, USBRX);
//pc.baud(115200);
printf("Sample_Date,HTS221_Temp,LPS25H_Press,HTS221_Hum\n\r");
char buffer[32];
- for(int i = v.size()-n-1; i < v.size(); i++)
- printf("%s,%7s°C,%smbar,%s%%\n\r", ctime(&v[i].date), ExpansionBoard::printDouble(buffer, v[i].tempCelsius, 2),
- ExpansionBoard::printDouble(buffer, v[i].pressure, 2), ExpansionBoard::printDouble(buffer, v[i].humidity, 2));
+ for(int i = vector.size()-num-1; i < vector.size(); i++)
+ printf("%s,%7s°C,%smbar,%s%%\n\r", ctime(&vector[i].date), ExpansionBoard::printDouble(buffer, vector[i].tempCelsius, 2),
+ ExpansionBoard::printDouble(buffer, vector[i].pressure, 2), ExpansionBoard::printDouble(buffer, vector[i].humidity, 2));
}
-void UserMethods::logging(const void*) { return; }
\ No newline at end of file
+void UserMethods::logging(const void*) { return; }
+
+UserMethods::UserMethods(vector<log_data> vector, int num) {
+ v = &vector;
+ n = #
+}
\ No newline at end of file
--- a/userMethods.h Sun May 15 14:34:31 2016 +0000
+++ b/userMethods.h Sun May 15 22:07:10 2016 +0000
@@ -1,8 +1,8 @@
#ifndef USERMETHODS_H
#define USERMETHODS_H
+#include <vector>
#include "log.h"
-#include <vector>
using std::vector;
@@ -11,9 +11,12 @@
class UserMethods
{
public:
+ UserMethods(vector<log_data> vector, int num);
static void logging(const void*);
static void readAllData(const void*);
static void readNData(const void*);
+ static vector<log_data> * v;
+ static int * n;
};
#endif
\ No newline at end of file
