38 #include <sys/types.h> 56 #define ARRAY_SIZE(stuff) (sizeof(stuff) / sizeof(stuff[0])) 59 #define TARGET_FREQ WS2811_TARGET_FREQ 63 #define STRIP_TYPE WS2811_STRIP_GBR // WS2812/SK6812RGB integrated chip+leds 68 #define LED_COUNT (WIDTH * HEIGHT) 108 for (x = 0; x <
width; x++)
110 for (y = 0; y <
height; y++)
121 for (y = 0; y < (
height - 1); y++)
123 for (x = 0; x <
width; x++)
127 matrix[y * width + x] =
matrix[(y + 1)*width + width - x - 1];
136 for (y = 0; y < (
height ); y++)
138 for (x = 0; x <
width; x++)
140 matrix[y * width + x] = 0;
199 struct sigaction sa =
204 sigaction(SIGINT, &sa, NULL);
205 sigaction(SIGTERM, &sa, NULL);
214 static struct option longopts[] =
216 {
"help", no_argument, 0,
'h'},
217 {
"dma", required_argument, 0,
'd'},
218 {
"gpio", required_argument, 0,
'g'},
219 {
"invert", no_argument, 0,
'i'},
220 {
"clear", no_argument, 0,
'c'},
221 {
"strip", required_argument, 0,
's'},
222 {
"height", required_argument, 0,
'y'},
223 {
"width", required_argument, 0,
'x'},
224 {
"version", no_argument, 0,
'v'},
232 c = getopt_long(argc, argv,
"cd:g:his:vx:y:", longopts, &index);
244 fprintf(stderr,
"%s version %s\n", argv[0],
VERSION);
245 fprintf(stderr,
"Usage: %s \n" 246 "-h (--help) - this information\n" 247 "-s (--strip) - strip type - rgb, grb, gbr, rgbw\n" 248 "-x (--width) - matrix width (default 8)\n" 249 "-y (--height) - matrix height (default 8)\n" 250 "-d (--dma) - dma channel to use (default 10)\n" 251 "-g (--gpio) - GPIO to use\n" 252 " If omitted, default is 18 (PWM0)\n" 253 "-i (--invert) - invert pin output (pulse LOW)\n" 254 "-c (--clear) - clear matrix on exit.\n" 255 "-v (--version) - version information\n" 264 int gpio = atoi(optarg);
293 int dma = atoi(optarg);
297 printf (
"invalid dma %d\n", dma);
309 printf (
"invalid height %d\n",
height);
317 width = atoi(optarg);
321 printf (
"invalid width %d\n",
width);
329 if (!strncasecmp(
"rgb", optarg, 4)) {
332 else if (!strncasecmp(
"rbg", optarg, 4)) {
335 else if (!strncasecmp(
"grb", optarg, 4)) {
338 else if (!strncasecmp(
"gbr", optarg, 4)) {
341 else if (!strncasecmp(
"brg", optarg, 4)) {
344 else if (!strncasecmp(
"bgr", optarg, 4)) {
347 else if (!strncasecmp(
"rgbw", optarg, 4)) {
350 else if (!strncasecmp(
"grbw", optarg, 4)) {
354 printf (
"invalid strip %s\n", optarg);
361 fprintf(stderr,
"%s version %s\n", argv[0],
VERSION);
375 int main(
int argc,
char *argv[])
379 sprintf(
VERSION,
"%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO);
387 if ((ret =
ws2811_init(&ledstring)) != WS2811_SUCCESS)
406 usleep(1000000 / 15);
int main(int argc, char *argv[])
ws2811_channel_t channel[RPI_PWM_CHANNELS]
#define ARRAY_SIZE(stuff)
void parseargs(int argc, char **argv, ws2811_t *ws2811)
ws2811_led_t dotcolors_rgbw[]
#define SK6812_STRIP_GRBW
static void setup_handlers(void)
ws2811_return_t ws2811_init(ws2811_t *ws2811)
ws2811_return_t ws2811_render(ws2811_t *ws2811)
const char * ws2811_get_return_t_str(const ws2811_return_t state)
void ws2811_fini(ws2811_t *ws2811)
#define SK6812_STRIP_RGBW
static void ctrl_c_handler(int signum)