mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-13 10:00:13 +00:00
ESP32-Console
This commit is contained in:
@@ -126,41 +126,41 @@ static struct {
|
|||||||
struct arg_int *level;
|
struct arg_int *level;
|
||||||
struct arg_int *pwm;
|
struct arg_int *pwm;
|
||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} gpio_args;
|
} gpio_set_args;
|
||||||
static int exec_gpio_cmd (int argc, char **argv) {
|
static int exec_gpio_set_cmd (int argc, char **argv) {
|
||||||
|
|
||||||
int nerrors = arg_parse(argc, argv, (void**) &gpio_args);
|
int nerrors = arg_parse(argc, argv, (void**) &gpio_set_args);
|
||||||
if (nerrors != 0) {
|
if (nerrors != 0) {
|
||||||
arg_print_errors(stderr, gpio_args.end, argv[0]);
|
arg_print_errors(stderr, gpio_set_args.end, argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (gpio_args.gpio != 0 && gpio_args.mode != 0 && gpio_args.level != 0) {
|
if (gpio_set_args.gpio != 0 && gpio_set_args.mode != 0 && gpio_set_args.level != 0) {
|
||||||
ESP_LOGI("GPIO", "pin: %i, mode: %s, level: %i", gpio_args.gpio->ival[0], gpio_args.mode->sval[0], gpio_args.level->ival[0]);
|
ESP_LOGI("GPIO", "pin: %i, mode: %s, level: %i", gpio_set_args.gpio->ival[0], gpio_set_args.mode->sval[0], gpio_set_args.level->ival[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static void register_gpio (void) {
|
static void register_set_gpio (void) {
|
||||||
|
|
||||||
gpio_args.gpio = arg_int0("p", "gpio", "<pin>", "Specifies GPIO to be used");
|
gpio_set_args.gpio = arg_int0("p", "gpio", "<pin>", "Specifies GPIO to be used");
|
||||||
gpio_args.mode = arg_str0("m", "mode", "<in|out>", "Sets the mode of GPIO.");
|
gpio_set_args.mode = arg_str0("m", "mode", "<in|out>", "Sets the mode of GPIO.");
|
||||||
gpio_args.level = arg_int0("l", "level", "<1|0>", "Sets the logical level of GPIO.");
|
gpio_set_args.level = arg_int0("l", "level", "<1|0>", "Sets the logical level of GPIO.");
|
||||||
gpio_args.pwm = arg_int0("f", "pwm", "<num>", "Set PWM for GPIO.");
|
gpio_set_args.pwm = arg_int0("f", "pwm", "<num>", "Set PWM for GPIO.");
|
||||||
gpio_args.end = arg_end(2);
|
gpio_set_args.end = arg_end(2);
|
||||||
const esp_console_cmd_t gpio_cmd = {
|
const esp_console_cmd_t gpio_set_cmd = {
|
||||||
.command = "gpio",
|
.command = "gpio",
|
||||||
.help = "Sets/Gets GPIOs",
|
.help = "Sets/Gets GPIOs",
|
||||||
.hint = NULL,
|
.hint = NULL,
|
||||||
.func = &exec_gpio_cmd,
|
.func = &exec_gpio_set_cmd,
|
||||||
.argtable = &gpio_args
|
.argtable = &gpio_set_args
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(esp_console_cmd_register(&gpio_cmd));
|
ESP_ERROR_CHECK(esp_console_cmd_register(&gpio_set_cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_commands (void) {
|
void register_commands (void) {
|
||||||
register_info();
|
register_info();
|
||||||
register_gpio();
|
register_set_gpio();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user