![]() |
SimpleFOClibrary 2.4.0
|
#include <Commander.h>
Public Member Functions | |
| Commander (Stream &serial, char eol='\n', bool echo=false) | |
| Commander (char eol='\n', bool echo=false) | |
| void | run () |
| void | run (Stream &reader, char eol='\n') |
| void | run (char *user_input) |
| void | add (char id, CommandCallback onCommand, const char *label=nullptr) |
| void | motor (FOCMotor *motor, char *user_cmd) |
| void | lpf (LowPassFilter *lpf, char *user_cmd) |
| void | pid (PIDController *pid, char *user_cmd) |
| void | scalar (float *value, char *user_cmd) |
| void | target (FOCMotor *motor, char *user_cmd, char *separator=(char *)" ") |
| void | motion (FOCMotor *motor, char *user_cmd, char *separator=(char *)" ") |
| bool | isSentinel (char ch) |
Public Attributes | |
| VerboseMode | verbose = VerboseMode::user_friendly |
| flag signaling that the commands should output user understanable text | |
| uint8_t | decimal_places = 3 |
| number of decimal places to be used when displaying numbers | |
| Stream * | com_port = nullptr |
| Serial terminal variable if provided. | |
| char | eol = '\n' |
| end of line sentinel character | |
| bool | echo = false |
| echo last typed character (for command line feedback) | |
Commander class implementing string communication protocol based on IDvalue (ex AB5.321 - command id A, sub-command id B,value 5.321)
Definition at line 38 of file Commander.h.
| Commander::Commander | ( | Stream & | serial, |
| char | eol = '\n', |
||
| bool | echo = false |
||
| ) |
Default constructor receiving a serial interface that it uses to output the values to Also if the function run() is used it uses this serial instance to read the serial for user commands
| serial | - Serial com port instance |
| eol | - the end of line sentinel character |
| echo | - echo last typed character (for command line feedback) |
Definition at line 3 of file Commander.cpp.
| Commander::Commander | ( | char | eol = '\n', |
| bool | echo = false |
||
| ) |
Definition at line 8 of file Commander.cpp.
| void Commander::add | ( | char | id, |
| CommandCallback | onCommand, | ||
| const char * | label = nullptr |
||
| ) |
Function adding a callback to the commander with the command id
| id | - char command letter |
| onCommand | - function pointer void function(char*) |
| label | - string label to be displayed when scan command sent |
Definition at line 14 of file Commander.cpp.
| bool Commander::isSentinel | ( | char | ch | ) |
| void Commander::lpf | ( | LowPassFilter * | lpf, |
| char * | user_cmd | ||
| ) |
Low pass fileter command interface
| lpf | - LowPassFilter instance |
| user_cmd | - the string command |
Definition at line 546 of file Commander.cpp.
| void Commander::motion | ( | FOCMotor * | motor, |
| char * | user_cmd, | ||
| char * | separator = (char *)" " |
||
| ) |
FOC motor (StepperMotor and BLDCMotor) motion control interfaces
| motor | - FOCMotor (BLDCMotor or StepperMotor) instance |
| user_cmd | - the string command |
| separator | - the string separator in between target and limit values, default is space - " " |
Commands: 'C' - Motion control type config sub-commands: 'D' - downsample motiron loop '0' - torque '1' - velocity '2' - angle 'T' - Torque control type sub-commands: '0' - voltage '1' - current '2' - foc_current 'E' - Motor status (enable/disable) sub-commands: '0' - enable '1' - disable '' - Target setting interface Depends of the motion control mode:
Definition at line 417 of file Commander.cpp.
| void Commander::motor | ( | FOCMotor * | motor, |
| char * | user_cmd | ||
| ) |
FOC motor (StepperMotor and BLDCMotor) command interface
| motor | - FOCMotor (BLDCMotor or StepperMotor) instance |
| user_cmd | - the string command |
Definition at line 107 of file Commander.cpp.
| void Commander::pid | ( | PIDController * | pid, |
| char * | user_cmd | ||
| ) |
PID controller command interface
| pid | - PIDController instance |
| user_cmd | - the string command |
Definition at line 509 of file Commander.cpp.
| void Commander::run | ( | ) |
Function reading the serial port and firing callbacks that have been added to the commander once the user has requested them - when he sends the command
Definition at line 22 of file Commander.cpp.
| void Commander::run | ( | char * | user_input | ) |
Function reading the string of user input and firing callbacks that have been added to the commander once the user has requested them - when he sends the command
| user_input | - string of user inputs |
Definition at line 59 of file Commander.cpp.
| void Commander::run | ( | Stream & | reader, |
| char | eol = '\n' |
||
| ) |
Function reading the string of user input and firing callbacks that have been added to the commander once the user has requested them - when he sends the command
| reader | - temporary stream to read user input |
| eol | - temporary end of line sentinel |
Definition at line 27 of file Commander.cpp.
| void Commander::scalar | ( | float * | value, |
| char * | user_cmd | ||
| ) |
Float variable scalar command interface
| value | - float variable pointer |
| user_cmd | - the string command |
Definition at line 563 of file Commander.cpp.
| void Commander::target | ( | FOCMotor * | motor, |
| char * | user_cmd, | ||
| char * | separator = (char *)" " |
||
| ) |
Target setting interface, enables setting the target and limiting variables at once. The values are sent separated by a separator specified as the third argument. The default separator is the space.
| motor | - FOCMotor (BLDCMotor or StepperMotor) instance |
| user_cmd | - the string command |
| separator | - the string separator in between target and limit values, default is space - " " |
Example: P2.34 70 2 P is the user defined command, 2.34 is the target angle 70 is the target velocity and 2 is the desired max current.
It depends of the motion control mode:
Definition at line 570 of file Commander.cpp.
| Stream* Commander::com_port = nullptr |
Serial terminal variable if provided.
Definition at line 101 of file Commander.h.
| uint8_t Commander::decimal_places = 3 |
number of decimal places to be used when displaying numbers
Definition at line 98 of file Commander.h.
| bool Commander::echo = false |
echo last typed character (for command line feedback)
Definition at line 103 of file Commander.h.
| char Commander::eol = '\n' |
end of line sentinel character
Definition at line 102 of file Commander.h.
| VerboseMode Commander::verbose = VerboseMode::user_friendly |
flag signaling that the commands should output user understanable text
Definition at line 97 of file Commander.h.