Commanders
Arduino buttons/bus library
SerialCommander.hpp
Go to the documentation of this file.
1
//-------------------------------------------------------------------
2
#ifndef __serialCommander_H__
3
#define __serialCommander_H__
4
//-------------------------------------------------------------------
5
6
#include <
Commanders.h
>
7
9
#define SerialCommander SerialCommanderClass::GetCurrent()
10
11
#ifdef NO_SERIALCOMMANDER
12
#pragma message ("Commanders : No Serial commander !")
13
#endif
14
59
//-------------------------------------------------------------------
60
64
#define SERIAL_COMMANDER(SERIAL_PORT)
65
66
class SerialCommanderClass : Commander
67
{
68
private:
69
TextInterpreter TI;
70
71
public:
72
inline SerialCommanderClass() : Commander() { }
73
74
inline void begin() { }
75
76
inline unsigned long loop()
77
{
78
unsigned long foundID = UNDEFINED_ID;
79
80
if (SERIAL_PORT.available() > 0)
81
{
82
while (1)
/* loop until 'enter' is received */
83
{
84
char incomingByte = SERIAL_PORT.read();
85
86
foundID = TI.SendChar(incomingByte);
87
if (incomingByte == 'n') break;
/* exit the while(1) : data OK */
88
}
89
}
90
91
return foundID;
92
}
93
94
public:
95
static SerialCommanderClass *pSerialCommander;
96
static inline SerialCommanderClass &GetCurrent()
97
{
98
if (pSerialCommander == NULL)
99
pSerialCommander = new SerialCommanderClass();
100
return *(SerialCommanderClass::pSerialCommander);
101
}
102
void printCommander() { Serial.println(F("Commander: SerialCommander")); }
103
104
};
105
SerialCommanderClass *SerialCommanderClass::pSerialCommander;
106
107
//-------------------------------------------------------------------
108
#endif
Commanders.h
src
SerialCommander.hpp
Generated on dim. juil. 15 2018 11:26:17 for Commanders by
1.2.10