mirror of
https://github.com/okalachev/flix.git
synced 2025-07-29 12:28:59 +00:00
Remove command parsing to simplify the code
This commit is contained in:
parent
6058e8ecab
commit
89c1ada005
@ -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") {
|
||||
|
10
flix/util.h
10
flix/util.h
@ -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, "");
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user