Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MDDS30_oit.cpp@3:a64fd9b238c5, 2021-07-22 (annotated)
- Committer:
- okadaya
- Date:
- Thu Jul 22 01:06:29 2021 +0000
- Revision:
- 3:a64fd9b238c5
- Parent:
- 0:670c09433f11
- Child:
- 4:085a9c395959
rebuild library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| okadaya | 0:670c09433f11 | 1 | #include "MDDS30_oit.h" |
| okadaya | 0:670c09433f11 | 2 | |
| okadaya | 0:670c09433f11 | 3 | MDDS30oit::MDDS30oit(PinName _txpin, PinName _rxpin) : md(_txpin, _rxpin, 115200) |
| okadaya | 0:670c09433f11 | 4 | { |
| okadaya | 0:670c09433f11 | 5 | |
| okadaya | 0:670c09433f11 | 6 | direction=0; |
| okadaya | 0:670c09433f11 | 7 | leftfront=0; |
| okadaya | 0:670c09433f11 | 8 | rightfront=0; |
| okadaya | 0:670c09433f11 | 9 | leftback=0; |
| okadaya | 0:670c09433f11 | 10 | rightback=0; |
| okadaya | 0:670c09433f11 | 11 | |
| okadaya | 0:670c09433f11 | 12 | } |
| okadaya | 0:670c09433f11 | 13 | |
| okadaya | 0:670c09433f11 | 14 | void MDDS30oit::lefttire(float speed){ |
| okadaya | 0:670c09433f11 | 15 | speed=speed*63.0f; |
| okadaya | 3:a64fd9b238c5 | 16 | if(speed>0){ |
| okadaya | 3:a64fd9b238c5 | 17 | direction=(word2<<1)|0; |
| okadaya | 3:a64fd9b238c5 | 18 | } |
| okadaya | 3:a64fd9b238c5 | 19 | else{ |
| okadaya | 3:a64fd9b238c5 | 20 | direction=(word2<<1)|1; |
| okadaya | 3:a64fd9b238c5 | 21 | } |
| okadaya | 0:670c09433f11 | 22 | leftfront=(direction<<6)|(int)speed; |
| okadaya | 0:670c09433f11 | 23 | md.putc(leftfront); |
| okadaya | 0:670c09433f11 | 24 | // r=r|31; |
| okadaya | 0:670c09433f11 | 25 | // pc.printf("%d\n",leftfront); |
| okadaya | 0:670c09433f11 | 26 | } |
| okadaya | 0:670c09433f11 | 27 | |
| okadaya | 0:670c09433f11 | 28 | void MDDS30oit::righttire(float speed){ |
| okadaya | 0:670c09433f11 | 29 | speed=speed*63.0f; |
| okadaya | 3:a64fd9b238c5 | 30 | if(speed>0){ |
| okadaya | 3:a64fd9b238c5 | 31 | direction=(word<<1)|0; |
| okadaya | 3:a64fd9b238c5 | 32 | } |
| okadaya | 3:a64fd9b238c5 | 33 | else{ |
| okadaya | 3:a64fd9b238c5 | 34 | direction=(word<<1)|1; |
| okadaya | 3:a64fd9b238c5 | 35 | } |
| okadaya | 0:670c09433f11 | 36 | rightfront=(direction<<6)|(int)speed; |
| okadaya | 3:a64fd9b238c5 | 37 | md.putc(rightfront); |
| okadaya | 0:670c09433f11 | 38 | // r=r|31; |
| okadaya | 0:670c09433f11 | 39 | // pc.printf("%d\n",rightfront); |
| okadaya | 0:670c09433f11 | 40 | } |