Basic tank-style drive robot control firmware for Freescale FRDM-K64F. Controls motors on a Dual-Full-H-Bridge with EN, like DBH-1x series, from Bluetooth serial commands

Dependencies:   mbed

ASerial.h

Committer:
Mr_What
Date:
2015-07-28
Revision:
0:41ca27337c2b
Child:
2:54d27fdcbe5c

File content as of revision 0:41ca27337c2b:

// Aaron Birenboim, 26jul15

// Add some common Serial methods used in Arduino sketches
//
// Serial inherits from stream, for which I have no docuemntation.
// examples seem to indicate that stream has (at least) printf

//#include "Serial.h"

class ASerial
{
  public:
    Serial *_serial;
    ASerial(Serial &s) : _serial(&s)
    {
        
    }
    
    void print(const char *s) { _serial->puts(s);      }
    void print(const int i  ) { _serial->printf("%d",i); }
    void print(const float f) { _serial->printf("%.3f",f); }
    
    void println(const char *s) { print(s); _serial->putc('\n'); }
    void println(const float f) { print(f); _serial->putc('\n'); }
    
    void baud(const int i) { _serial->baud(i); }

    int readc()
    {
      if (_serial->readable())
      {
         char c = _serial->getc();
         return((int)c);   
      }
      return(-1);
    }
};