natsu tsumagari
/
test_cadenceClass
回転数計のクラスです。
main.cpp@5:871c2d6c1129, 2017-01-28 (annotated)
- Committer:
- tsumagari
- Date:
- Sat Jan 28 01:07:59 2017 +0000
- Revision:
- 5:871c2d6c1129
- Parent:
- 4:2def7f5f7fed
- Child:
- 6:93f90c5d0e5b
sscanf??????????int??????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tsumagari | 0:57308daf8dfe | 1 | #include "mbed.h" |
tsumagari | 0:57308daf8dfe | 2 | |
tsumagari | 0:57308daf8dfe | 3 | DigitalOut myled(LED1); |
tsumagari | 0:57308daf8dfe | 4 | Ticker cadenceTicker; |
tsumagari | 4:2def7f5f7fed | 5 | Serial pc(USBTX,USBRX);//for debug |
tsumagari | 0:57308daf8dfe | 6 | |
tsumagari | 4:2def7f5f7fed | 7 | #include "Cadence.h" |
tsumagari | 4:2def7f5f7fed | 8 | Cadence ar(p13,p14); |
tsumagari | 0:57308daf8dfe | 9 | |
tsumagari | 0:57308daf8dfe | 10 | int main() { |
tsumagari | 4:2def7f5f7fed | 11 | // ar.format(8, Serial::None, 1); |
tsumagari | 4:2def7f5f7fed | 12 | ar.baud(115200); |
tsumagari | 0:57308daf8dfe | 13 | while(1) { |
tsumagari | 4:2def7f5f7fed | 14 | pc.printf("data:"); |
tsumagari | 4:2def7f5f7fed | 15 | ar.readData(); |
tsumagari | 4:2def7f5f7fed | 16 | pc.printf("\n\r"); |
tsumagari | 4:2def7f5f7fed | 17 | for(int i = 0; i<75; i++){ |
tsumagari | 4:2def7f5f7fed | 18 | if(ar.data[i] == '\r') { |
tsumagari | 4:2def7f5f7fed | 19 | pc.putc('!'); |
tsumagari | 4:2def7f5f7fed | 20 | continue; |
tsumagari | 4:2def7f5f7fed | 21 | }else if(ar.data[i] == '\n'){ |
tsumagari | 4:2def7f5f7fed | 22 | pc.putc('$'); |
tsumagari | 4:2def7f5f7fed | 23 | continue; |
tsumagari | 4:2def7f5f7fed | 24 | } |
tsumagari | 4:2def7f5f7fed | 25 | pc.printf("%c",ar.data[i]); |
tsumagari | 4:2def7f5f7fed | 26 | } |
tsumagari | 0:57308daf8dfe | 27 | pc.printf("test\n\r"); |
tsumagari | 5:871c2d6c1129 | 28 | pc.printf("cadence:%4.2f\n\r",ar.cadence); |
tsumagari | 5:871c2d6c1129 | 29 | pc.printf("voltage:%4.2f\n\r",ar.voltage); |
tsumagari | 4:2def7f5f7fed | 30 | pc.printf("strC:"); |
tsumagari | 4:2def7f5f7fed | 31 | for(int i=0; i<4; i++) pc.printf("%c",ar.strC[i]); |
tsumagari | 4:2def7f5f7fed | 32 | pc.printf("\n\rstrV:"); |
tsumagari | 4:2def7f5f7fed | 33 | for(int i=0; i<4; i++) pc.printf("%c",ar.strV[i]); |
tsumagari | 4:2def7f5f7fed | 34 | pc.printf("\n\r"); |
tsumagari | 4:2def7f5f7fed | 35 | // pc.printf("'%s'\n\r",ar.strC.c_str()); |
tsumagari | 0:57308daf8dfe | 36 | } |
tsumagari | 4:2def7f5f7fed | 37 | } |