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
sensor.cpp
00001 #include "mbed.h" 00002 #include "x_nucleo_iks01a1.h" 00003 #include <vector> 00004 #include "sensor.h" 00005 #include "userMethods.h" 00006 00007 // Queue 00008 00009 00010 //std::vector<log_data> ExpansionBoard::v; 00011 int * ExpansionBoard::n; 00012 bool ExpansionBoard::flag; 00013 00014 // This is the consumer 00015 00016 void ExpansionBoard::getData(const void*) 00017 {/* 00018 00019 while(true) { 00020 //Block on queue if no data is available 00021 osEvent event = queue.get(2000); 00022 if(flag) { 00023 printf("MAIL_BOX.GET\n"); 00024 } 00025 00026 if (event.status == osEventMail) { 00027 // Successful, store log_data 00028 log_data* temp = (log_data*) event.value.p; 00029 v.push_back(*temp); 00030 if(flag) { 00031 printf("GET value stored and freed up mail_box\n"); 00032 } 00033 } 00034 }*/ 00035 } 00036 00037 00038 // Helper function for printing floats & doubles 00039 char *ExpansionBoard::printDouble(char* str, double v, int decimalDigits) 00040 { 00041 int intPart, fractPart, len, i=1; 00042 char *ptr; 00043 for (; decimalDigits!=0; i*=10, decimalDigits--); 00044 intPart = (int)v; 00045 fractPart = (int)((v-(double)(int)v)*i); 00046 sprintf(str, "%i.", intPart); 00047 len = strlen(str); 00048 ptr = &str[len]; 00049 for (i/=10; i>1; i/=10, ptr++) { 00050 if(fractPart >= i) break; 00051 *ptr = '0'; 00052 } 00053 sprintf(ptr, "%i", fractPart); 00054 return str; 00055 } 00056 00057 // Constructor for the class 00058 ExpansionBoard::ExpansionBoard(int num, bool lFlag): T(15.0f) 00059 { 00060 n = # 00061 flag = &lFlag; 00062 00063 /* Retrieve the composing elements of the expansion board */ 00064 printf("Initialising expansion board...\n\r"); 00065 }
Generated on Fri Jul 15 2022 17:35:06 by
1.7.2