forked from tom-2015/rpi-ws2812-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodifications.txt
67 lines (55 loc) · 2.24 KB
/
modifications.txt
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
If you want to update the jgarff rpi_ws281x code you need to make some changes:
https://github.com/jgarff/rpi_ws281x
//First add in ws2811.h:
int color_size; //3 = RGB, 4 = RGBW
//to ws2811_channel_t;
//change type of ws2811_led_t;
typedef struct
{
uint32_t color;
uint32_t brightness;
}ws2811_led_t;
//change in the reder function of ws2811.c the for loop:
for (i = 0; i < channel->count; i++) // Led
{
const int brightness = scale * (channel->leds[i].brightness & 0xff) + 1;
uint8_t color[] =
{
channel->gamma[(((channel->leds[i].color >> channel->rshift) & 0xff) * brightness) >> 16], // red
channel->gamma[(((channel->leds[i].color >> channel->gshift) & 0xff) * brightness) >> 16], // green
channel->gamma[(((channel->leds[i].color >> channel->bshift) & 0xff) * brightness) >> 16], // blue
channel->gamma[(((channel->leds[i].color >> channel->wshift) & 0xff) * brightness) >> 16], // white
};
uint8_t array_size = 3; // Assume 3 color LEDs, RGB
// If our shift mask includes the highest nibble, then we have 4
// LEDs, RBGW.
if (channel->strip_type & SK6812_SHIFT_WMASK)
{
array_size = 4;
}
//add initialization of the led brightness table in the ws2811_return_t ws2811_init(ws2811_t *ws2811) function:
//add:
for (i=0;i<channel->count;i++) channel->leds[i].brightness=255;
//before:
// Set default uncorrected gamma table
if (!channel->gamma)
{
//add extra paramter to the ws2811_render function: int32_t channel_number
//add check for channel number in the for loop of ws2811_render() function:
for (chan = 0; chan < RPI_PWM_CHANNELS; chan++) // Channel
{
if (channel_number == chan || channel_number == -1) {
//.... original for loop code here
}
}
//move the code to wait for ws2811 dma to complete (inside ws2811_render function) BEFORE the for loop that changes the raw pixel data:
// Wait for any previous DMA operation to complete.
if ((ret = ws2811_wait(ws2811)) != WS2811_SUCCESS)
{
return ret;
}
//before:
for (chan = 0; chan < RPI_PWM_CHANNELS; chan++) // Channel
in readpng.c:readpng_get_image comment:
//if (png_get_gAMA(png_ptr, info_ptr, &gamma))
// png_set_gamma(png_ptr, display_exponent, gamma);