1 #include "TextInterpreter.hpp" 3 #ifndef NO_SERIALCOMMANDER 15 this->neg_sign =
false;
16 this->step = TEXTINTERPRETER_STEP_ID;
21 if (inCharacter ==
'n')
32 #ifdef COMMANDERS_DEBUG_MODE 35 Serial.print(F(
"data = "));
38 Serial.println(this->data);
42 if (this->neg_sign ==
true)
43 this->data = -this->data;
46 #ifndef NO_DCCCOMMANDER 48 foundID = DCCINT(this->
id, this->id2);
61 if (inCharacter == (
char)-1)
64 if (inCharacter ==
':')
66 if (this->step == TEXTINTERPRETER_STEP_ID)
68 this->step = TEXTINTERPRETER_STEP_ID2;
73 if (inCharacter ==
' ' || inCharacter ==
',' || inCharacter ==
';' || inCharacter ==
'/')
75 #ifdef COMMANDERS_DEBUG_VERBOSE_MODE 76 Serial.println(F(
"separator"));
80 case TEXTINTERPRETER_STEP_ID:
81 #ifdef COMMANDERS_DEBUG_MODE 82 Serial.print(F(
"id = "));
83 Serial.println(this->
id);
85 this->step = TEXTINTERPRETER_STEP_TYPE;
87 case TEXTINTERPRETER_STEP_ID2:
88 #ifdef COMMANDERS_DEBUG_MODE 89 Serial.print(F(
"id = DCCINT("));
90 Serial.print(this->
id);
92 Serial.print(this->id2);
95 this->step = TEXTINTERPRETER_STEP_TYPE;
97 case TEXTINTERPRETER_STEP_TYPE:
98 #ifdef COMMANDERS_DEBUG_MODE 99 Serial.print(F(
"event = "));
100 Serial.println(this->lastEventType);
102 this->step = TEXTINTERPRETER_STEP_DATA;
105 case TEXTINTERPRETER_STEP_DATA:
106 #ifdef COMMANDERS_DEBUG_MODE 107 Serial.print(F(
"data = "));
109 Serial.print(F(
"-"));
110 Serial.println(this->data);
112 this->step = TEXTINTERPRETER_STEP_END;
120 if (step == TEXTINTERPRETER_STEP_END)
123 #ifdef COMMANDERS_DEBUG_VERBOSE_MODE 124 Serial.print(F(
"read "));
125 Serial.println(inCharacter, DEC);
130 case TEXTINTERPRETER_STEP_ID:
131 if (inCharacter >= 48 && inCharacter <= 57)
134 this->
id = ((inCharacter - 48) + this->
id);
139 case TEXTINTERPRETER_STEP_ID2:
140 if (inCharacter >= 48 && inCharacter <= 57)
142 if (this->id2 == 255)
146 this->id2 = ((inCharacter - 48) + this->id2);
150 case TEXTINTERPRETER_STEP_TYPE:
162 case TEXTINTERPRETER_STEP_DATA:
163 if (inCharacter ==
'-')
164 this->neg_sign =
true;
165 if (inCharacter >= 48 && inCharacter <= 57)
168 this->data = ((inCharacter - 48) + this->data);
unsigned long SendString(char *inpString)
static void SetLastEventData(int inData)
static void SetLastEventType(COMMANDERS_EVENT_TYPE inEvent)
static unsigned long RaiseEvent(unsigned long inId, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0)
unsigned long SendChar(char inCharacter)