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
main.cpp@11:3b5e035ffef9, 2018-01-21 (annotated)
- Committer:
- rattokiller
- Date:
- Sun Jan 21 20:40:24 2018 +0000
- Revision:
- 11:3b5e035ffef9
- Parent:
- 9:7f0c1261e905
programma con scrittura sd con concorenza
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:bdbd3d6fc5d5 | 1 | #include "mbed.h" |
NdA994 | 2:f59bd5312559 | 2 | #include "setting.h" |
rattokiller | 11:3b5e035ffef9 | 3 | #define f_campionamento 100 // se va male 50 |
rattokiller | 11:3b5e035ffef9 | 4 | #define debug |
rattokiller | 11:3b5e035ffef9 | 5 | |
NdA994 | 3:3b2b8b0955f9 | 6 | DigitalIn mybutton(USER_BUTTON); |
rattokiller | 11:3b5e035ffef9 | 7 | Ticker accelerometro; |
rattokiller | 11:3b5e035ffef9 | 8 | Thread thread; |
rattokiller | 11:3b5e035ffef9 | 9 | Timer tempo; |
rattokiller | 11:3b5e035ffef9 | 10 | float temp; |
rattokiller | 11:3b5e035ffef9 | 11 | int n=0; |
rattokiller | 11:3b5e035ffef9 | 12 | void simula_dati(){ |
rattokiller | 11:3b5e035ffef9 | 13 | |
rattokiller | 11:3b5e035ffef9 | 14 | ax=n++ /100.0; |
rattokiller | 11:3b5e035ffef9 | 15 | ay=4.56; |
rattokiller | 11:3b5e035ffef9 | 16 | az=-4.358; |
rattokiller | 11:3b5e035ffef9 | 17 | //prelivevo dei dati fatto in tempo |
rattokiller | 11:3b5e035ffef9 | 18 | float t=tempo.read(); |
rattokiller | 11:3b5e035ffef9 | 19 | if((t-temp)>1.0/(2*f_campionamento))pc.printf("problema"); |
rattokiller | 11:3b5e035ffef9 | 20 | temp=t; |
rattokiller | 11:3b5e035ffef9 | 21 | invia_m(1000*ax+4000,1000*ay+4000,1000*az+4000,0,0,0); |
rattokiller | 11:3b5e035ffef9 | 22 | } |
rattokiller | 11:3b5e035ffef9 | 23 | |
mbed_official | 0:bdbd3d6fc5d5 | 24 | int main() { |
NdA994 | 3:3b2b8b0955f9 | 25 | init(); |
NdA994 | 3:3b2b8b0955f9 | 26 | initFile(); |
rattokiller | 11:3b5e035ffef9 | 27 | |
rattokiller | 11:3b5e035ffef9 | 28 | //initAccellerometro(); |
NdA994 | 3:3b2b8b0955f9 | 29 | aperturaFile(); |
NdA994 | 9:7f0c1261e905 | 30 | |
rattokiller | 11:3b5e035ffef9 | 31 | tempo.reset(); |
rattokiller | 11:3b5e035ffef9 | 32 | tempo.start(); |
rattokiller | 11:3b5e035ffef9 | 33 | temp=0; |
rattokiller | 11:3b5e035ffef9 | 34 | accelerometro.attach(&raccoltaDati,1.0/f_campionamento); |
rattokiller | 11:3b5e035ffef9 | 35 | |
rattokiller | 11:3b5e035ffef9 | 36 | thread.start(callback(scrivi_m)); |
rattokiller | 11:3b5e035ffef9 | 37 | |
NdA994 | 9:7f0c1261e905 | 38 | |
NdA994 | 9:7f0c1261e905 | 39 | while(1){ |
rattokiller | 11:3b5e035ffef9 | 40 | Thread::wait(0.01); |
rattokiller | 11:3b5e035ffef9 | 41 | if (mybutton) { |
rattokiller | 11:3b5e035ffef9 | 42 | |
rattokiller | 11:3b5e035ffef9 | 43 | invia_m(65535,65535,65535,65535,65535,65535); |
rattokiller | 11:3b5e035ffef9 | 44 | |
rattokiller | 11:3b5e035ffef9 | 45 | Thread::wait(2); |
NdA994 | 4:58e4283f9a59 | 46 | } |
NdA994 | 4:58e4283f9a59 | 47 | |
rattokiller | 11:3b5e035ffef9 | 48 | |
NdA994 | 3:3b2b8b0955f9 | 49 | } |
mbed_official | 0:bdbd3d6fc5d5 | 50 | } |