MCPcopy Create free account
hub / github.com/FastLED/FastLED / readInputFromSerial

Method readInputFromSerial

src/platforms/shared/ui/json/json_console.cpp.hpp:124–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void JsonConsole::readInputFromSerial() FL_NOEXCEPT {
125 if (!mReadAvailableCallback || !mReadCallback) {
126 return;
127 }
128
129 // Read available characters
130 while (mReadAvailableCallback() > 0) {
131 int ch = mReadCallback();
132 if (ch == -1) {
133 break; // No more data
134 }
135
136 char c = static_cast<char>(ch);
137
138 if (c == '\n' || c == '\r') {
139 // End of command - execute it
140 if (!mInputBuffer.empty()) {
141 executeCommand(mInputBuffer);
142 mInputBuffer.clear();
143 }
144 } else if (c == '\b' || c == 127) { // Backspace or DEL
145 if (!mInputBuffer.empty()) {
146 mInputBuffer = mInputBuffer.substring(0, mInputBuffer.size() - 1);
147 }
148 } else if (c >= 32 && c <= 126) { // Printable ASCII
149 mInputBuffer.write(c);
150 }
151 // Ignore other control characters
152 }
153}
154
155void JsonConsole::parseCommand(const fl::string& command) FL_NOEXCEPT {
156 FL_WARN("JsonConsole::parseCommand: Parsing command '" << command.c_str() << "'");

Callers

nothing calls this directly

Calls 5

substringMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected