Library for JrkG2. this bases on Arduino Library (https://github.com/pololu/jrk-g2-arduino)
Diff: JrkG2.h
- Revision:
- 2:e78c0ddcf337
- Parent:
- 1:d611aa1f9f70
--- a/JrkG2.h Sat Aug 25 13:15:38 2018 +0000 +++ b/JrkG2.h Sun Aug 26 08:42:11 2018 +0000 @@ -1,6 +1,7 @@ #pragma once #include "mbed.h" +#include "AsyncSerial.hpp" /*example********************************** @@ -12,7 +13,7 @@ //on the other or both //on Serial - Serial device(p9, p10); + AsyncSerial device(p9, p10); JrkG2Serial jrk(&device); //on I2C @@ -1695,10 +1696,10 @@ /// Represents a serial connection to a Jrk G2. /// /// For the high-level commands you can use on this object, see JrkG2Base. -class JrkG2Serial : public JrkG2Base //public Stream +class JrkG2Serial : public JrkG2Base { public: - JrkG2Serial(Serial *stream, uint8_t deviceNumber = 255) : + JrkG2Serial(AsyncSerial *stream, uint8_t deviceNumber = 255) : _deviceNumber(deviceNumber) { _stream = stream; @@ -1708,7 +1709,9 @@ uint8_t getDeviceNumber() { return _deviceNumber; } private: - Serial *_stream; + //Serial *_stream; + AsyncSerial *_stream; + const uint8_t _deviceNumber; virtual void commandQuick(uint8_t cmd) { sendCommandHeader(cmd); } @@ -1722,7 +1725,6 @@ uint8_t length, uint8_t * buffer); void sendCommandHeader(uint8_t cmd); - //void serialW7(uint8_t val) { _stream->write(val & 0x7F); } void serialW7(uint8_t val) { _stream->putc(val & 0x7F); } };