sdaffass
Dependencies: SDFileSystem_conMOD mbed-rtos mbed
Fork of ncola_f4_def_v2_def by
main.cpp@12:f5aae967c4d7, 2018-01-29 (annotated)
- Committer:
- NdA994
- Date:
- Mon Jan 29 13:31:16 2018 +0000
- Revision:
- 12:f5aae967c4d7
- Parent:
- 11:295d7cea3c7d
ruote foniche con binario;
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" |
NdA994 | 2:f59bd5312559 | 3 | #include "lettoreSD.h" |
NdA994 | 3:3b2b8b0955f9 | 4 | #include "accellerometro.h" |
NdA994 | 12:f5aae967c4d7 | 5 | #include "sd_binario.h" |
NdA994 | 3:3b2b8b0955f9 | 6 | |
NdA994 | 3:3b2b8b0955f9 | 7 | DigitalIn mybutton(USER_BUTTON); |
NdA994 | 3:3b2b8b0955f9 | 8 | |
mbed_official | 0:bdbd3d6fc5d5 | 9 | int main() { |
rattokiller | 11:295d7cea3c7d | 10 | int nad2,nas2; |
rattokiller | 11:295d7cea3c7d | 11 | pc.baud(921600); |
rattokiller | 11:295d7cea3c7d | 12 | pc.printf("ok"); |
rattokiller | 11:295d7cea3c7d | 13 | |
rattokiller | 11:295d7cea3c7d | 14 | trigger_ad.rise(&counta_giri_ad); //attach count() to interrupt on rising edge of trigger |
rattokiller | 11:295d7cea3c7d | 15 | trigger_as.rise(&counta_giri_as); //attach count() to interrupt on rising edge of trigger |
rattokiller | 11:295d7cea3c7d | 16 | |
NdA994 | 3:3b2b8b0955f9 | 17 | init(); |
NdA994 | 3:3b2b8b0955f9 | 18 | initFile(); |
rattokiller | 11:295d7cea3c7d | 19 | // initAccellerometro(); |
NdA994 | 3:3b2b8b0955f9 | 20 | aperturaFile(); |
NdA994 | 9:7f0c1261e905 | 21 | |
NdA994 | 3:3b2b8b0955f9 | 22 | Timer timer; |
NdA994 | 9:7f0c1261e905 | 23 | |
NdA994 | 9:7f0c1261e905 | 24 | while(1){ |
rattokiller | 11:295d7cea3c7d | 25 | nas2=nas; |
rattokiller | 11:295d7cea3c7d | 26 | nad2=nad; |
rattokiller | 11:295d7cea3c7d | 27 | nas=nad=0; |
NdA994 | 4:58e4283f9a59 | 28 | timer.start(); |
NdA994 | 12:f5aae967c4d7 | 29 | //fprintf(fp,"%d %.d\n\r",50*nad2/64.0,50*nas2/64.0); |
NdA994 | 12:f5aae967c4d7 | 30 | inviaMessaggio((char)(500*nad2/64.0), (char)(500*nas2/64.0)); |
NdA994 | 12:f5aae967c4d7 | 31 | |
NdA994 | 12:f5aae967c4d7 | 32 | |
rattokiller | 11:295d7cea3c7d | 33 | //fprintf(fp,"%.2f %.2f\n\r",50*nad/64.0,50*nas/64.0); |
NdA994 | 12:f5aae967c4d7 | 34 | pc.printf("%.2f %.2f\n\r",500*nad2/64.0, 500*nas2/64.0); |
rattokiller | 11:295d7cea3c7d | 35 | |
rattokiller | 11:295d7cea3c7d | 36 | //raccoltaDati(); |
NdA994 | 4:58e4283f9a59 | 37 | //stampaFile("A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n"); |
NdA994 | 9:7f0c1261e905 | 38 | //fprintf(fp, "A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n"); |
NdA994 | 4:58e4283f9a59 | 39 | timer.stop(); |
rattokiller | 11:295d7cea3c7d | 40 | if(timer.read_ms()>20){//non si tiene conto del tempo perso per scrive i dati |
NdA994 | 12:f5aae967c4d7 | 41 | int overTime = (timer.read_ms() / 20) + 1; |
NdA994 | 12:f5aae967c4d7 | 42 | pc.printf("tempo: %d e overtime %d\n\r ", timer.read_ms(), overTime); |
NdA994 | 9:7f0c1261e905 | 43 | for (int i=0; i<overTime; i++){ |
NdA994 | 12:f5aae967c4d7 | 44 | inviaMessaggio(255, 200); |
NdA994 | 9:7f0c1261e905 | 45 | } |
NdA994 | 4:58e4283f9a59 | 46 | } |
NdA994 | 4:58e4283f9a59 | 47 | else{ |
rattokiller | 11:295d7cea3c7d | 48 | wait_ms(20-timer.read_ms()); |
NdA994 | 9:7f0c1261e905 | 49 | //printf("tempo: %f\n\r", timer.read()); |
NdA994 | 4:58e4283f9a59 | 50 | } |
NdA994 | 4:58e4283f9a59 | 51 | timer.reset(); |
NdA994 | 4:58e4283f9a59 | 52 | if (mybutton == 0) { |
NdA994 | 9:7f0c1261e905 | 53 | //chiusuraFile(); |
NdA994 | 9:7f0c1261e905 | 54 | //aperturaFile(); |
NdA994 | 12:f5aae967c4d7 | 55 | inviaMessaggio(255, 255); |
NdA994 | 4:58e4283f9a59 | 56 | wait(1); |
NdA994 | 4:58e4283f9a59 | 57 | } |
NdA994 | 4:58e4283f9a59 | 58 | |
rattokiller | 11:295d7cea3c7d | 59 | |
NdA994 | 3:3b2b8b0955f9 | 60 | } |
mbed_official | 0:bdbd3d6fc5d5 | 61 | } |
rattokiller | 11:295d7cea3c7d | 62 | |
rattokiller | 11:295d7cea3c7d | 63 | |
rattokiller | 11:295d7cea3c7d | 64 | |
rattokiller | 11:295d7cea3c7d | 65 | |
rattokiller | 11:295d7cea3c7d | 66 |