trabalho

Dependencies:   X_NUCLEO_IKS01A1 mbed-rtos mbed

Fork of HelloWorld_IKS01A1 by ST

Committer:
stwykd
Date:
Sun May 08 08:37:33 2016 +0000
Revision:
26:71c54c8ae536
Parent:
25:55c0dc5b32b3
Child:
28:840000670c88
Created a buffer and finished implementing expansion board.; There's missing to send the data to the buffer just after reading on readData. You can copy and paste buffer.cpp to mailbox.cpp, or continue buffer.cpp as a mailbox

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nlsantos 12:7ef8061de189 1 #include "mbed.h"
nlsantos 12:7ef8061de189 2 #include "rtos.h"
stwykd 24:527fdf64cbb0 3 #include <time.h>
stwykd 25:55c0dc5b32b3 4 //#include <main.cpp>
nlsantos 12:7ef8061de189 5
Jacinta 18:bf6578e82712 6 class MailBox{
nlsantos 12:7ef8061de189 7
Jacinta 18:bf6578e82712 8 public:
Jacinta 18:bf6578e82712 9 typedef struct {
Jacinta 18:bf6578e82712 10 uint8_t id;
Jacinta 18:bf6578e82712 11 float tempCelcius;
Jacinta 18:bf6578e82712 12 float tempFarenheit;
Jacinta 18:bf6578e82712 13 float humidity;
Jacinta 18:bf6578e82712 14 float pressure;
Jacinta 18:bf6578e82712 15 int accelerometer;
Jacinta 18:bf6578e82712 16 int gyroscope;
Jacinta 18:bf6578e82712 17 int magnetometer;
stwykd 24:527fdf64cbb0 18 char* date;
Jacinta 18:bf6578e82712 19 } log_data;
Jacinta 18:bf6578e82712 20
Jacinta 18:bf6578e82712 21 Mail<log_data, 120> mail_box;
Jacinta 18:bf6578e82712 22
Jacinta 18:bf6578e82712 23 void send_thread (log_data newLog) {
Jacinta 18:bf6578e82712 24 while (true) {
Jacinta 18:bf6578e82712 25 log_data *log = mail_box.alloc();
Jacinta 18:bf6578e82712 26 log->tempCelcius = newLog.tempCelcius;
Jacinta 18:bf6578e82712 27 log->tempFarenheit = newLog.tempFarenheit;
Jacinta 18:bf6578e82712 28 log->humidity = newLog.humidity;
Jacinta 18:bf6578e82712 29 log->pressure = newLog.pressure;
Jacinta 18:bf6578e82712 30 log->accelerometer = newLog.accelerometer;
Jacinta 18:bf6578e82712 31 log->gyroscope = newLog.gyroscope;
Jacinta 18:bf6578e82712 32 log->magnetometer = newLog.magnetometer;
stwykd 24:527fdf64cbb0 33
stwykd 24:527fdf64cbb0 34 //TODO I get a weird error because of include <main>
stwykd 24:527fdf64cbb0 35 //You need that to include t
stwykd 24:527fdf64cbb0 36 //Not solved it yet, but you can do it by moving t or something
stwykd 24:527fdf64cbb0 37 //For the date represetation, that statement does it
stwykd 25:55c0dc5b32b3 38 //log->date = asctime(&t);
Jacinta 18:bf6578e82712 39
Jacinta 18:bf6578e82712 40 mail_box.put(log);
Jacinta 18:bf6578e82712 41 Thread::wait(1000);
Jacinta 18:bf6578e82712 42 }
nlsantos 12:7ef8061de189 43 }
Jacinta 18:bf6578e82712 44 };
nlsantos 12:7ef8061de189 45