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: main.cpp
- Revision:
- 2:54d27fdcbe5c
- Parent:
- 1:23d0a615756a
- Child:
- 3:502f90649834
diff -r 23d0a615756a -r 54d27fdcbe5c main.cpp
--- a/main.cpp Fri Jul 31 17:37:52 2015 +0000
+++ b/main.cpp Sun Aug 02 18:34:12 2015 +0000
@@ -38,6 +38,9 @@
//Serial CmdSerial(PTC17,PTC16); // Command/Diagnostic serial port on UART3, sicne I don't know how to use USB ports (yet)
Serial CmdSerial(PTC15,PTC14); // Command/Diagnostic serial port on "bluetooth add-on" header
+// emulation of some Arduino serial methods.
+// this class has a singleton interrupt callback, so it
+// creates a singleton global
#include "ASerial.h" // emulation of some common Arduino Serial methods
ASerial cSerial(CmdSerial);
@@ -91,7 +94,7 @@
float cr, cl;
cr = MotR.getCurrent();
cl = MotL.getCurrent();
- CmdSerial.printf("\r\nCurrent: left=%.3f right=%.3f\r\n",cl,cr);
+ CmdSerial.printf("\tCurrent: left=%.3f right=%.3f\r\n",cl,cr);
}
//void dumpSerialChar()
@@ -115,7 +118,8 @@
{
CmdSerial.baud(57600);
CmdSerial.puts("\r\nTankDrive for K64F with Bluetooth\r\n\n");
-
+ CmdSerial.attach(&gotChar); // singleton serial character buffer
+
// Set motor drive parameters
initMotorDrive(MotL);
initMotorDrive(MotR);
@@ -123,7 +127,7 @@
Time.reset();
Time.start();
- CommandReader cmd(cSerial);
+ CommandReader cmd;
//int detailMsg=9;
while (true) {
@@ -154,8 +158,8 @@
}
else
{ // no command, do housekeeping (misc state update stuff)
- MotL.update(t);
- MotR.update(t);
+ //MotL.update(t);
+ //MotR.update(t);
if ((prevCommandTime > 0x0fffff00) && (t < 999))
{ // time counter is close to wrapping around. make sure this does not happen.