PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
Command Processor Internals

Data Structures

struct  st_cmd_help
 

Macros

#define CMDPROC_PROMPT_STR   "> "
 
#define CMD_HELP_COUNT   (sizeof(cmd_help)/sizeof(cmd_help[0]))
 

Typedefs

typedef void(* handler_fn_t) (void *p_cmd_args)
 

Functions

static void send_trailer (bool is_nak, pixelkey_error_t error)
 Sends the OK/NAK trailer for each command. More...
 
static void handler_undefined (void *p_cmd_args)
 
static void handler_config_get (void *p_cmd_args)
 
static void handler_config_set (void *p_cmd_args)
 
static void handler_help (void *p_cmd_args)
 
static void handler_resume (void *p_cmd_args)
 
static void handler_stop (void *p_cmd_args)
 
static void handler_status (void *p_cmd_args)
 
static void handler_version (void *p_cmd_args)
 
static void handler_time_get (void *p_cmd_args)
 
static void handler_time_set (void *p_cmd_args)
 
static void handler_reboot (void *p_cmd_args)
 
static void handler_keyframe_wrapper (void *p_cmd_args)
 
static void handler_keyframe_mod_repeat (void *p_cmd_args)
 
static void handler_keyframe_mod_schedule (void *p_cmd_args)
 
static void handler_keyframe_mod_group (void *p_cmd_args)
 
void pixelkey_commandproc_init (void)
 Initialize the command processor.
 
pixelkey_error_t pixelkey_commandproc_push (cmd_t *p_cmd)
 Pushes a command to the processor buffer. More...
 
void pixelkey_commandproc_task (void)
 Executes queued commands. More...
 
void pixelkey_commandproc_terminal_connected (void)
 Writes the initial device info and terminal prompt when a terminal attach is detected.
 
void pixelkey_commandproc_send_prompt (void)
 Writes the terminal prompt. More...
 

Variables

static cmd_tcmd_buffer_data [PIXELKEY_COMMAND_BUFFER_LENGTH] = {0}
 
static ring_buffer_t cmd_buffer = {0}
 
static handler_fn_t cmd_handlers [CMD_TYPE_COUNT]
 
static struct st_cmd_help cmd_help []
 
static bool has_repeat_modifier = false
 
static int32_t repeat_modifier = 0
 
static bool has_schedule_modifier = false
 
static bool is_schedule_repeating = false
 
static keyframe_schedule_t schedule_modifier = {0}
 

Detailed Description

Function Documentation

◆ handler_config_set()

static void handler_config_set ( void *  p_cmd_args)
static
Todo:
Add support to set number of neopixels.

◆ pixelkey_commandproc_push()

pixelkey_error_t pixelkey_commandproc_push ( cmd_t p_cmd)

Pushes a command to the processor buffer.

Parameters
[in]p_cmdPointer to the command to queue.
Return values
PIXELKEY_ERROR_BUFFER_FULLNo more space in the command queue.
PIXELKEY_ERROR_NONECommand was pushed to the queue.

◆ pixelkey_commandproc_send_prompt()

void pixelkey_commandproc_send_prompt ( void  )

Writes the terminal prompt.

This is done as a task so that it can execute after all command processing has been completed.

◆ pixelkey_commandproc_task()

void pixelkey_commandproc_task ( void  )

Executes queued commands.

Todo:
Remove this check once all the handlers are implemented.

◆ send_trailer()

static void send_trailer ( bool  is_nak,
pixelkey_error_t  error 
)
static

Sends the OK/NAK trailer for each command.

Parameters
is_nakTrue if a NAK should be sent, false for OK.
errorThe error code if this is called for a NAK.

Variable Documentation

◆ cmd_handlers

handler_fn_t cmd_handlers[CMD_TYPE_COUNT]
static
Initial value:
=
{
[CMD_TYPE_CONFIG_GET] = handler_config_get,
[CMD_TYPE_RESUME] = handler_resume,
[CMD_TYPE_STOP] = handler_stop,
[CMD_TYPE_STATUS] = handler_status,
[CMD_TYPE_VERSION] = handler_version,
[CMD_TYPE_TIME_GET] = handler_time_get,
[CMD_TYPE_TIME_SET] = handler_time_set,
[CMD_TYPE_KEYFRAME_WRAPPER] = handler_keyframe_wrapper,
[CMD_TYPE_KEYFRAME_MOD_REPEAT] = handler_keyframe_mod_repeat,
[CMD_TYPE_KEYFRAME_MOD_SCHEDULE] = handler_keyframe_mod_schedule,
[CMD_TYPE_KEYFRAME_MOD_GROUP] = handler_keyframe_mod_group,
[CMD_TYPE_HELP] = handler_help,
[CMD_TYPE_REBOOT] = handler_reboot,
}
static void handler_config_set(void *p_cmd_args)
Definition: command_processor.c:328
@ CMD_TYPE_CONFIG_GET
Get a configuration value.
Definition: pixelkey_commands.h:51
@ CMD_TYPE_STOP
Stop keyframe processing and go idle.
Definition: pixelkey_commands.h:54
@ CMD_TYPE_REBOOT
Triggers a software reset of the micro.
Definition: pixelkey_commands.h:60
@ CMD_TYPE_TIME_GET
Get the current system time.
Definition: pixelkey_commands.h:57
@ CMD_TYPE_CONFIG_SET
Set a configuration value.
Definition: pixelkey_commands.h:52
@ CMD_TYPE_KEYFRAME_MOD_GROUP
Keyframe group modifier command.
Definition: pixelkey_commands.h:50
@ CMD_TYPE_STATUS
Display device status.
Definition: pixelkey_commands.h:55
@ CMD_TYPE_KEYFRAME_MOD_SCHEDULE
Keyframe schedule modifier command.
Definition: pixelkey_commands.h:49
@ CMD_TYPE_HELP
Displays a help message.
Definition: pixelkey_commands.h:59
@ CMD_TYPE_KEYFRAME_MOD_REPEAT
Keyframe repeat modifier command.
Definition: pixelkey_commands.h:48
@ CMD_TYPE_KEYFRAME_WRAPPER
Command wrapper around a keyframe.
Definition: pixelkey_commands.h:47
@ CMD_TYPE_TIME_SET
Set the current system time.
Definition: pixelkey_commands.h:58
@ CMD_TYPE_RESUME
Resume keyframe processing.
Definition: pixelkey_commands.h:53
@ CMD_TYPE_VERSION
Display device firmware version.
Definition: pixelkey_commands.h:56

◆ cmd_help

struct st_cmd_help cmd_help[]
static
Initial value:
=
{
{ "$config-get", "Gets a configuration value." },
{ "$config-set", "Sets a configuration value." },
{ "$help, help, ?", "Displays a help message." },
{ "$reboot", "Reboots the PixelKey."},
{ "$resume", "Resume keyframe processing and rendering." },
{ "$status", "Shows device status and info." },
{ "$stop", "Stops keyframe processing and rendering." },
{ "$time-get", "Gets current system time." },
{ "$time-set", "Sets current system time." },
{ "$version", "Shows current firmware version." },
{ "blink", "Keyframe to blink between two colors." },
{ "fade", "Keyframe to fade between colors." },
{ "set", "Keyframe to set the color of NeoPixels." },
{ "^<repeat>", "Repeat keyframe modifier." },
{ "@<schedule>", "Schedule keyframe modifier." },
{ "{[name], }", "Keyframe group modifier." },
}