mirror of
https://github.com/okalachev/flix.git
synced 2026-01-11 13:36:43 +00:00
Refactor CLI submodule
Move command parsing to doCommand Parse command with splitString instead of stringToken Trim commands Move cliTestMotor to the bottom Rename parseInput to handleInput, which is more clear Move motor test function to motors.ino Remove parameters table functionality to simplify the code
This commit is contained in:
@@ -33,9 +33,17 @@ class __FlashStringHelper;
|
||||
// https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/
|
||||
class String: public std::string {
|
||||
public:
|
||||
String(const char *str = "") : std::string(str ? str : "") {}
|
||||
long toInt() const { return atol(this->c_str()); }
|
||||
float toFloat() const { return atof(this->c_str()); }
|
||||
bool isEmpty() const { return this->empty(); }
|
||||
void toCharArray(char *buf, unsigned int bufsize, unsigned int index = 0) const {
|
||||
strlcpy(buf, this->c_str() + index, bufsize);
|
||||
}
|
||||
void trim() {
|
||||
this->erase(0, this->find_first_not_of(" \t\n\r"));
|
||||
this->erase(this->find_last_not_of(" \t\n\r") + 1);
|
||||
}
|
||||
};
|
||||
|
||||
class Print;
|
||||
|
||||
@@ -34,7 +34,8 @@ void controlTorque();
|
||||
void showTable();
|
||||
void sendMotors();
|
||||
bool motorsActive();
|
||||
void cliTestMotor(uint8_t n);
|
||||
void doCommand(String str);
|
||||
void normalizeRC();
|
||||
void printRCCal();
|
||||
void processMavlink();
|
||||
void sendMavlink();
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
attitude.setYaw(this->model->WorldPose().Yaw());
|
||||
|
||||
control();
|
||||
parseInput();
|
||||
handleInput();
|
||||
processMavlink();
|
||||
|
||||
applyMotorForces();
|
||||
|
||||
Reference in New Issue
Block a user