trabalho final
Dependencies: X_NUCLEO_IKS01A1-f255a2c75ecb mbed-rtos mbed
sensor.cpp
- Committer:
- Jacinta
- Date:
- 2016-05-18
- Revision:
- 37:886dcde018ad
- Parent:
- 35:34bbca276f99
File content as of revision 37:886dcde018ad:
#include "mbed.h" #include "x_nucleo_iks01a1.h" #include <vector> #include "sensor.h" #include "userMethods.h" // Queue //std::vector<log_data> ExpansionBoard::v; int * ExpansionBoard::n; bool ExpansionBoard::flag; // This is the consumer void ExpansionBoard::getData(const void*) {/* while(true) { //Block on queue if no data is available osEvent event = queue.get(2000); if(flag) { printf("MAIL_BOX.GET\n"); } if (event.status == osEventMail) { // Successful, store log_data log_data* temp = (log_data*) event.value.p; v.push_back(*temp); if(flag) { printf("GET value stored and freed up mail_box\n"); } } }*/ } // Helper function for printing floats & doubles char *ExpansionBoard::printDouble(char* str, double v, int decimalDigits) { int intPart, fractPart, len, i=1; char *ptr; for (; decimalDigits!=0; i*=10, decimalDigits--); intPart = (int)v; fractPart = (int)((v-(double)(int)v)*i); sprintf(str, "%i.", intPart); len = strlen(str); ptr = &str[len]; for (i/=10; i>1; i/=10, ptr++) { if(fractPart >= i) break; *ptr = '0'; } sprintf(ptr, "%i", fractPart); return str; } // Constructor for the class ExpansionBoard::ExpansionBoard(int num, bool lFlag): T(15.0f) { n = # flag = &lFlag; /* Retrieve the composing elements of the expansion board */ printf("Initialising expansion board...\n\r"); }