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.
Dependents: 3pi_Example_2 3pi_Lab1_Task2_Example1 3pi_Lab2_Task1_Example1 3pi_Line_Follow ... more
Diff: m3pi.h
- Revision:
- 2:26bf14f4dc84
- Parent:
- 1:5523d6d1feec
- Child:
- 3:5015bc2d1cf8
--- a/m3pi.h Wed Apr 05 10:25:42 2017 +0000
+++ b/m3pi.h Fri Apr 07 18:22:35 2017 +0000
@@ -73,19 +73,12 @@
*/
void reset_calibration();
- /** Returns estimate of line position
- * @returns int in the range -2000 to 2000
- * @details -2000 for line under sensor 0, -1000 for line under sensor 1
- * @details 0 for line under sensor 2, 1000 for line under sensor 3 etc.
- */
- int get_line_position();
-
/** Returns estimate of normalised line position
* @returns float in the range -1.0 to 1.0
* @details -1.0 for line under sensor 0, -0.5 for line under sensor 1
* @details 0.0 for line under sensor 2, 0.5 for line under sensor 3 etc.
*/
- float get_normalised_line_position();
+ float get_line_position();
/** Clear LCD
*/
@@ -163,6 +156,25 @@
* @param y - line on LCD to display
*/
void display_signature(int x,int y);
+
+ /** Display sensor values on LCD
+ * @param values - array of calibrated sensor values
+ * @param y - line on LCD to display
+ */
+ void display_sensor_values(unsigned int values[],int y);
+
+ /** Gets value of sensor array expressed as decimal number
+ * @details Each sensor is a bit (PC4 is bit 0, PC0 is bit 5)
+ * @returns value - 5-bit value of sensor reading
+ */
+ unsigned int get_sensor_array_value(unsigned int values[]);
+
+ /** Calculates an estimate of normalised line position from the sensor readings
+ * @returns float in the range -1.0 to 1.0
+ * @details -1.0 for line under sensor 0, -0.5 for line under sensor 1
+ * @details 0.0 for line under sensor 2, 0.5 for line under sensor 3 etc.
+ */
+ float calc_line_position(unsigned int values[]);
private:
@@ -170,6 +182,8 @@
DigitalOut* _reset;
DigitalIn* _button;
BusOut* _leds;
+
+ float _last_line_position;
void reset();