mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-02 22:18:29 -04:00
uncrustify libraries/AP_Common/menu.cpp
This commit is contained in:
parent
a6567abdc3
commit
eb1fff9584
@ -30,14 +30,14 @@ Menu::Menu(const prog_char *prompt, const Menu::command *commands, uint8_t entri
|
|||||||
void
|
void
|
||||||
Menu::run(void)
|
Menu::run(void)
|
||||||
{
|
{
|
||||||
int8_t ret;
|
int8_t ret;
|
||||||
uint8_t len, i;
|
uint8_t len, i;
|
||||||
uint8_t argc;
|
uint8_t argc;
|
||||||
int c;
|
int c;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
// loop performing commands
|
// loop performing commands
|
||||||
for (;;) {
|
for (;; ) {
|
||||||
|
|
||||||
// run the pre-prompt function, if one is defined
|
// run the pre-prompt function, if one is defined
|
||||||
if ((NULL != _ppfunc) && !_ppfunc())
|
if ((NULL != _ppfunc) && !_ppfunc())
|
||||||
@ -46,7 +46,7 @@ Menu::run(void)
|
|||||||
// loop reading characters from the input
|
// loop reading characters from the input
|
||||||
len = 0;
|
len = 0;
|
||||||
Serial.printf("%S] ", FPSTR(_prompt));
|
Serial.printf("%S] ", FPSTR(_prompt));
|
||||||
for (;;) {
|
for (;; ) {
|
||||||
c = Serial.read();
|
c = Serial.read();
|
||||||
if (-1 == c)
|
if (-1 == c)
|
||||||
continue;
|
continue;
|
||||||
@ -84,13 +84,13 @@ Menu::run(void)
|
|||||||
if ('\0' == _argv[argc].str)
|
if ('\0' == _argv[argc].str)
|
||||||
break;
|
break;
|
||||||
_argv[argc].i = atol(_argv[argc].str);
|
_argv[argc].i = atol(_argv[argc].str);
|
||||||
_argv[argc].f = atof(_argv[argc].str); // calls strtod, > 700B !
|
_argv[argc].f = atof(_argv[argc].str); // calls strtod, > 700B !
|
||||||
argc++;
|
argc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_argv[0].str == NULL) {
|
if (_argv[0].str == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// populate arguments that have not been specified with "" and 0
|
// populate arguments that have not been specified with "" and 0
|
||||||
// this is safer than NULL in the case where commands may look
|
// this is safer than NULL in the case where commands may look
|
||||||
@ -103,7 +103,7 @@ Menu::run(void)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmd_found = false;
|
bool cmd_found = false;
|
||||||
// look for a command matching the first word (note that it may be empty)
|
// look for a command matching the first word (note that it may be empty)
|
||||||
for (i = 0; i < _entries; i++) {
|
for (i = 0; i < _entries; i++) {
|
||||||
if (!strcasecmp_P(_argv[0].str, _commands[i].command)) {
|
if (!strcasecmp_P(_argv[0].str, _commands[i].command)) {
|
||||||
@ -127,8 +127,8 @@ Menu::run(void)
|
|||||||
|
|
||||||
if (cmd_found==false)
|
if (cmd_found==false)
|
||||||
{
|
{
|
||||||
Serial.println("Invalid command, type 'help'");
|
Serial.println("Invalid command, type 'help'");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ Menu::run(void)
|
|||||||
void
|
void
|
||||||
Menu::_help(void)
|
Menu::_help(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Serial.println("Commands:");
|
Serial.println("Commands:");
|
||||||
for (i = 0; i < _entries; i++)
|
for (i = 0; i < _entries; i++)
|
||||||
@ -148,7 +148,7 @@ Menu::_help(void)
|
|||||||
int8_t
|
int8_t
|
||||||
Menu::_call(uint8_t n, uint8_t argc)
|
Menu::_call(uint8_t n, uint8_t argc)
|
||||||
{
|
{
|
||||||
func fn;
|
func fn;
|
||||||
|
|
||||||
fn = (func)pgm_read_pointer(&_commands[n].func);
|
fn = (func)pgm_read_pointer(&_commands[n].func);
|
||||||
return(fn(argc, &_argv[0]));
|
return(fn(argc, &_argv[0]));
|
||||||
|
Loading…
Reference in New Issue
Block a user