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: SDFileSystem_conMOD mbed-rtos mbed
Fork of f4_sd_imu_4 by
Diff: main.cpp
- Revision:
- 11:3b5e035ffef9
- Parent:
- 9:7f0c1261e905
--- a/main.cpp Wed Dec 13 21:08:45 2017 +0000 +++ b/main.cpp Sun Jan 21 20:40:24 2018 +0000 @@ -1,52 +1,50 @@ #include "mbed.h" #include "setting.h" -#include "lettoreSD.h" -#include "accellerometro.h" - +#define f_campionamento 100 // se va male 50 +#define debug + DigitalIn mybutton(USER_BUTTON); - +Ticker accelerometro; +Thread thread; +Timer tempo; +float temp; +int n=0; +void simula_dati(){ + + ax=n++ /100.0; + ay=4.56; + az=-4.358; + //prelivevo dei dati fatto in tempo + float t=tempo.read(); + if((t-temp)>1.0/(2*f_campionamento))pc.printf("problema"); + temp=t; + invia_m(1000*ax+4000,1000*ay+4000,1000*az+4000,0,0,0); +} + int main() { init(); initFile(); - initAccellerometro(); + + //initAccellerometro(); aperturaFile(); - Timer timer; + tempo.reset(); + tempo.start(); + temp=0; + accelerometro.attach(&raccoltaDati,1.0/f_campionamento); + + thread.start(callback(scrivi_m)); + while(1){ - - timer.start(); - raccoltaDati(); - //stampaFile("A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n"); - //fprintf(fp, "A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n"); - timer.stop(); - if(timer.read_ms()>10){ - int overTime = (timer.read_ms() / 10) + 1; - pc.printf("tempo: %d e overtime %d\n\r ", timer.read_ms(), overTime); - for (int i=0; i<overTime; i++){ - fprintf(fp,"#\n\r"); - } - } - else{ - wait_ms(10-timer.read_ms()); - //printf("tempo: %f\n\r", timer.read()); - } - timer.reset(); - if (mybutton == 0) { - //chiusuraFile(); - //aperturaFile(); - fprintf(fp, "###########FLAG MARCATORE PRESSIONE PULSANTE############\r\n"); - wait(1); + Thread::wait(0.01); + if (mybutton) { + + invia_m(65535,65535,65535,65535,65535,65535); + + Thread::wait(2); } - /*if(i%100==99){ - timer.stop(); - float tempo = 1 - timer.read(); - wait(tempo); - printf("tempo: %f\n\r", tempo + timer.read()); - timer.reset(); - timer.start(); - } - i++;*/ + } }