60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
#if !defined(DEBUG_FLAG)
|
|
#define DEBUG_FLAG false
|
|
#endif
|
|
|
|
#include <SoftwareSerial.h>
|
|
#if DEBUG_FLAG
|
|
#include <HardwareSerial.h>
|
|
#endif
|
|
|
|
class DispClass {
|
|
private:
|
|
SoftwareSerial* serD;
|
|
#if DEBUG_FLAG
|
|
HardwareSerial* _debug;
|
|
#endif
|
|
void init(void);
|
|
public:
|
|
#if DEBUG_FLAG
|
|
DispClass(HardwareSerial *debug);
|
|
#else
|
|
DispClass(void);
|
|
#endif
|
|
void print(String text);
|
|
void setTimeout(unsigned long timeout);
|
|
String readStringUntil(char terminator);
|
|
};
|
|
|
|
#if DEBUG_FLAG
|
|
DispClass::DispClass(HardwareSerial *debug) {
|
|
this->_debug = debug;
|
|
this->init();
|
|
}
|
|
#else
|
|
DispClass::DispClass(void) {
|
|
this->init();
|
|
}
|
|
#endif
|
|
|
|
void DispClass::init(void) {
|
|
this->serD = new SoftwareSerial(7, 6);
|
|
this->serD->begin(9600);
|
|
}
|
|
|
|
void DispClass::print(String text) {
|
|
#if DEBUG_FLAG
|
|
this->_debug->println("d->: "+text);
|
|
#endif
|
|
this->serD->listen();
|
|
this->serD->println(text);
|
|
}
|
|
|
|
void DispClass::setTimeout(unsigned long timeout) {
|
|
this->serD->setTimeout(timeout);
|
|
}
|
|
|
|
String DispClass::readStringUntil(char terminator) {
|
|
return this->serD->readStringUntil(terminator);
|
|
}
|
|
|