pwd 测试成功。
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
idf_component_register(SRCS
|
||||
cmd_system.c
|
||||
cmd_system_common.c
|
||||
cmd_custom.c
|
||||
CustomCommand.cpp
|
||||
INCLUDE_DIRS .
|
||||
REQUIRES console spi_flash driver
|
||||
REQUIRES console spi_flash driver LedController
|
||||
)
|
||||
|
||||
target_sources(${COMPONENT_LIB} PRIVATE cmd_system_sleep.c)
|
36
components/command/CustomCommand.cpp
Normal file
36
components/command/CustomCommand.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "CustomCommand.h"
|
||||
#include "LedController.h"
|
||||
#include "esp_console.h"
|
||||
#include <iostream>
|
||||
|
||||
static int custom_command(int argc, char **argv) {
|
||||
printf("i am amass.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int led_command(int argc, char **argv) {
|
||||
for (int i = 0; i < argc; i++) {
|
||||
std::cout << i << " " << argv[i] << std::endl;
|
||||
}
|
||||
LedController::instance()->setDuty(atoi(argv[1]), atoi(argv[2]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void register_custom() {
|
||||
const esp_console_cmd_t heap_cmd = {
|
||||
.command = "amass",
|
||||
.help = "test command.",
|
||||
.hint = NULL,
|
||||
.func = &custom_command,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_console_cmd_register(&heap_cmd));
|
||||
|
||||
const esp_console_cmd_t led_cmd = {
|
||||
.command = "led",
|
||||
.help = "led pwm duty.",
|
||||
.hint = NULL,
|
||||
.func = &led_command,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_console_cmd_register(&led_cmd));
|
||||
}
|
11
components/command/CustomCommand.h
Normal file
11
components/command/CustomCommand.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __CUSTOMCOMMAND_H__
|
||||
#define __CUSTOMCOMMAND_H__
|
||||
|
||||
|
||||
|
||||
|
||||
void register_custom();
|
||||
|
||||
|
||||
|
||||
#endif // __CUSTOMCOMMAND_H__
|
@ -1,18 +0,0 @@
|
||||
#include "cmd_custom.h"
|
||||
#include "esp_console.h"
|
||||
|
||||
|
||||
static int custom_command(int argc, char **argv) {
|
||||
printf("i am amass.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void register_custom() {
|
||||
const esp_console_cmd_t heap_cmd = {
|
||||
.command = "amass",
|
||||
.help = "test command.",
|
||||
.hint = NULL,
|
||||
.func = &custom_command,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_console_cmd_register(&heap_cmd));
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#ifndef __CMD_CUSTOM_H__
|
||||
#define __CMD_CUSTOM_H__
|
||||
|
||||
void register_custom();
|
||||
|
||||
#endif // __CMD_CUSTOM_H__
|
Reference in New Issue
Block a user