dotHR_URG
Dependencies: FatFileSystem TextLCD mbed
Revision 2:22b200c374cd, committed 2015-09-29
- Comitter:
- higedura
- Date:
- Tue Sep 29 02:00:59 2015 +0000
- Parent:
- 1:52d3136e1a22
- Commit message:
- 150929_URG
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 52d3136e1a22 -r 22b200c374cd main.cpp --- a/main.cpp Wed Dec 05 13:56:13 2012 +0000 +++ b/main.cpp Tue Sep 29 02:00:59 2015 +0000 @@ -11,12 +11,15 @@ DigitalOut led3(LED3); DigitalOut led4(LED4); Serial pc(USBTX, USBRX); // tx, rx -SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board +//SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board Serial navi(p13, p14); // tx, rx -DigitalIn stop(p17); // button (green) +DigitalIn stop(p12); // button (green) Serial urg(p28, p27); // tx, rx //TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7 +// Local file system +//LocalFileSystem local("local"); + void send_to_navi(); int iaf_delta = 500; @@ -56,7 +59,7 @@ double i_pow = 0; - pc.baud(921600); + pc.baud(115200); navi.baud(115200); urg.baud(19200); @@ -65,27 +68,24 @@ pow2[i] = pow(2,i_pow); }; + //FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing + // Waiting start up URG //lcd.cls(); //lcd.printf("Waiting start up URG"); pc.printf("\n\r\n\rWaiting start up URG\n\r"); - led1 = 1; led2 = 1; led3 = 1; led4 = 1; - wait(.5); led4 = 0; - wait(.5); led3 = 0; - wait(.5); led2 = 0; - wait(.5); led1 = 0; + led1 = 1; + wait(2); // SCIP 1.0 --> SCIP 2.0 //lcd.cls(); //lcd.printf("SCIP 2.0"); pc.printf("SCIP 2.0\n\r"); for( int i=0;i<8;i++ ){ urg.putc(SCIP2[i]); } + //for( int i=0;i<8;i++ ){ pc.putc(SCIP2[i]); } // Waiting SCIP 2.0 - led1 = 1; led2 = 1; led3 = 1; led4 = 1; - wait(.5); led4 = 0; - wait(.5); led3 = 0; - wait(.5); led2 = 0; - wait(.5); led1 = 0; + led2 = 1; + wait(2); // Changing baudrate //lcd.cls(); @@ -93,14 +93,10 @@ pc.printf("Changing baudrate\n\r"); for( int i=0;i<9;i++ ){ urg.putc(SS1152[i]); } urg.baud(115200); - led1 = 1; led2 = 1; led3 = 1; led4 = 1; - wait(.5); led4 = 0; - wait(.5); led3 = 0; - wait(.5); led2 = 0; - wait(.5); led1 = 0; + led3 = 1; + wait(2); // Getting data - led1 = 1; led4 = 1; //lcd.cls(); //lcd.printf("Getting data ..."); pc.printf("Getting data ...\n\r\n\r"); @@ -114,9 +110,21 @@ if( c_urg_data[0]==aLF && c_urg_data[1]==aLF ){ flag = 1; } for( int i=0;i<2;i++ ){ c_urg_data[i+1] = c_urg_data[i]; } } + + // For test /* + char buf_char; + while(1){ + buf_char = urg.getc(); + pc.printf("%c", buf_char); + } + */ + + led4 = 1; + //while(1){ while( stop==0 ){ + //for(int iLoop=0;iLoop<3;iLoop++){ c_urg_data[2] = c_urg_data[1]; c_urg_data[1] = c_urg_data[0]; @@ -166,7 +174,12 @@ if( iaf_delta>800 ){ iaf_delta = 800; } if( iaf_delta<200 ){ iaf_delta = 200; } - + //for(int i=0;i<682;i++){ fprintf(fp, "%5d ", urg_depth[i]); } + //fprintf(fp, "\n\r"); + for(int i=0;i<682;i++){ pc.printf("%5d ", urg_depth[i]); } + pc.printf("\n\r"); + wait(3); + // Initialization for( int i=0;i<682;i++ ){ urg_depth[i] = 0; } iaf_SR_print = iaf_SR; @@ -177,5 +190,11 @@ } } - */ + + //fclose(fp); + led1 = 0; + led2 = 0; + led3 = 0; + led4 = 0; + }