IPAB Neuromorphic / Koala

Files at this revision

API Documentation at this revision

Comitter:
IPAB
Date:
Thu Jul 15 23:51:56 2010 +0000
Parent:
2:b614b7a16e8d
Commit message:

Changed in this revision

Koala.cpp Show annotated file Show diff for this revision Revisions of this file
Koala.h Show annotated file Show diff for this revision Revisions of this file
diff -r b614b7a16e8d -r c32adf6f5ec6 Koala.cpp
--- a/Koala.cpp	Thu Jul 15 23:01:51 2010 +0000
+++ b/Koala.cpp	Thu Jul 15 23:51:56 2010 +0000
@@ -1,9 +1,9 @@
 #include "Koala.h"
 
-Koala::Koala(PinName tx, PinName rx, int baudrate) :  _serial(tx, rx) {
+Koala::Koala(PinName tx, PinName rx, int baudrate) :  Serial(tx, rx) {
 
-    _serial.baud(baudrate);
-    _serial.format(8,Serial::None,1);
+    this->baud(baudrate);
+    this->format(8,Serial::None,1);
     set_speed(0,0);
     set_pos_cnt(0,0);
 }
@@ -11,13 +11,13 @@
 
 void Koala::dummyread() {
 
-    char dummy = _serial.getc();
+    char dummy = this->getc();
 }
 
 char Koala::set_speed(int speedL,int speedR) {
 
-    _serial.printf("D,%d,%d\n",speedL,speedR);
-    char reply = _serial.getc();
+    this->printf("D,%d,%d\n",speedL,speedR);
+    char reply = this->getc();
     dummyread();
     dummyread();
     return reply;
@@ -26,8 +26,8 @@
 
 char Koala::set_pos_cnt(int posL,int posR) {
 
-    _serial.printf("G,%d,%d\n",posL,posR);
-    char reply = _serial.getc();
+    this->printf("G,%d,%d\n",posL,posR);
+    char reply = this->getc();
     dummyread();
     dummyread();
     return reply;
@@ -39,8 +39,8 @@
     PosL = (int*)nPosL;
     PosR = (int*)nPosR;
 
-    _serial.printf("H\n");
-    _serial.scanf("h,%d,%d",PosL,PosR);
+    this->printf("H\n");
+    this->scanf("h,%d,%d",PosL,PosR);
     dummyread();
     dummyread();
 }
@@ -48,17 +48,9 @@
 int Koala::read_channel(int channel) {
 
     int reply;
-    _serial.printf("I,%d\n",channel);
-    _serial.scanf("i,%d",&reply);
+    this->printf("I,%d\n",channel);
+    this->scanf("i,%d",&reply);
     dummyread();
     dummyread();
     return reply;
-}
-
-int printf(const char* format, ...) {
-    return _serial.printf(format)
-}
-
-int scanf(const char* format, ... ) {
-    return _serial.scanf(format)
 }
\ No newline at end of file
diff -r b614b7a16e8d -r c32adf6f5ec6 Koala.h
--- a/Koala.h	Thu Jul 15 23:01:51 2010 +0000
+++ b/Koala.h	Thu Jul 15 23:51:56 2010 +0000
@@ -3,21 +3,16 @@
 
 #include "mbed.h"
 
-class Koala {
+class Koala : public Serial {
 
 public:
-
     Koala(PinName tx, PinName rx, int baudrate);
     char set_speed(int speedL,int speedR);
     char set_pos_cnt(int posL,int posR);
     void read_position(int* nCountL, int* nCountR);
     int read_channel(int channel);
-    int printf(const char* format, ...);
-    int scanf(const char* format, ... );
 protected:
-
     void dummyread();
-    Serial _serial;
 };