This commit is contained in:
parent
9a7da25043
commit
d9911a4d68
4 changed files with 209 additions and 168 deletions
|
@ -106,11 +106,11 @@ EXAMPLE:
|
|||
#### Turn off backlight (user selects: channel)
|
||||
```
|
||||
↓↓↓↓↓↓-----------------------|
|
||||
cc2204000000000000000001ff ← 1 |‾‾|‾‾‾‾‾‾‾‾‾‾‾1|
|
||||
cc2204000000000000000001ff ← 1 |‾‾|‾‾‾‾‾‾‾‾‾‾‾4|
|
||||
cc2410000000000000000001ff ← 2 | 6| |‾‾| |||| |
|
||||
cc2520000000000000000001ff ← 3 | | ‾‾ |||| |
|
||||
cc2640000000000000000001ff ← 4 |__| |‾‾‾| |
|
||||
cc2780000000000000000001ff ← 5 | |_4_| |
|
||||
cc2780000000000000000001ff ← 5 | |_1_| |
|
||||
cc9100020000000000000001ff ← 6 |___2_3_5_______|
|
||||
cc28ff07
|
||||
```
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include "commands.c"
|
||||
#include "iousb.c"
|
||||
|
||||
enum synchronized_commands { SYNC_COLOR, SYNC_WAVE, SYNC_WAVE2, SYNC_OFF, SPEC_IMPULSE }
|
||||
synchronized_commands;
|
||||
|
||||
struct separate_c{
|
||||
char *command1, *command2, *command3, *command4, *command5, *command6;
|
||||
int red1, red2, red3, red4, red5, red6;
|
||||
|
@ -29,6 +32,9 @@ struct separate_c{
|
|||
int intensity1, intensity2, intensity3, intensity4, intensity5, intensity6;
|
||||
} sc;
|
||||
|
||||
separate_commands_set s;
|
||||
enum synchronized_commands sync_cmd;
|
||||
|
||||
void parse_color(char *color, unsigned int *red, unsigned int *green, unsigned int *blue ){
|
||||
if (strlen(color) != 6){
|
||||
printf("Incorrect color: \"%s\". Using default: \"ffffff\"\n", color);
|
||||
|
@ -59,26 +65,30 @@ int parse_brightness(char *brightness){
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sync_flow(char* command, unsigned int red, unsigned int green, unsigned int blue){
|
||||
if (strcmp(command, "wave") == 0)
|
||||
return wave1();
|
||||
int prepare_sync(char* command){
|
||||
if (strcmp(command, "") == 0)
|
||||
sync_cmd = SYNC_COLOR;
|
||||
else if (strcmp(command, "wave") == 0)
|
||||
sync_cmd = SYNC_WAVE;
|
||||
else if (strcmp(command, "wave2") == 0)
|
||||
return wave2();
|
||||
sync_cmd = SYNC_WAVE2;
|
||||
else if (strcmp(command, "color") == 0)
|
||||
return staticColorSync(red, green, blue);
|
||||
sync_cmd = SYNC_COLOR;
|
||||
else if (strcmp(command, "off") == 0)
|
||||
return turnOffBacklightSync();
|
||||
sync_cmd = SYNC_OFF;
|
||||
else if (strcmp(command, "impulse") == 0)
|
||||
sync_cmd = SPEC_IMPULSE;
|
||||
else{
|
||||
printf("Invalid command \"%s\"\n"
|
||||
"Allowed: color wave wave2 off\n", command);
|
||||
|
||||
return staticColorSync(red, green, blue); // TODO: refactor; leave information block and nothing instead
|
||||
"Allowed: color wave wave2 off\n", command);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_single_separate(static_commands_set *s, int dev_number, char *command,
|
||||
int red, int green, int blue,
|
||||
int brightness, int intensity){
|
||||
int make_separate_command(separate_commands_set *s, int dev_number, char *command,
|
||||
int red, int green, int blue,
|
||||
int brightness, int intensity){
|
||||
if (strcmp(command, "color") == 0){
|
||||
if (staticOneColor(dev_number, s, brightness, red, green, blue))
|
||||
return -1;
|
||||
|
@ -104,38 +114,57 @@ int parse_single_separate(static_commands_set *s, int dev_number, char *command,
|
|||
return -1;
|
||||
}
|
||||
else{
|
||||
printf("Invalid command \"%s\"\n"
|
||||
"Allowed: color off impulse flash flash2 cycle\n", command);
|
||||
printf("Invalid command --z%d=%s\n"
|
||||
"Allowed: color off impulse flash flash2 cycle\n", dev_number, command);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int separate_flow(){
|
||||
int make_separate_commands_set(){
|
||||
if (make_separate_command(&s, 1, sc.command1, sc.red1, sc.green1, sc.blue1, sc.brightness1, sc.intensity1))
|
||||
return -1;
|
||||
if (make_separate_command(&s, 2, sc.command2, sc.red2, sc.green2, sc.blue2, sc.brightness2, sc.intensity2))
|
||||
return -1;
|
||||
if (make_separate_command(&s, 3, sc.command3, sc.red3, sc.green3, sc.blue3, sc.brightness3, sc.intensity3))
|
||||
return -1;
|
||||
if (make_separate_command(&s, 4, sc.command4, sc.red4, sc.green4, sc.blue4, sc.brightness4, sc.intensity4))
|
||||
return -1;
|
||||
if (make_separate_command(&s, 5, sc.command5, sc.red5, sc.green5, sc.blue5, sc.brightness5, sc.intensity5))
|
||||
return -1;
|
||||
if (make_separate_command(&s, 6, sc.command6, sc.red6, sc.green6, sc.blue6, sc.brightness6, sc.intensity6))
|
||||
return -1;
|
||||
|
||||
static_commands_set s;
|
||||
|
||||
if (parse_single_separate(&s, 1, sc.command1, sc.red1, sc.green1, sc.blue1, sc.brightness1, sc.intensity1))
|
||||
return staticColorSync(sc.red1, sc.green1, sc.blue1); // TODO: FIX ME
|
||||
if (parse_single_separate(&s, 2, sc.command2, sc.red2, sc.green2, sc.blue2, sc.brightness2, sc.intensity2))
|
||||
return staticColorSync(sc.red2, sc.green2, sc.blue2); // TODO: FIX ME
|
||||
if (parse_single_separate(&s, 3, sc.command3, sc.red3, sc.green3, sc.blue3, sc.brightness3, sc.intensity3))
|
||||
return staticColorSync(sc.red3, sc.green3, sc.blue3); // TODO: FIX ME
|
||||
if (parse_single_separate(&s, 4, sc.command4, sc.red4, sc.green4, sc.blue4, sc.brightness4, sc.intensity4))
|
||||
return staticColorSync(sc.red4, sc.green4, sc.blue4); // TODO: FIX ME
|
||||
if (parse_single_separate(&s, 5, sc.command5, sc.red5, sc.green5, sc.blue5, sc.brightness5, sc.intensity5))
|
||||
return staticColorSync(sc.red5, sc.green5, sc.blue5); // TODO: FIX ME
|
||||
if (parse_single_separate(&s, 6, sc.command6, sc.red6, sc.green6, sc.blue6, sc.brightness6, sc.intensity6))
|
||||
return staticColorSync(sc.red6, sc.green6, sc.blue6); // TODO: FIX ME
|
||||
return 0;
|
||||
}
|
||||
|
||||
return runStaticCommand(s);
|
||||
int sync_flow(unsigned int red, unsigned int green, unsigned int blue){
|
||||
switch (sync_cmd){
|
||||
case SYNC_COLOR:
|
||||
return staticColorSync(red, green, blue);
|
||||
case SYNC_WAVE:
|
||||
return wave1();
|
||||
case SYNC_WAVE2:
|
||||
return wave2();
|
||||
case SYNC_OFF:
|
||||
return turnOffBacklightSync();
|
||||
case SPEC_IMPULSE:
|
||||
make_separate_command(&s, 1, "impulse", red, green, blue, 4, 4);
|
||||
make_separate_command(&s, 2, "impulse", red, green, blue, 4, 4);
|
||||
make_separate_command(&s, 3, "impulse", red, green, blue, 4, 4);
|
||||
make_separate_command(&s, 4, "impulse", red, green, blue, 4, 4);
|
||||
make_separate_command(&s, 5, "impulse", red, green, blue, 4, 4);
|
||||
make_separate_command(&s, 6, "impulse", red, green, blue, 4, 4);
|
||||
return runStaticCommand(s);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
struct arguments arguments;
|
||||
/* Default values. */
|
||||
/* Defaults. */
|
||||
arguments.quiet = 0;
|
||||
arguments.sync = 0;
|
||||
arguments.separate = 0;
|
||||
|
@ -146,10 +175,10 @@ int main(int argc, char *argv[]) {
|
|||
arguments.b1 = arguments.b2 = arguments.b3 = arguments.b4 =
|
||||
arguments.b5 = arguments.b6 = arguments.brightness = "4";
|
||||
arguments.z1 = arguments.z2 = arguments.z3 =
|
||||
arguments.z4 = arguments.z5 = arguments.z6 = "-";
|
||||
arguments.z4 = arguments.z5 = arguments.z6 = "???";
|
||||
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
|
||||
|
||||
if (arguments.quiet)
|
||||
freopen("/dev/null", "a", stdout);
|
||||
|
||||
|
@ -162,7 +191,7 @@ int main(int argc, char *argv[]) {
|
|||
parse_color(arguments.color, &red, &green, &blue);
|
||||
brightness = parse_brightness(arguments.brightness);
|
||||
|
||||
if (arguments.separate == 1){
|
||||
if (arguments.separate == 1){
|
||||
sc.command1 = arguments.z1;
|
||||
sc.command2 = arguments.z2;
|
||||
sc.command3 = arguments.z3;
|
||||
|
@ -190,7 +219,12 @@ int main(int argc, char *argv[]) {
|
|||
sc.intensity4 = parse_brightness(arguments.i4);
|
||||
sc.intensity5 = parse_brightness(arguments.i5);
|
||||
sc.intensity6 = parse_brightness(arguments.i6);
|
||||
|
||||
if (make_separate_commands_set(&sc))
|
||||
return -1;
|
||||
}
|
||||
else if (prepare_sync(arguments.args[0]))
|
||||
return -1;
|
||||
|
||||
// - - -
|
||||
int ret = configure_device();
|
||||
|
@ -210,27 +244,17 @@ int main(int argc, char *argv[]) {
|
|||
printf("Initialization sequence sent\n");
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
if (arguments.sync == 1){ // Sync flow
|
||||
if (sync_flow(arguments.args[0], red, green, blue)){
|
||||
if (arguments.separate == 1){ // Separate flow
|
||||
if (runStaticCommand(s)){
|
||||
printf("Command transfer failure\n");
|
||||
libusb_close(dev_handle);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (arguments.separate == 1){ // Separate flow
|
||||
if (separate_flow(&sc)){
|
||||
printf("Command transfer failure\n");
|
||||
libusb_close(dev_handle);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(staticColorSync(red, green, blue)){ // Executed neither for sync, nor for separate => set single color
|
||||
printf("Command transfer failure\n");
|
||||
libusb_close(dev_handle);
|
||||
return -1;
|
||||
}
|
||||
else if (sync_flow(red, green, blue)){ // Sync & not-defined
|
||||
printf("Command transfer failure\n");
|
||||
libusb_close(dev_handle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (terminate_sequence()){
|
||||
|
|
|
@ -186,12 +186,12 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state){
|
|||
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);
|
||||
if (state->arg_num < 1)
|
||||
arguments->args[0] = "";
|
||||
break;
|
||||
*/
|
||||
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
|
239
src/commands.c
239
src/commands.c
|
@ -139,7 +139,7 @@ int staticColorSync(unsigned char red, unsigned char green, unsigned char blue){
|
|||
if(64 != writeUsb(end_transaction))
|
||||
return 1;
|
||||
|
||||
printf("One color (Sync) applied\n");
|
||||
printf("One color %02x%02x%02x (Sync) applied\n", red, green, blue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -160,13 +160,13 @@ typedef struct {
|
|||
STATIC_EFFECT name4;
|
||||
STATIC_EFFECT name5;
|
||||
STATIC_EFFECT name6;
|
||||
unsigned char* dir1;
|
||||
unsigned char* dir2;
|
||||
unsigned char* dir3;
|
||||
unsigned char* dir4;
|
||||
unsigned char* dir5;
|
||||
unsigned char* dir6;
|
||||
} static_commands_set;
|
||||
unsigned char dir1[64];
|
||||
unsigned char dir2[64];
|
||||
unsigned char dir3[64];
|
||||
unsigned char dir4[64];
|
||||
unsigned char dir5[64];
|
||||
unsigned char dir6[64];
|
||||
} separate_commands_set;
|
||||
|
||||
void print_ext_report(STATIC_EFFECT effect){
|
||||
switch (effect)
|
||||
|
@ -192,8 +192,7 @@ void print_ext_report(STATIC_EFFECT effect){
|
|||
}
|
||||
}
|
||||
|
||||
int runStaticCommand(static_commands_set c_set){
|
||||
|
||||
int runStaticCommand(separate_commands_set c_set){
|
||||
if (prefix())
|
||||
return 1;
|
||||
|
||||
|
@ -232,9 +231,7 @@ int runStaticCommand(static_commands_set c_set){
|
|||
return 0;
|
||||
}
|
||||
|
||||
//int staticOneColor(int dev_number, unsigned char* save_to, int brightness, unsigned char red, unsigned char green, unsigned char blue){
|
||||
int staticOneColor(int dev_number, static_commands_set *s, int brightness, unsigned char red, unsigned char green, unsigned char blue){
|
||||
|
||||
int staticOneColor(int dev_number, separate_commands_set *s, int brightness, unsigned char red, unsigned char green, unsigned char blue){
|
||||
unsigned char brgt;
|
||||
|
||||
switch (brightness){
|
||||
|
@ -261,27 +258,27 @@ int staticOneColor(int dev_number, static_commands_set *s, int brightness, unsig
|
|||
switch (dev_number){
|
||||
case 1: //cc 22 04 00 00 00 00 00 00 00 00 01 __ 00 __ __ __
|
||||
s->name1 = EFFECT_COLOR;
|
||||
s->dir1 = (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, };
|
||||
memcpy(s->dir1, (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, }, 64);
|
||||
break;
|
||||
case 2: //cc 24 10 00 00 00 00 00 00 00 00 01 __ 00 __ __ __
|
||||
s->name2 = EFFECT_COLOR;
|
||||
s->dir2 = (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, };
|
||||
memcpy(s->dir2, (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, }, 64);
|
||||
break;
|
||||
case 3: //cc 25 20 00 00 00 00 00 00 00 00 01 __ 00 __ __ __
|
||||
s->name3 = EFFECT_COLOR;
|
||||
s->dir3 = (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, };
|
||||
memcpy(s->dir3, (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, }, 64);
|
||||
break;
|
||||
case 4: //cc 26 40 00 00 00 00 00 00 00 00 01 __ 00 __ __ __
|
||||
s->name4 = EFFECT_COLOR;
|
||||
s->dir4 = (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, };
|
||||
memcpy(s->dir4, (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, }, 64);
|
||||
break;
|
||||
case 5: //cc 27 80 00 00 00 00 00 00 00 00 01 __ 00 __ __ __
|
||||
s->name5 = EFFECT_COLOR;
|
||||
s->dir5 = (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, };
|
||||
memcpy(s->dir5, (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, }, 64);
|
||||
break;
|
||||
case 6: //cc 91 00 02 00 00 00 00 00 00 00 01 __ 00 __ __ __
|
||||
s->name6 = EFFECT_COLOR;
|
||||
s->dir6 = (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, };
|
||||
memcpy(s->dir6, (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, brgt, 0x00, blue, green, red, }, 64);
|
||||
break;
|
||||
default:
|
||||
printf("Device number must be in range of 1..6\n");
|
||||
|
@ -291,31 +288,31 @@ int staticOneColor(int dev_number, static_commands_set *s, int brightness, unsig
|
|||
return 0;
|
||||
}
|
||||
|
||||
int staticOff(int dev_number, static_commands_set *s){
|
||||
int staticOff(int dev_number, separate_commands_set *s){
|
||||
switch (dev_number){
|
||||
case 1: //cc 22 04 00 00 00 00 00 00 00 00 01 ff
|
||||
s->name1 = EFFECT_OFF;
|
||||
s->dir1 = (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, };
|
||||
memcpy(s->dir1, (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, }, 64);
|
||||
break;
|
||||
case 2: //cc 24 10 00 00 00 00 00 00 00 00 01 ff
|
||||
s->name2 = EFFECT_OFF;
|
||||
s->dir2 = (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, };
|
||||
memcpy(s->dir2, (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, }, 64);
|
||||
break;
|
||||
case 3: //cc 25 20 00 00 00 00 00 00 00 00 01 ff
|
||||
s->name3 = EFFECT_OFF;
|
||||
s->dir3 = (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, };
|
||||
memcpy(s->dir3, (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, }, 64);
|
||||
break;
|
||||
case 4: //cc 26 40 00 00 00 00 00 00 00 00 01 ff
|
||||
s->name4 = EFFECT_OFF;
|
||||
s->dir4 = (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, };
|
||||
memcpy(s->dir4, (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, }, 64);
|
||||
break;
|
||||
case 5: //cc 27 80 00 00 00 00 00 00 00 00 01 ff
|
||||
s->name5 = EFFECT_OFF;
|
||||
s->dir5 = (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, };
|
||||
memcpy(s->dir5, (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, }, 64);
|
||||
break;
|
||||
case 6: //cc 91 00 02 00 00 00 00 00 00 00 01 ff
|
||||
s->name6 = EFFECT_OFF;
|
||||
s->dir6 = (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, };
|
||||
memcpy(s->dir6, (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, }, 64);
|
||||
break;
|
||||
default:
|
||||
printf("Device number must be in range of 1..6\n");
|
||||
|
@ -325,24 +322,30 @@ int staticOff(int dev_number, static_commands_set *s){
|
|||
return 0;
|
||||
}
|
||||
|
||||
int staticImpulse(int dev_number, static_commands_set *s, int intensity, unsigned char red, unsigned char green, unsigned char blue){
|
||||
unsigned char *I;
|
||||
int staticImpulse(int dev_number, separate_commands_set *s, int intensity, unsigned char red, unsigned char green, unsigned char blue){
|
||||
unsigned char intensity0[6] = { 0x40, 0x06, 0x40, 0x06, 0x20, 0x03 }; // 400640062003
|
||||
unsigned char intensity1[6] = { 0xb0, 0x04, 0xb0, 0x04, 0xf4, 0x01 }; // b004b004f401
|
||||
unsigned char intensity2[6] = { 0x84, 0x03, 0x84, 0x03, 0xc2, 0x01 }; // 84038403c201
|
||||
unsigned char intensity3[6] = { 0xbc, 0x02, 0xbc, 0x02, 0x5e, 0x01 }; // bc02bc025e01
|
||||
unsigned char intensity4[6] = { 0xf4, 0x01, 0xf4, 0x01, 0xfa, 0x00 }; // f401f401fa00
|
||||
|
||||
unsigned char* I;
|
||||
|
||||
switch (intensity){
|
||||
case 0:
|
||||
I = (unsigned char [6]) { 0x40, 0x06, 0x40, 0x06, 0x20, 0x03 }; // 400640062003
|
||||
I = intensity0;
|
||||
break;
|
||||
case 1:
|
||||
I = (unsigned char [6]) { 0xb0, 0x04, 0xb0, 0x04, 0xf4, 0x01 }; // b004b004f401
|
||||
I = intensity1;
|
||||
break;
|
||||
case 2:
|
||||
I = (unsigned char [6]) { 0x84, 0x03, 0x84, 0x03, 0xc2, 0x01 }; // 84038403c201
|
||||
I = intensity2;
|
||||
break;
|
||||
case 3:
|
||||
I = (unsigned char [6]) { 0xbc, 0x02, 0xbc, 0x02, 0x5e, 0x01 }; // bc02bc025e01
|
||||
I = intensity3;
|
||||
break;
|
||||
case 4:
|
||||
I = (unsigned char [6]) { 0xf4, 0x01, 0xf4, 0x01, 0xfa, 0x00 }; // f401f401fa00
|
||||
I = intensity4;
|
||||
break;
|
||||
default:
|
||||
printf("Intensity must be in range of 0..4\n");
|
||||
|
@ -352,33 +355,33 @@ int staticImpulse(int dev_number, static_commands_set *s, int intensity, unsigne
|
|||
switch (dev_number){
|
||||
case 1: //cc 22 04 00 00 00 00 00 00 00 00 02 64 00 __ __ __ 00 00 00 00 00 __ __ __ __ __ __ 00 00 00 01
|
||||
s->name1 = EFFECT_IMPULSE;
|
||||
s->dir1 = (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, };
|
||||
memcpy(s->dir1, (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, }, 64);
|
||||
break;
|
||||
case 2: //cc 24 10 00 00 00 00 00 00 00 00 02 64 00 __ __ __ 00 00 00 00 00 __ __ __ __ __ __ 00 00 00 01
|
||||
s->name2 = EFFECT_IMPULSE;
|
||||
s->dir2 = (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, };
|
||||
memcpy(s->dir2, (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, }, 64);
|
||||
break;
|
||||
case 3: //cc 25 20 00 00 00 00 00 00 00 00 02 64 00 __ __ __ 00 00 00 00 00 __ __ __ __ __ __ 00 00 00 01
|
||||
s->name3 = EFFECT_IMPULSE;
|
||||
s->dir3 = (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, };
|
||||
memcpy(s->dir3, (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, }, 64);
|
||||
break;
|
||||
case 4: //cc 26 40 00 00 00 00 00 00 00 00 02 64 00 __ __ __ 00 00 00 00 00 __ __ __ __ __ __ 00 00 00 01
|
||||
s->name4 = EFFECT_IMPULSE;
|
||||
s->dir4 = (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, };
|
||||
memcpy(s->dir4, (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, }, 64);
|
||||
break;
|
||||
case 5: //cc 27 80 00 00 00 00 00 00 00 00 02 64 00 __ __ __ 00 00 00 00 00 __ __ __ __ __ __ 00 00 00 01
|
||||
s->name5 = EFFECT_IMPULSE;
|
||||
s->dir5 = (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, };
|
||||
memcpy(s->dir5, (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, }, 64);
|
||||
break;
|
||||
case 6: //cc 91 00 02 00 00 00 00 00 00 00 02 64 00 __ __ __ 00 00 00 00 00 __ __ __ __ __ __ 00 00 00 01
|
||||
s->name6 = EFFECT_IMPULSE;
|
||||
s->dir6 = (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, };
|
||||
memcpy(s->dir6, (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], I[4], I[5], 0x00, 0x00, 0x00, 0x01, }, 64);
|
||||
break;
|
||||
default:
|
||||
printf("Device number must be in range of 1..6\n");
|
||||
|
@ -389,7 +392,7 @@ int staticImpulse(int dev_number, static_commands_set *s, int intensity, unsigne
|
|||
}
|
||||
// flash - 1 = brighness; 2 - frequency
|
||||
|
||||
int staticFlash(int dev_number, static_commands_set *s, int brightness, int frequency, unsigned char red, unsigned char green, unsigned char blue){
|
||||
int staticFlash(int dev_number, separate_commands_set *s, int brightness, int frequency, unsigned char red, unsigned char green, unsigned char blue){
|
||||
|
||||
unsigned char brgt;
|
||||
|
||||
|
@ -414,23 +417,28 @@ int staticFlash(int dev_number, static_commands_set *s, int brightness, int freq
|
|||
return 1;
|
||||
}
|
||||
|
||||
unsigned char *F;
|
||||
unsigned char F[2];
|
||||
|
||||
switch (frequency){
|
||||
case 0:
|
||||
F = (unsigned char [2]) { 0x60, 0x09 }; // 6009
|
||||
F[0] = 0x60; // 6009
|
||||
F[1] = 0x09;
|
||||
break;
|
||||
case 1:
|
||||
F = (unsigned char [2]) { 0xd0, 0x07 }; // d007
|
||||
F[0] = 0xd0; // d007
|
||||
F[1] = 0x07;
|
||||
break;
|
||||
case 2:
|
||||
F = (unsigned char [2]) { 0x40, 0x06 }; // 4006
|
||||
F[0] = 0x40; // 4006
|
||||
F[1] = 0x06;
|
||||
break;
|
||||
case 3:
|
||||
F = (unsigned char [2]) { 0xb0, 0x04 }; // b004
|
||||
F[0] = 0xb0; // b004
|
||||
F[1] = 0x04;
|
||||
break;
|
||||
case 4:
|
||||
F = (unsigned char [2]) { 0x20, 0x03 }; // 2003
|
||||
F[0] = 0x20; // 2003
|
||||
F[1] = 0x03;
|
||||
break;
|
||||
default:
|
||||
printf("Frequency must be in range of 0..4\n");
|
||||
|
@ -440,39 +448,39 @@ int staticFlash(int dev_number, static_commands_set *s, int brightness, int freq
|
|||
switch (dev_number){
|
||||
case 1: //cc 22 04 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 01
|
||||
s->name1 = EFFECT_FLASH;
|
||||
s->dir1 = (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, };
|
||||
memcpy(s->dir1, (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, }, 64);
|
||||
break;
|
||||
case 2: //cc 24 10 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 01
|
||||
s->name2 = EFFECT_FLASH;
|
||||
s->dir2 = (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, };
|
||||
memcpy(s->dir2, (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, }, 64);
|
||||
break;
|
||||
case 3: //cc 25 20 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 01
|
||||
s->name3 = EFFECT_FLASH;
|
||||
s->dir3 = (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, };
|
||||
memcpy(s->dir3, (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, }, 64);
|
||||
break;
|
||||
case 4: //cc 26 40 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 01
|
||||
s->name4 = EFFECT_FLASH;
|
||||
s->dir4 = (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, };
|
||||
memcpy(s->dir4, (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, }, 64);
|
||||
break;
|
||||
case 5: //cc 27 80 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 01
|
||||
s->name5 = EFFECT_FLASH;
|
||||
s->dir5 = (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, };
|
||||
memcpy(s->dir5, (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, }, 64);
|
||||
break;
|
||||
case 6: //cc 91 00 02 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 01
|
||||
s->name6 = EFFECT_FLASH;
|
||||
s->dir6 = (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, };
|
||||
memcpy(s->dir6, (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, }, 64);
|
||||
break;
|
||||
default:
|
||||
printf("Device number must be in range of 1..6\n");
|
||||
|
@ -482,8 +490,7 @@ int staticFlash(int dev_number, static_commands_set *s, int brightness, int freq
|
|||
return 0;
|
||||
}
|
||||
|
||||
int staticFlash2(int dev_number, static_commands_set *s, int brightness, int frequency, unsigned char red, unsigned char green, unsigned char blue){
|
||||
|
||||
int staticFlash2(int dev_number, separate_commands_set *s, int brightness, int frequency, unsigned char red, unsigned char green, unsigned char blue){
|
||||
unsigned char brgt;
|
||||
|
||||
switch (brightness){
|
||||
|
@ -507,23 +514,28 @@ int staticFlash2(int dev_number, static_commands_set *s, int brightness, int fre
|
|||
return 1;
|
||||
}
|
||||
|
||||
unsigned char *F;
|
||||
unsigned char F[2];
|
||||
|
||||
switch (frequency){
|
||||
case 0:
|
||||
F = (unsigned char [2]) { 0x28, 0x0a }; // 280a
|
||||
F[0] = 0x28; // 280a
|
||||
F[1] = 0x0a;
|
||||
break;
|
||||
case 1:
|
||||
F = (unsigned char [2]) { 0x98, 0x08 }; // 9808
|
||||
F[0] = 0x98; // 9808
|
||||
F[1] = 0x08;
|
||||
break;
|
||||
case 2:
|
||||
F = (unsigned char [2]) { 0x08, 0x07 }; // 0807
|
||||
F[0] = 0x08; // 0807
|
||||
F[1] = 0x07;
|
||||
break;
|
||||
case 3:
|
||||
F = (unsigned char [2]) { 0x78, 0x05 }; // 7805
|
||||
F[0] = 0x78; // 7805
|
||||
F[1] = 0x05;
|
||||
break;
|
||||
case 4:
|
||||
F = (unsigned char [2]) { 0xe8, 0x03 }; // e803
|
||||
F[0] = 0xe8; // e803
|
||||
F[1] = 0x03;
|
||||
break;
|
||||
default:
|
||||
printf("Frequency must be in range of 0..4\n");
|
||||
|
@ -533,39 +545,39 @@ int staticFlash2(int dev_number, static_commands_set *s, int brightness, int fre
|
|||
switch (dev_number){
|
||||
case 1: //cc 22 04 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 02
|
||||
s->name1 = EFFECT_DOUBLE_FLASH;
|
||||
s->dir1 = (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
memcpy(s->dir1, (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, };
|
||||
0x02, }, 64);
|
||||
break;
|
||||
case 2: //cc 24 10 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 02
|
||||
s->name2 = EFFECT_DOUBLE_FLASH;
|
||||
s->dir2 = (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
memcpy(s->dir2, (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, };
|
||||
0x02, }, 64);
|
||||
break;
|
||||
case 3: //cc 25 20 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 02
|
||||
s->name3 = EFFECT_DOUBLE_FLASH;
|
||||
s->dir3 = (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
memcpy(s->dir3, (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, };
|
||||
0x02, }, 64);
|
||||
break;
|
||||
case 4: //cc 26 40 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 02
|
||||
s->name4 = EFFECT_DOUBLE_FLASH;
|
||||
s->dir4 = (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
memcpy(s->dir4, (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, };
|
||||
0x02, }, 64);
|
||||
break;
|
||||
case 5: //cc 27 80 00 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 02
|
||||
s->name5 = EFFECT_DOUBLE_FLASH;
|
||||
s->dir5 = (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
memcpy(s->dir5, (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, };
|
||||
0x02, }, 64);
|
||||
break;
|
||||
case 6: //cc 91 00 02 00 00 00 00 00 00 00 03 __ 00 __ __ __ 00 00 00 00 00 64 00 64 00 __ __ 00 00 00 01 02
|
||||
s->name6 = EFFECT_DOUBLE_FLASH;
|
||||
s->dir6 = (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
memcpy(s->dir6, (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, brgt, 0x00, blue, green,
|
||||
red, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x64, 0x00, F[0], F[1], 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, };
|
||||
0x02, }, 64);
|
||||
break;
|
||||
default:
|
||||
printf("Device number must be in range of 1..6\n");
|
||||
|
@ -575,8 +587,7 @@ int staticFlash2(int dev_number, static_commands_set *s, int brightness, int fre
|
|||
return 0;
|
||||
}
|
||||
|
||||
int staticCycle(int dev_number, static_commands_set *s, int intensity, int brightness){
|
||||
|
||||
int staticCycle(int dev_number, separate_commands_set *s, int intensity, int brightness){
|
||||
unsigned char brgt;
|
||||
switch (brightness){
|
||||
case 0:
|
||||
|
@ -599,58 +610,64 @@ int staticCycle(int dev_number, static_commands_set *s, int intensity, int brigh
|
|||
return 1;
|
||||
}
|
||||
|
||||
unsigned char *I;
|
||||
unsigned char intensity0[4] = { 0x78, 0x05, 0xb0, 0x04 }; // 7805b004
|
||||
unsigned char intensity1[4] = { 0x52, 0x03, 0xee, 0x02 }; // 5203ee02
|
||||
unsigned char intensity2[4] = { 0x26, 0x02, 0xc2, 0x01 }; // 2602c201
|
||||
unsigned char intensity3[4] = { 0x58, 0x02, 0x90, 0x01 }; // 58029001
|
||||
unsigned char intensity4[4] = { 0x90, 0x01, 0xc8, 0x00 }; // 9001c800
|
||||
|
||||
unsigned char* I;
|
||||
switch (intensity){
|
||||
case 0:
|
||||
I = (unsigned char [4]) { 0x78, 0x05, 0xb0, 0x04 }; // 7805b004
|
||||
I = intensity0;
|
||||
break;
|
||||
case 1:
|
||||
I = (unsigned char [4]) { 0x52, 0x03, 0xee, 0x02 }; // 5203ee02
|
||||
I = intensity1;
|
||||
break;
|
||||
case 2:
|
||||
I = (unsigned char [4]) { 0x26, 0x02, 0xc2, 0x01 }; // 2602c201
|
||||
I = intensity2;
|
||||
break;
|
||||
case 3:
|
||||
I = (unsigned char [4]) { 0x58, 0x02, 0x90, 0x01 }; // 58029001
|
||||
I = intensity3;
|
||||
break;
|
||||
case 4:
|
||||
I = (unsigned char [4]) { 0x90, 0x01, 0xc8, 0x00 }; // 9001c800
|
||||
I = intensity4;
|
||||
break;
|
||||
default:
|
||||
printf("Intensity must be in range of 0..4\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (dev_number){
|
||||
switch (dev_number){
|
||||
case 1: //cc 22 04 00 00 00 00 00 00 00 00 04 __ 00 fd 00 fe 00 00 00 00 00 __ __ __ __ 00 00 00 00 07
|
||||
s->name1 = EFFECT_CYCLE;
|
||||
s->dir1 = (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, };
|
||||
memcpy(s->dir1, (unsigned char [64]){ 0xcc, 0x22, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, }, 64);
|
||||
break;
|
||||
case 2: //cc 24 10 00 00 00 00 00 00 00 00 04 __ 00 fd 00 fe 00 00 00 00 00 __ __ __ __ 00 00 00 00 07
|
||||
s->name2 = EFFECT_CYCLE;
|
||||
s->dir2 = (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, };
|
||||
memcpy(s->dir2, (unsigned char [64]){ 0xcc, 0x24, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, }, 64);
|
||||
break;
|
||||
case 3: //cc 25 20 00 00 00 00 00 00 00 00 04 __ 00 fd 00 fe 00 00 00 00 00 __ __ __ __ 00 00 00 00 07
|
||||
s->name3 = EFFECT_CYCLE;
|
||||
s->dir3 = (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, };
|
||||
memcpy(s->dir3, (unsigned char [64]){ 0xcc, 0x25, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, }, 64);
|
||||
break;
|
||||
case 4: //cc 26 40 00 00 00 00 00 00 00 00 04 __ 00 fd 00 fe 00 00 00 00 00 __ __ __ __ 00 00 00 00 07
|
||||
s->name4 = EFFECT_CYCLE;
|
||||
s->dir4 = (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, };
|
||||
memcpy(s->dir4, (unsigned char [64]){ 0xcc, 0x26, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, }, 64);
|
||||
break;
|
||||
case 5: //cc 27 80 00 00 00 00 00 00 00 00 04 __ 00 fd 00 fe 00 00 00 00 00 __ __ __ __ 00 00 00 00 07
|
||||
s->name5 = EFFECT_CYCLE;
|
||||
s->dir5 = (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, };
|
||||
memcpy(s->dir5, (unsigned char [64]){ 0xcc, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, }, 64);
|
||||
break;
|
||||
case 6: //cc 91 00 02 00 00 00 00 00 00 00 04 __ 00 fd 00 fe 00 00 00 00 00 __ __ __ __ 00 00 00 00 07
|
||||
s->name6 = EFFECT_CYCLE;
|
||||
s->dir6 = (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, };
|
||||
memcpy(s->dir6, (unsigned char [64]){ 0xcc, 0x91, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, brgt, 0x00, 0xfd, 0x00,
|
||||
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, I[0], I[1], I[2], I[3], 0x00, 0x00, 0x00, 0x00, 0x07, }, 64);
|
||||
break;
|
||||
default:
|
||||
printf("Device number must be in range of 1..6\n");
|
||||
|
|
Loading…
Reference in a new issue