forked from Yona-Appletree/LEDscape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathledscape.h
90 lines (68 loc) · 1.5 KB
/
ledscape.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/** \file
* LEDscape for the BeagleBone Black.
*
* Drives up to 32 ws281x LED strips using the PRU to have no CPU overhead.
* Allows easy double buffering of frames.
*/
#ifndef _ledscape_h_
#define _ledscape_h_
#include <stdint.h>
/** The number of strips supported.
*
* Changing this also requires changes in ws281x.p to stride the
* correct number of bytes per row..
*/
#define LEDSCAPE_NUM_STRIPS 48
/** LEDscape pixel format is BRGA.
*
* data is laid out with BRGA format, since that is how it will
* be translated during the clock out from the PRU.
*/
typedef struct {
uint8_t b;
uint8_t r;
uint8_t g;
uint8_t a;
} __attribute__((__packed__)) ledscape_pixel_t;
/** LEDscape frame buffer is "strip-major".
*
* All 32 strips worth of data for each pixel are stored adjacent.
* This makes it easier to clock out while reading from the DDR
* in a burst mode.
*/
typedef struct {
ledscape_pixel_t strip[LEDSCAPE_NUM_STRIPS];
} __attribute__((__packed__)) ledscape_frame_t;
typedef struct ledscape ledscape_t;
extern ledscape_t *
ledscape_init(
unsigned num_pixels
);
extern ledscape_frame_t *
ledscape_frame(
ledscape_t * const leds,
unsigned frame
);
extern void
ledscape_draw(
ledscape_t * const leds,
unsigned frame
);
extern void
ledscape_set_color(
ledscape_frame_t * const frame,
uint32_t strip,
uint32_t pixel,
uint8_t r,
uint8_t g,
uint8_t b
);
extern uint32_t
ledscape_wait(
ledscape_t * const leds
);
extern void
ledscape_close(
ledscape_t * const leds
);
#endif