Remove command parsing to simplify the code

This commit is contained in:
Oleg Kalachev 2025-02-28 23:02:02 +03:00
parent 6058e8ecab
commit 89c1ada005
3 changed files with 2 additions and 17 deletions

View File

@ -33,12 +33,7 @@ const char* motd =
"mfr, mfl, mrr, mrl - test motor (remove props)\n"
"reset - reset drone's state\n";
void doCommand(String str) {
// parse command
String command, arg0, arg1;
splitString(str, command, arg0, arg1);
// execute command
void doCommand(const String& command) {
if (command == "help" || command == "motd") {
Serial.println(motd);
} else if (command == "ps") {

View File

@ -42,13 +42,3 @@ void printArray(T arr[], int size) {
void disableBrownOut() {
REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ENA);
}
// Trim and split string by spaces
void splitString(String& str, String& token0, String& token1, String& token2) {
str.trim();
char chars[str.length() + 1];
str.toCharArray(chars, str.length() + 1);
token0 = strtok(chars, " ");
token1 = strtok(NULL, " "); // String(NULL) creates empty string
token2 = strtok(NULL, "");
}

View File

@ -34,7 +34,7 @@ void controlTorque();
void showTable();
void sendMotors();
bool motorsActive();
void doCommand(String str);
void doCommand(const String& command);
void normalizeRC();
void printRCCal();
void processMavlink();