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.
Diff: m3pi.cpp
- Revision:
- 9:074ce6197b51
- Parent:
- 8:92167bd3eb44
- Child:
- 10:0dec82280040
diff -r 92167bd3eb44 -r 074ce6197b51 m3pi.cpp
--- a/m3pi.cpp Wed Jul 05 14:39:33 2017 +0000
+++ b/m3pi.cpp Mon Mar 19 13:06:40 2018 +0000
@@ -9,10 +9,14 @@
_reset = new DigitalOut(p8);
_last_line_position = 0.0;
+ // initialise the arrays
_bar_graph[0] = ' ';
for (int i = 0; i < 6; i++) {
_bar_graph[i+1] = i;
}
+ for (int i = 0; i < 5; i++) {
+ _values[i]=0;
+ }
}
m3pi::~m3pi()
@@ -34,6 +38,10 @@
/////////////////////////////// serial slave commands ////////////////////////////////
+void m3pi::scan()
+{
+ get_calibrated_values(_values);
+}
void m3pi::get_signature(char *signature)
{
@@ -112,7 +120,6 @@
}
}
-
void m3pi::calibrate()
{
_serial->putc(0xB4);
@@ -302,6 +309,17 @@
}
+void m3pi::display_data()
+{
+ display_sensor_values(_values,1);
+
+ char buffer[8]={0};
+ sprintf(buffer,"% .3f",_last_line_position);
+ lcd_goto_xy(0,0);
+ lcd_print(buffer,6);
+
+}
+
unsigned int m3pi::get_sensor_array_value(unsigned int values[])
{
unsigned int value = 0;
@@ -350,6 +368,11 @@
return _last_line_position;
}
+float m3pi::read_line() {
+ return calc_line_position(_values);
+}
+
+
/////////////////////////////// private methods ////////////////////////////////
void m3pi::reset()