natsu tsumagari
/
test_cadenceClass
回転数計のクラスです。
Diff: main.cpp
- Revision:
- 4:2def7f5f7fed
- Parent:
- 3:0986b5d80ded
- Child:
- 5:871c2d6c1129
diff -r 0986b5d80ded -r 2def7f5f7fed main.cpp --- a/main.cpp Wed Nov 23 13:59:26 2016 +0000 +++ b/main.cpp Fri Jan 27 14:10:44 2017 +0000 @@ -1,25 +1,37 @@ #include "mbed.h" -#include "Cadence.h" -//#include <string> DigitalOut myled(LED1); Ticker cadenceTicker; -Serial pc(USBTX,USBRX); //for debug +Serial pc(USBTX,USBRX);//for debug -Cadence cadence(p13,p14); +#include "Cadence.h" +Cadence ar(p13,p14); int main() { - pc.baud(115200); +// ar.format(8, Serial::None, 1); + ar.baud(115200); while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + pc.printf("data:"); + ar.readData(); + pc.printf("\n\r"); + for(int i = 0; i<75; i++){ + if(ar.data[i] == '\r') { + pc.putc('!'); + continue; + }else if(ar.data[i] == '\n'){ + pc.putc('$'); + continue; + } + pc.printf("%c",ar.data[i]); + } pc.printf("test\n\r"); - pc.printf("cadence: %f\n\r",cadence.cadence); - pc.printf("%s\n\r",cadence.strC); - pc.printf("voltage: %f\n\r",cadence.cadenceV); - cadence.readData(); - pc.printf("'%c!\n\r",cadence.strData[0]); + pc.printf("cadence: %d\n\r",ar.cadence); + pc.printf("voltage: %d\n\r",ar.voltage); + pc.printf("strC:"); + for(int i=0; i<4; i++) pc.printf("%c",ar.strC[i]); + pc.printf("\n\rstrV:"); + for(int i=0; i<4; i++) pc.printf("%c",ar.strV[i]); + pc.printf("\n\r"); +// pc.printf("'%s'\n\r",ar.strC.c_str()); } -} \ No newline at end of file +}