add led command
This commit is contained in:
parent
2887173681
commit
d185891740
@ -1 +1 @@
|
||||
Subproject commit 8261e605bccf98e6f028d0ca221ffb81ebc4c0c2
|
||||
Subproject commit f08c8e5788cb24b7321697560987ecca9322e050
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
#include "commands.h"
|
||||
#include "utils.h"
|
||||
#include "led.h"
|
||||
|
||||
typedef enum {
|
||||
BOAT_AVAILABLE,
|
||||
@ -74,10 +75,42 @@ int cmd_status(char* line, CLI_t* cli)
|
||||
return ret;
|
||||
}
|
||||
|
||||
char* readInt(char* str, int* out)
|
||||
{
|
||||
*out = 0;
|
||||
while ((*str >= '0') && (*str <= '9'))
|
||||
{
|
||||
*out *= 10;
|
||||
*out += *str - '0';
|
||||
str++;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
int setLed(char* line, CLI_t* cli)
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
char* arg = getNextArg(line, ':');
|
||||
readInt(arg, &r);
|
||||
arg = getNextArg(arg, ',');
|
||||
readInt(arg, &g);
|
||||
arg = getNextArg(arg, ',');
|
||||
readInt(arg, &b);
|
||||
|
||||
led_setRGB(r, g, b);
|
||||
|
||||
char msg[20];
|
||||
snprintf(&msg[0], 20, "led: r%d g%d n%d\n", r, g, b);
|
||||
CLI_stringOut(cli, &msg[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CMD_t Commands[] = {
|
||||
{ "d", &cmd_contrl },
|
||||
{ "shutdown", &cmd_shutdown },
|
||||
{ "status", &cmd_status }
|
||||
{ "status", &cmd_status },
|
||||
{ "led", &setLed }
|
||||
};
|
||||
|
||||
CMDList_t* getCMDList()
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#include "esp_event.h"
|
||||
#include "esp_task_wdt.h"
|
||||
|
||||
#include "../lib/cli/CLI/CLI.h"
|
||||
#include "../lib/cli/CMDList/CMDList.h"
|
||||
#include "CLI/CLI.h"
|
||||
#include "CMDList/CMDList.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "utils.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user