@@ -59,6 +59,7 @@ float brightness_scale = 1.0f;
5959uint8_t minumum_brightness = 75 ;
6060std::string initial_colorset_str = " " ;
6161std::string initial_pattern_str = " " ;
62+ std::string initial_pattern_args_str = " " ;
6263uint32_t initial_mode_index = 0 ;
6364
6465// used to switch terminal to non-blocking and back
@@ -106,6 +107,27 @@ int main(int argc, char *argv[])
106107 // re-initialize the current pattern
107108 Helios::cur_pattern ().init ();
108109 }
110+ // set initial pattern args based on user arguments
111+ if (initial_pattern_args_str.length () > 0 ) {
112+ // parse the list of args into an array of ints
113+ std::vector<uint32_t > vals;
114+ std::istringstream ss (initial_pattern_args_str);
115+ // push 6 args into the array
116+ while (vals.size () < 6 ) {
117+ std::string arg;
118+ uint32_t val = 0 ;
119+ // try to parse out a number
120+ if (std::getline (ss, arg, ' ,' )) {
121+ val = strtoul (arg.c_str (), NULL , 10 );
122+ }
123+ // push the val either 0 or parsed number
124+ vals.push_back (val);
125+ }
126+ // construct pattern args from the array of values
127+ PatternArgs args (vals[0 ], vals[1 ], vals[2 ], vals[3 ], vals[4 ], vals[5 ]);
128+ // set the args of the current pattern
129+ Helios::cur_pattern ().setArgs (args);
130+ }
109131 // Set the initial colorset based on user arguments
110132 if (initial_colorset_str.length () > 0 ) {
111133 std::stringstream ss (initial_colorset_str);
@@ -206,14 +228,15 @@ static void parse_options(int argc, char *argv[])
206228 {" min-brightness" , required_argument, nullptr , ' m' },
207229 {" colorset" , required_argument, nullptr , ' C' },
208230 {" pattern" , required_argument, nullptr , ' P' },
231+ {" pattern-args" , required_argument, nullptr , ' A' },
209232 {" mode-index" , required_argument, nullptr , ' I' },
210233 {" bmp" , optional_argument, nullptr , ' b' },
211234 {" eeprom" , no_argument, nullptr , ' E' },
212235 {" parse-save" , required_argument, nullptr , ' S' },
213236 {" help" , no_argument, nullptr , ' h' },
214237 {nullptr , 0 , nullptr , 0 }
215238 };
216- while ((opt = getopt_long (argc, argv, " xcqltisyamC:P:I:b::ES:h" , long_options, &option_index)) != -1 ) {
239+ while ((opt = getopt_long (argc, argv, " xcqltisyamC:P:A: I:b::ES:h" , long_options, &option_index)) != -1 ) {
217240 switch (opt) {
218241 case ' x' :
219242 // if the user wants pretty colors or hex codes
@@ -292,6 +315,10 @@ static void parse_options(int argc, char *argv[])
292315 // set the initial pattern from the string
293316 initial_pattern_str = optarg;
294317 break ;
318+ case ' A' :
319+ // set the initial pattern args from the string
320+ initial_pattern_args_str = optarg;
321+ break ;
295322 case ' I' :
296323 // set the initial mode index
297324 initial_mode_index = strtoul (optarg, NULL , 10 );
@@ -534,6 +561,7 @@ static void print_usage(const char* program_name)
534561 fprintf (stderr, " Initial Pattern and Colorset (optional):\n " );
535562 fprintf (stderr, " -C, --colorset Set the colorset of the first mode, ex: red,green,0x0000ff\n " );
536563 fprintf (stderr, " -P, --pattern Set the pattern of the first mode, ex: 1 or blend\n " );
564+ fprintf (stderr, " -A, --pattern-args Set the pattern args of the first mode, ex: 1,2,3 or 1,2,3,4,5\n " );
537565 fprintf (stderr, " -I, --mode-index Set the initial mode index, ex 4\n " );
538566 fprintf (stderr, " \n " );
539567 fprintf (stderr, " Other Options:\n " );
0 commit comments