Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2093 - 1
///////////////////////////////////////////////////////////////////////////////
2
 
3
#define RIGGER_CNT 4 // up to 8
4
#define LED_CNT 10
5
#define LED_BIT_CNT 3 * LED_CNT * 8 // RGB * LED_CNT * Bits_per_led
6
#define LED_BIT_INDEX(led, color, bit) (led * 24 + color * 8 + 7 - bit)
7
 
8
///////////////////////////////////////////////////////////////////////////////
9
//
10
// One bit per channel, 8 bytes per color, 3 colors per pixel
11
//                                 
12
//                                 Pixel_1
13
//                Green               Red                Blue
14
//           0 1 2 3 4 5 6 7    0 1 2 3 4 5 6 7    0 1 2 3 4 5 6 7
15
// Channel_0 
16
// Channel_1 
17
// Channel_2 
18
// Channel_3 
19
// Channel_4 
20
// Channel_5 
21
// Channel_6 
22
// Channel_7 
23
//
24
///////////////////////////////////////////////////////////////////////////////
25
 
26
typedef unsigned char Data[LED_BIT_CNT];
27
 
28
///////////////////////////////////////////////////////////////////////////////
29
 
30
#include <util/delay.h>
31
#include "ws2812b.h"
32
 
33
///////////////////////////////////////////////////////////////////////////////
34
//
35
// One Channel per Port bit, up to eight channels
36
//
37
///////////////////////////////////////////////////////////////////////////////
38
 
39
void sample(double delay)
40
{
41
  Data data;
42
  unsigned char   l;
43
 
44
  for(l=0;l<2;l++)
45
  {
46
    unsigned char  k=l;
47
    unsigned short i=0;
48
 
49
    while(i<sizeof(data))
50
    {
51
      unsigned char b;
52
      unsigned char d;
53
 
54
      d = (k & 1)?0x05:0x04;
55
      for(b=0;b<8;b++)data[i++] = d; // Green
56
      d = (k & 1)?0x09:0x08;
57
      for(b=0;b<8;b++)data[i++] = d; // Red
58
      d = (k & 1)?0x03:0x02;
59
      for(b=0;b<8;b++)data[i++] = d; // Blue
60
      k++;
61
    }
62
    ws2812b_send(data, sizeof(data));
63
    _delay_ms(delay);
64
  }
65
}
66
 
67
///////////////////////////////////////////////////////////////////////////////