mirror of
https://github.com/okalachev/flix.git
synced 2025-07-30 04:48: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"
|
"mfr, mfl, mrr, mrl - test motor (remove props)\n"
|
||||||
"reset - reset drone's state\n";
|
"reset - reset drone's state\n";
|
||||||
|
|
||||||
void doCommand(String str) {
|
void doCommand(const String& command) {
|
||||||
// parse command
|
|
||||||
String command, arg0, arg1;
|
|
||||||
splitString(str, command, arg0, arg1);
|
|
||||||
|
|
||||||
// execute command
|
|
||||||
if (command == "help" || command == "motd") {
|
if (command == "help" || command == "motd") {
|
||||||
Serial.println(motd);
|
Serial.println(motd);
|
||||||
} else if (command == "ps") {
|
} else if (command == "ps") {
|
||||||
|
10
flix/util.h
10
flix/util.h
@ -42,13 +42,3 @@ void printArray(T arr[], int size) {
|
|||||||
void disableBrownOut() {
|
void disableBrownOut() {
|
||||||
REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ENA);
|
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 showTable();
|
||||||
void sendMotors();
|
void sendMotors();
|
||||||
bool motorsActive();
|
bool motorsActive();
|
||||||
void doCommand(String str);
|
void doCommand(const String& command);
|
||||||
void normalizeRC();
|
void normalizeRC();
|
||||||
void printRCCal();
|
void printRCCal();
|
||||||
void processMavlink();
|
void processMavlink();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user