some minor corrections to make variations work
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
e2febb5686
commit
11a9cf32e6
1 changed files with 44 additions and 39 deletions
|
@ -21,22 +21,18 @@
|
||||||
#include "iousb.c"
|
#include "iousb.c"
|
||||||
const char *argp_program_version = "argbColor 0.1";
|
const char *argp_program_version = "argbColor 0.1";
|
||||||
const char *argp_program_bug_address = "https://github.com/developersu/argbColors/issues/";
|
const char *argp_program_bug_address = "https://github.com/developersu/argbColors/issues/";
|
||||||
static char doc[] = "TODO \
|
static char doc[] = "Application for adjusting backlight";
|
||||||
TODO \
|
|
||||||
there should be a well structed description one day";
|
|
||||||
|
|
||||||
static char args_doc[] = "ARG1";
|
|
||||||
static struct argp_option options[] = {
|
static struct argp_option options[] = {
|
||||||
{"sync", 's', "COMMAND", 0, "Bypass synchronized command" },
|
{"sync", 's', "COMMAND", 0, "Synchronized command" },
|
||||||
{"separate", 'e', "COMMAND", 0, "Bypass separate command(s)" },
|
{"separate", 'e', "COMMAND", 0, "Separate command(s)" },
|
||||||
{"color", 'c', "RGB_COLOR", 0, "Define color" },
|
{"color", 'c', "RGB_COLOR", 0, "Define color (000000..ffffff)" },
|
||||||
{"brightness", 'b', "VALUE", 0, "Define brightness" },
|
{"brightness", 'b', "VALUE", 0, "Define brightness (0..5)" },
|
||||||
{"quiet", 'q', 0, 0, "Don't produce any output" },
|
{"quiet", 'q', 0, 0, "Don't produce any output" },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arguments{
|
struct arguments{
|
||||||
char *args[1];
|
|
||||||
int quiet;
|
int quiet;
|
||||||
char *sync;
|
char *sync;
|
||||||
char *separate;
|
char *separate;
|
||||||
|
@ -65,27 +61,13 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state){
|
||||||
case 'b':
|
case 'b':
|
||||||
arguments->brightness = arg;
|
arguments->brightness = arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARGP_KEY_ARG:
|
|
||||||
if (state->arg_num >= 1) /* Too many arguments. */
|
|
||||||
argp_usage(state);
|
|
||||||
|
|
||||||
arguments->args[state->arg_num] = arg;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ARGP_KEY_END:
|
|
||||||
if (state->arg_num < 1) /* Not enough arguments. */
|
|
||||||
argp_usage(state);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ARGP_ERR_UNKNOWN;
|
return ARGP_ERR_UNKNOWN;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct argp argp = { options, parse_opt, args_doc, doc };
|
static struct argp argp = { options, parse_opt, 0, doc };
|
||||||
|
|
||||||
int parse_color(char *color, unsigned int *red, unsigned int *green, unsigned int *blue ){
|
int parse_color(char *color, unsigned int *red, unsigned int *green, unsigned int *blue ){
|
||||||
printf("%s\n", color);
|
printf("%s\n", color);
|
||||||
|
@ -122,20 +104,18 @@ int main(int argc, char *argv[]) {
|
||||||
be reflected in arguments. */
|
be reflected in arguments. */
|
||||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||||
|
|
||||||
printf("ARG1 = %s\nSYNC = %s\nSEPARATE = %s\nCOLOR = %s\n"
|
|
||||||
"QUIET = %s\n",
|
|
||||||
arguments.args[0], arguments.args[1],
|
|
||||||
arguments.sync,
|
|
||||||
arguments.separate,
|
|
||||||
arguments.color,
|
|
||||||
arguments.quiet ? "yes" : "no");
|
|
||||||
|
|
||||||
unsigned int red, green, blue;
|
unsigned int red, green, blue;
|
||||||
|
|
||||||
if (parse_color(arguments.color, &red, &green, &blue) != 0){
|
if (parse_color(arguments.color, &red, &green, &blue) != 0){
|
||||||
printf("Color parse failure\n");
|
printf("Color parse failure\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int brightness = atoi(arguments.brightness);
|
||||||
|
if (brightness > 5)
|
||||||
|
brightness = 0;
|
||||||
|
|
||||||
|
printf("%s\n", arguments.sync);
|
||||||
|
|
||||||
// - - -
|
// - - -
|
||||||
int ret = configure_device();
|
int ret = configure_device();
|
||||||
if (ret != 0){
|
if (ret != 0){
|
||||||
|
@ -148,6 +128,35 @@ int main(int argc, char *argv[]) {
|
||||||
libusb_close(dev_handle);
|
libusb_close(dev_handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
// - - - - - - - - - - - - - -
|
||||||
|
if ((strcmp(arguments.sync, "-") == 0) && (strcmp(arguments.separate, "-") == 0)){
|
||||||
|
if(staticColorSync(red, green, blue)){
|
||||||
|
printf("Command transfer failure\n");
|
||||||
|
libusb_close(dev_handle);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(arguments.sync, "wave1") == 0){
|
||||||
|
if(wave1()){
|
||||||
|
printf("Command transfer failure\n");
|
||||||
|
libusb_close(dev_handle);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(arguments.sync, "wave2") == 0){
|
||||||
|
if(wave2()){
|
||||||
|
printf("Command transfer failure\n");
|
||||||
|
libusb_close(dev_handle);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(staticColorSync(red, green, blue)){
|
||||||
|
printf("Command transfer failure\n");
|
||||||
|
libusb_close(dev_handle);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
if (cycle(0, 4)){
|
if (cycle(0, 4)){
|
||||||
printf("Command transfer failure\n");
|
printf("Command transfer failure\n");
|
||||||
|
@ -161,11 +170,7 @@ int main(int argc, char *argv[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//*/
|
//*/
|
||||||
if(staticColorSync(red, green, blue)){
|
|
||||||
printf("Command transfer failure\n");
|
|
||||||
libusb_close(dev_handle);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (terminate_sequence()){
|
if (terminate_sequence()){
|
||||||
printf("Termination sequence transfer failure\n");
|
printf("Termination sequence transfer failure\n");
|
||||||
|
|
Loading…
Reference in a new issue