hosei2
Dependencies: FatFileSystem MSCFileSystem SCP1000 mbed
main.cpp@0:927b64c12d0c, 2017-02-08 (annotated)
- Committer:
- hosei2
- Date:
- Wed Feb 08 10:31:26 2017 +0000
- Revision:
- 0:927b64c12d0c
ver1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hosei2 | 0:927b64c12d0c | 1 | #include "mbed.h" |
hosei2 | 0:927b64c12d0c | 2 | #include "SCP1000.h" |
hosei2 | 0:927b64c12d0c | 3 | #include "MSCFileSystem.h" |
hosei2 | 0:927b64c12d0c | 4 | Serial pc(USBTX,USBRX); ///// connect to PC |
hosei2 | 0:927b64c12d0c | 5 | DigitalOut sp1(p10); |
hosei2 | 0:927b64c12d0c | 6 | DigitalOut L1(LED1); |
hosei2 | 0:927b64c12d0c | 7 | DigitalOut L2(LED2); |
hosei2 | 0:927b64c12d0c | 8 | DigitalOut L3(LED3); |
hosei2 | 0:927b64c12d0c | 9 | DigitalOut L4(LED4); |
hosei2 | 0:927b64c12d0c | 10 | #define FSNAME "msc" |
hosei2 | 0:927b64c12d0c | 11 | MSCFileSystem msc(FSNAME); |
hosei2 | 0:927b64c12d0c | 12 | FILE *USB_fp; |
hosei2 | 0:927b64c12d0c | 13 | int main() |
hosei2 | 0:927b64c12d0c | 14 | { |
hosei2 | 0:927b64c12d0c | 15 | pc.printf("\n\nMBED START UP\n\n"); |
hosei2 | 0:927b64c12d0c | 16 | pc.printf("3\n"); |
hosei2 | 0:927b64c12d0c | 17 | L4=1; |
hosei2 | 0:927b64c12d0c | 18 | int L1_mode,L2_mode,L3_mode,L4_mode; |
hosei2 | 0:927b64c12d0c | 19 | pc.printf("2\n"); |
hosei2 | 0:927b64c12d0c | 20 | L3=1; |
hosei2 | 0:927b64c12d0c | 21 | SCP1000 scp1000(p11, p12, p13, p14 , SCP1000::HIGH_SPEED_MODE ); |
hosei2 | 0:927b64c12d0c | 22 | scp1000.setOperationMode(SCP1000::HIGH_SPEED_MODE); |
hosei2 | 0:927b64c12d0c | 23 | float scp_pressure,scp_temperature; |
hosei2 | 0:927b64c12d0c | 24 | float bscp_pressure,bscp_temperature; |
hosei2 | 0:927b64c12d0c | 25 | float ascp_pressure,ascp_temperature; |
hosei2 | 0:927b64c12d0c | 26 | pc.printf("1\n"); |
hosei2 | 0:927b64c12d0c | 27 | L2=1; |
hosei2 | 0:927b64c12d0c | 28 | char totaldata[512]; |
hosei2 | 0:927b64c12d0c | 29 | int i=0; |
hosei2 | 0:927b64c12d0c | 30 | pc.printf("READY GO!\n\n"); |
hosei2 | 0:927b64c12d0c | 31 | pc.printf("0\n"); |
hosei2 | 0:927b64c12d0c | 32 | L1=1; |
hosei2 | 0:927b64c12d0c | 33 | while(1) |
hosei2 | 0:927b64c12d0c | 34 | { |
hosei2 | 0:927b64c12d0c | 35 | scp_pressure = scp1000.readPressure(); |
hosei2 | 0:927b64c12d0c | 36 | scp_temperature = scp1000.readTemperature(); |
hosei2 | 0:927b64c12d0c | 37 | L1_mode=L1; L2_mode=L2; |
hosei2 | 0:927b64c12d0c | 38 | L3_mode=L3; L4_mode=L4; |
hosei2 | 0:927b64c12d0c | 39 | ascp_pressure=bscp_pressure*0.9+scp_pressure*0.1; |
hosei2 | 0:927b64c12d0c | 40 | ascp_temperature=bscp_temperature*0.9+scp_temperature*0.1; |
hosei2 | 0:927b64c12d0c | 41 | sprintf(totaldata,"%d,%f,%f,%d,%f,%f,%d,%d,%d,%d\n", |
hosei2 | 0:927b64c12d0c | 42 | i,scp_pressure, scp_temperature,i,ascp_pressure,ascp_temperature, |
hosei2 | 0:927b64c12d0c | 43 | L1_mode,L2_mode,L3_mode,L4_mode); |
hosei2 | 0:927b64c12d0c | 44 | pc.printf("%d,%f,%f,%d,%f,%f,%d,%d,%d,%d\n", |
hosei2 | 0:927b64c12d0c | 45 | i,scp_pressure, scp_temperature,i,ascp_pressure,ascp_temperature, |
hosei2 | 0:927b64c12d0c | 46 | L1_mode,L2_mode,L3_mode,L4_mode); |
hosei2 | 0:927b64c12d0c | 47 | i++; |
hosei2 | 0:927b64c12d0c | 48 | bscp_pressure=ascp_pressure; |
hosei2 | 0:927b64c12d0c | 49 | bscp_temperature=ascp_temperature; |
hosei2 | 0:927b64c12d0c | 50 | if(sizeof(i)>0) |
hosei2 | 0:927b64c12d0c | 51 | { |
hosei2 | 0:927b64c12d0c | 52 | USB_fp = fopen( "/" FSNAME "/data.txt", "a"); |
hosei2 | 0:927b64c12d0c | 53 | if ( USB_fp != NULL ) fprintf(USB_fp, "%s\r\n",totaldata); |
hosei2 | 0:927b64c12d0c | 54 | fclose(USB_fp); |
hosei2 | 0:927b64c12d0c | 55 | } |
hosei2 | 0:927b64c12d0c | 56 | L1=0;L2=0;L3=0;L4=0; |
hosei2 | 0:927b64c12d0c | 57 | if(i%4==0) {L1=1;} |
hosei2 | 0:927b64c12d0c | 58 | else if(i%4==1){L2=1;} |
hosei2 | 0:927b64c12d0c | 59 | else if(i%4==2){L3=1;} |
hosei2 | 0:927b64c12d0c | 60 | else if(i%4==3){L4=1;} |
hosei2 | 0:927b64c12d0c | 61 | } |
hosei2 | 0:927b64c12d0c | 62 | |
hosei2 | 0:927b64c12d0c | 63 | } |