Permalink
Browse files

Allow us to specify a number of iterations.

  • Loading branch information...
1 parent c468a38 commit 3fbbac7f69ceed8a6c23d1ad46910ac1ca288964 @jwhite66 committed Aug 7, 2012
Showing with 19 additions and 8 deletions.
  1. +19 −8 testlib.c
View
@@ -1,27 +1,38 @@
#include <unistd.h>
#include <stdio.h>
+#include <stdlib.h>
#include "led.h"
int main(int argc, char *argv[])
{
LED_HANDLE_T h;
int x, y, i, j;
+ long count = 0;
+
+ if (argc <= 1)
+ {
+ fprintf(stderr, "Specify number of bulbs to set\n");
+ return 1;
+ }
h = led_init();
if (h)
{
led_get_size(h, &x, &y);
printf("Size is %d x %d\n", x, y);
- for (i = 0; i < x; i++)
- for (j = 0; j < y; j++)
- {
- printf("%d, %d\n", i, j);
- led_set_pixel(h, i, j, MAX_BRIGHT, 0xf, 0, 0);
- usleep(1000000);
- led_set_pixel(h, i, j, 0, 0, 0, 0);
- }
+ do
+ {
+ for (i = 0; i < x; i++)
+ for (j = 0; j < y; j++)
+ {
+ led_set_pixel(h, i, j, MAX_BRIGHT, 0xf, 0, 0);
+ led_set_pixel(h, i, j, 0, 0, 0, 0);
+ count += 2;
+ }
+ }
+ while (count < atol(argv[1]));
led_term(h);
}

0 comments on commit 3fbbac7

Please sign in to comment.