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.
Fork of m3pi by
Revision 9:d2449eb32198, committed 2018-05-09
- Comitter:
- bertgereels
- Date:
- Wed May 09 15:35:12 2018 +0000
- Parent:
- 7:9b128cebb3c2
- Commit message:
- LineFollower + VLC Decoder
Changed in this revision
m3pi.cpp | Show annotated file Show diff for this revision Revisions of this file |
m3pi.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9b128cebb3c2 -r d2449eb32198 m3pi.cpp --- a/m3pi.cpp Fri Mar 25 15:44:52 2011 +0000 +++ b/m3pi.cpp Wed May 09 15:35:12 2018 +0000 @@ -112,6 +112,24 @@ return(fpos); } +void m3pi::get_raw_values(unsigned int *values) +{ + while (_ser.readable() ) { // flush buffer + _ser.getc(); + } + + char vals[10]; // array to receive 10 byte return message + _ser.putc(0x86); // send command + + for (int i=0; i < 10; i++) { + vals[i] = _ser.getc(); + } + + for(int i=0; i<5; i++) { // construct the 2-byte values + values[i] = (vals[2*i+1] << 8) | vals[2*i]; + } +} + char m3pi::sensor_auto_calibrate() { _ser.putc(AUTO_CALIBRATE); return(_ser.getc());
diff -r 9b128cebb3c2 -r d2449eb32198 m3pi.h --- a/m3pi.h Fri Mar 25 15:44:52 2011 +0000 +++ b/m3pi.h Wed May 09 15:35:12 2018 +0000 @@ -163,6 +163,11 @@ * 1.0 means the line is on the right */ float line_position (void); + + /** Read raw sensor values from IR sensors (0 - 2000) + * @param values - array of size 5 to store values + */ + void get_raw_values(unsigned int *values); /** Calibrate the sensors. This turns the robot left then right, looking for a line