-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
20 changed files
with
1,868 additions
and
1,505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Version 4.0 | ||
|
||
* now possible to run multiple threads in the background executing different commands at the same time. | ||
* threads can be started from all input methods (TCP, CLI, named pipe). | ||
* added thread synchronization and termination commands. | ||
* new progress bar effect (progress command). | ||
* readpng, readjpg support for horizontal flip of odd rows. | ||
* no need to enter a value for optional commands, for example: progress 1,1,0,,,,,1 will use default values for arguments in ,,,,, | ||
* do ... loop supported from direct console input (CLI). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//generates random colors | ||
//random <channel>,<start>,<len>,<RGBWL> | ||
void add_random(thread_context * context, char * args){ | ||
char value[MAX_VAL_LEN]; | ||
int channel=0; | ||
unsigned int start=0, len=0; | ||
char component='L'; //L is brightness level | ||
int use_r=1, use_g=1, use_b=1, use_w=1, use_l=1; | ||
|
||
if (is_valid_channel_number(channel)){ | ||
len = ledstring.channel[channel].count;; | ||
} | ||
|
||
args = read_channel(args, & channel); | ||
if (is_valid_channel_number(channel)){ | ||
len = ledstring.channel[channel].count;; | ||
} | ||
args = read_int(args, & start); | ||
args = read_int(args, & len); | ||
if (args!=NULL && *args!=0){ | ||
args = read_val(args, value, MAX_VAL_LEN); | ||
use_r=0, use_g=0, use_b=0, use_w=0, use_l=0; | ||
unsigned char i; | ||
for (i=0;i<strlen(value);i++){ | ||
switch(toupper(value[i])){ | ||
case 'R': | ||
use_r=1; | ||
break; | ||
case 'G': | ||
use_g=1; | ||
break; | ||
case 'B': | ||
use_b=1; | ||
break; | ||
case 'W': | ||
use_w=1; | ||
break; | ||
case 'L': | ||
use_l=1; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (is_valid_channel_number(channel)){ | ||
|
||
if (start>=ledstring.channel[channel].count) start=0; | ||
if ((start+len)>ledstring.channel[channel].count) len=ledstring.channel[channel].count-start; | ||
|
||
if (debug) printf("random %d,%d,%d\n", channel, start, len); | ||
|
||
ws2811_led_t * leds = ledstring.channel[channel].leds; | ||
//unsigned int colors = ledstring[channel].color_size; | ||
unsigned char r=0,g=0,b=0,w=0,l=0; | ||
unsigned int i; | ||
for (i=0; i<len;i++){ | ||
if (use_r) r = rand() % 256; | ||
if (use_g) g = rand() % 256; | ||
if (use_b) b = rand() % 256; | ||
if (use_w) w = rand() % 256; | ||
if (use_l) l = rand() % 256; | ||
|
||
if (use_r || use_g || use_b || use_w) leds[start+i].color = color_rgbw(r,g,b,w); | ||
if (use_l) leds[start+i].brightness = l; | ||
} | ||
}else{ | ||
fprintf(stderr,ERROR_INVALID_CHANNEL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//makes some leds blink between 2 given colors for x times with a given delay | ||
//blink <channel>,<color1>,<color2>,<delay>,<blink_count>,<startled>,<len> | ||
void blink (thread_context * context, char * args){ | ||
int channel=0, color1=0, color2=0xFFFFFF,delay=1000, count=10; | ||
unsigned int start=0, len=0; | ||
|
||
if (is_valid_channel_number(channel)){ | ||
len = ledstring.channel[channel].count;; | ||
} | ||
|
||
args = read_channel(args, & channel); | ||
if (is_valid_channel_number(channel)){ | ||
len = ledstring.channel[channel].count;; | ||
} | ||
|
||
if (is_valid_channel_number(channel)) args = read_color_arg(args, & color1, ledstring.channel[channel].color_size); | ||
if (is_valid_channel_number(channel)) args = read_color_arg(args, & color2, ledstring.channel[channel].color_size); | ||
args = read_int(args, & delay); | ||
args = read_int(args, & count); | ||
args = read_int(args, & start); | ||
args = read_int(args, & len); | ||
|
||
|
||
if (is_valid_channel_number(channel)){ | ||
|
||
if (start>=ledstring.channel[channel].count) start=0; | ||
if ((start+len)>ledstring.channel[channel].count) len=ledstring.channel[channel].count-start; | ||
|
||
if (delay<=0) delay=100; | ||
|
||
if (debug) printf("blink %d, %d, %d, %d, %d, %d, %d\n", channel, color1, color2, delay, count, start, len); | ||
|
||
ws2811_led_t * leds = ledstring.channel[channel].leds; | ||
int i,blinks; | ||
for (blinks=0; blinks<count;blinks++){ | ||
for (i=start;i<start+len;i++){ | ||
if ((blinks%2)==0) { | ||
leds[i].color=color1; | ||
}else{ | ||
leds[i].color=color2; | ||
} | ||
} | ||
ws2811_render(&ledstring); | ||
usleep(delay * 1000); | ||
if (context->end_current_command) break; //signal to exit this command | ||
} | ||
}else{ | ||
fprintf(stderr,ERROR_INVALID_CHANNEL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//dims leds | ||
//brightness <channel>,<brightness>,<start>,<len> (brightness: 0-255) | ||
void brightness(thread_context * context, char * args){ | ||
int channel=0, brightness=255; | ||
unsigned int start=0, len=0; | ||
if (is_valid_channel_number(channel)){ | ||
len = ledstring.channel[channel].count;; | ||
} | ||
|
||
args = read_channel(args, & channel); | ||
if (is_valid_channel_number(channel)) len = ledstring.channel[channel].count;; | ||
args = read_int(args, & brightness); | ||
args = read_int(args, & start); | ||
args = read_int(args, & len); | ||
|
||
if (is_valid_channel_number(channel)){ | ||
if (brightness<0 || brightness>0xFF) brightness=255; | ||
|
||
if (start>=ledstring.channel[channel].count) start=0; | ||
if ((start+len)>ledstring.channel[channel].count) len=ledstring.channel[channel].count-start; | ||
|
||
if (debug) printf("Changing brightness %d, %d, %d, %d\n", channel, brightness, start, len); | ||
|
||
ws2811_led_t * leds = ledstring.channel[channel].leds; | ||
unsigned int i; | ||
for (i=start;i<start+len;i++){ | ||
leds[i].brightness=brightness; | ||
} | ||
}else{ | ||
fprintf(stderr,ERROR_INVALID_CHANNEL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//chaser makes leds run accross the led strip | ||
//chaser <channel>,<duration>,<color>,<count>,<direction>,<delay>,<start>,<len>,<brightness>,<loops> | ||
//channel = 1 | ||
//duration = time in seconds, or 0 4ever | ||
//color = color to use | ||
//count = number of leds | ||
//direction = scroll direction | ||
//delay = delay between moving the leds, speed | ||
//start = start index led (default 0) | ||
//len = length of the chaser (default enitre strip) | ||
//brightness = brightness of the chasing leds | ||
//loops = max number of chasing loops, 0 = 4ever, default = 0 | ||
void chaser(thread_context * context, char * args){ | ||
unsigned int channel=0, direction=1, duration=10, delay=10, color=255, brightness=255, loops=0; | ||
int i, n, index, len=0, count=1, start=0; | ||
|
||
args = read_channel(args, & channel); | ||
|
||
if (is_valid_channel_number(channel)){ | ||
len = ledstring.channel[channel].count; | ||
args = read_int(args, & duration); | ||
args = read_color_arg(args, & color, ledstring.channel[channel].color_size); | ||
args = read_int(args, & count); | ||
args = read_int(args, & direction); | ||
args = read_int(args, & delay); | ||
args = read_int(args, & start); | ||
args = read_int(args, & len); | ||
args = read_brightness(args, & brightness); | ||
args = read_int(args, & loops); | ||
} | ||
|
||
if (is_valid_channel_number(channel)){ | ||
if (start>=ledstring.channel[channel].count) start=0; | ||
if ((start+len)>ledstring.channel[channel].count) len=ledstring.channel[channel].count-start; | ||
if (len==0) len = 1; | ||
if (count>len) count = len; | ||
|
||
if (debug) printf("chaser %d %d %d %d %d %d %d %d %d %d\n", channel, duration, color, count, direction, delay, start, len, brightness, loops); | ||
|
||
ws2811_led_t * org_leds = malloc(len * sizeof(ws2811_led_t)); | ||
ws2811_led_t * leds = ledstring.channel[channel].leds; | ||
memcpy(org_leds, &leds[start], len * sizeof(ws2811_led_t)); //create a backup of original leds | ||
|
||
int loop_count=0; | ||
|
||
unsigned int start_time = time(0); | ||
while (((((time(0) - start_time) < duration) || duration==0) && (loops==0 || loops < loop_count)) && context->end_current_command==0){ | ||
ws2811_led_t tmp_led; | ||
|
||
for (n=0;n<count;n++){ | ||
index = direction==1 ? i - n: len - i + n; | ||
if (loop_count>0 || (index > 0 && index < len)){ | ||
index = (index + len) % len; | ||
leds[start + index].color = color; | ||
leds[start + index].brightness = brightness; | ||
} | ||
} | ||
|
||
ws2811_render(&ledstring); | ||
usleep(delay * 1000); | ||
|
||
for (n=0;n<count;n++){ | ||
index = direction==1 ? i - n : len - i + n; | ||
index = (index + len) % len; | ||
leds[start + index].color = org_leds[index].color; | ||
leds[start + index].brightness = org_leds[index].brightness; | ||
} | ||
|
||
i++; | ||
i = i % len; | ||
if (i==0){ | ||
loop_count++; | ||
} | ||
} | ||
|
||
memcpy(org_leds, & leds[start], len * sizeof(ws2811_led_t)); | ||
free(org_leds); | ||
}else{ | ||
fprintf(stderr, ERROR_INVALID_CHANNEL); | ||
} | ||
} |
Oops, something went wrong.