PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
pixelkey_commands.h
Go to the documentation of this file.
1#ifndef PIXELKEY_COMMANDS_H
2#define PIXELKEY_COMMANDS_H
3
11#include <stdlib.h>
12#include <stdint.h>
13#include <stdbool.h>
14
15#include "keyframes.h"
16
18#define CMD_PREFIX ('$')
19
21#define CMD_REPEAT_MOD_PREFIX ('^')
22
24#define CMD_SCHEDULE_MOD_PREFIX ('@')
25
27#define CMD_GROUP_BEGIN_MOD_PREFIX ('{')
28
30#define CMD_GROUP_END_MOD_PREFIX ('}')
31
33#define CMD_CONFIG_KEY_MAX_LENGTH (32)
35#define CMD_TIME_SET_MAX_LENGTH (26) // YYYY-MM-DD HH:mm:ssZZZZZZ\0
36
38#define CMD_KEYFRAME_WRAPPER_CHANNELS_MAX_LENGTH (16)
39
41#define CMD_KEYFRAME_MAX_CHANNEL_NUMBER (0x7FFF)
42
44typedef enum e_cmd_type
45{
63
65typedef enum e_value_type
66{
71
73typedef struct st_cmd_args_keyframe_wrapper
74{
75 keyframe_base_t * p_keyframe;
78
80typedef struct st_cmd_args_config_get
81{
84
86typedef struct st_cmd_args_config_set
87{
89
91 union
92 {
93 int32_t i32;
94 float f32;
95 bool b;
96 } value;
97
99
101typedef struct st_cmd_args_time_set
102{
104 struct
105 {
106 uint16_t year;
107 uint8_t month;
108 uint8_t day;
109 uint8_t hour;
110 uint8_t minute;
111 uint8_t second;
112 uint8_t tz_hour;
113 uint8_t tz_minute;
114 } time_bcd;
116
118typedef struct st_cmd_args_keyframe_mod_repeat
119{
120 int32_t repeat_count;
122
124typedef struct st_cmd_args_keyframe_mod_schedule
125{
128
130typedef struct st_cmd
131{
133 void * p_args;
134} cmd_t;
135
137typedef struct st_cmd_list
138{
140 struct st_cmd_list * p_next;
141} cmd_list_t;
142
143void pixelkey_cmd_free(cmd_t * p_cmd);
144void pixelkey_cmd_list_free(cmd_list_t * p_cmd_list);
145pixelkey_error_t pixelkey_command_parse(char * command_str, cmd_list_t ** p_cmd_list);
146
149#endif
cmd_type_t
Command types.
Definition: pixelkey_commands.h:45
value_type_t
Value types.
Definition: pixelkey_commands.h:66
#define CMD_CONFIG_KEY_MAX_LENGTH
Max string length for configuration keys.
Definition: pixelkey_commands.h:33
#define CMD_KEYFRAME_WRAPPER_CHANNELS_MAX_LENGTH
Maximum length of the index array for keyfrmaes.
Definition: pixelkey_commands.h:38
pixelkey_error_t pixelkey_command_parse(char *command_str, cmd_list_t **p_cmd_list)
Parses a command string.
Definition: command_parser.c:34
@ CMD_TYPE_UNDEFINED
Undefined command.
Definition: pixelkey_commands.h:46
@ CMD_TYPE_COUNT
Total number of command types.
Definition: pixelkey_commands.h:61
@ 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
@ VALUE_TYPE_FLOAT
Float value.
Definition: pixelkey_commands.h:69
@ VALUE_TYPE_BOOLEAN
Boolean value.
Definition: pixelkey_commands.h:67
@ VALUE_TYPE_INTEGER
Integer value.
Definition: pixelkey_commands.h:68
pixelkey_error_t
PixelKey errors.
Definition: pixelkey_errors.h:11
Arguments to config-set command.
Definition: pixelkey_commands.h:81
Arguments to config-set command.
Definition: pixelkey_commands.h:87
int32_t i32
Integer config value.
Definition: pixelkey_commands.h:93
float f32
Float config value.
Definition: pixelkey_commands.h:94
value_type_t value_type
Type for value.
Definition: pixelkey_commands.h:90
bool b
Boolean config value.
Definition: pixelkey_commands.h:95
Arguments for repeat keyframe modifier command.
Definition: pixelkey_commands.h:119
int32_t repeat_count
Number of repeats to perform, -1 is indefinite, 0 = 1.
Definition: pixelkey_commands.h:120
Arguments for schedule keyframe modifier command.
Definition: pixelkey_commands.h:125
Command which wraps a keyframe.
Definition: pixelkey_commands.h:74
keyframe_base_t * p_keyframe
Pointer to the parsed keyframe.
Definition: pixelkey_commands.h:75
Arguments to time-set command.
Definition: pixelkey_commands.h:102
uint8_t tz_minute
Time-zone minute offset.
Definition: pixelkey_commands.h:113
uint8_t second
Second.
Definition: pixelkey_commands.h:111
uint8_t minute
Minute.
Definition: pixelkey_commands.h:110
uint8_t day
Day.
Definition: pixelkey_commands.h:108
uint8_t tz_hour
Time-zone hour offset (MSB signifies sign).
Definition: pixelkey_commands.h:112
uint8_t hour
Hour (24).
Definition: pixelkey_commands.h:109
uint16_t year
Year.
Definition: pixelkey_commands.h:106
uint8_t month
Month.
Definition: pixelkey_commands.h:107
Parsed command list.
Definition: pixelkey_commands.h:138
struct st_cmd_list * p_next
Pointer to the next command list element.
Definition: pixelkey_commands.h:140
cmd_t * p_cmd
Pointer to the current command.
Definition: pixelkey_commands.h:139
Parsed command and arguments.
Definition: pixelkey_commands.h:131
cmd_type_t type
Command type.
Definition: pixelkey_commands.h:132
void * p_args
Pointer to command arguments.
Definition: pixelkey_commands.h:133