File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ platforms = [
4848 ],
4949 'LINKFLAGS' : [
5050 "-lrt" ,
51+ "-lm" ,
5152 ],
5253 },
5354 ],
Original file line number Diff line number Diff line change 4141#include <linux/types.h>
4242#include <linux/spi/spidev.h>
4343#include <time.h>
44-
44+ #include <math.h>
4545#include "mailbox.h"
4646#include "clk.h"
4747#include "gpio.h"
@@ -1282,3 +1282,23 @@ const char * ws2811_get_return_t_str(const ws2811_return_t state)
12821282
12831283 return "" ;
12841284}
1285+
1286+
1287+ void setCustomGammaFactor (ws2811_t * ws2811 , double gammaFactor )
1288+ {
1289+ for (int chan = 0 ; chan < RPI_PWM_CHANNELS ; chan ++ )
1290+ {
1291+ ws2811_channel_t * channel = & ws2811 -> channel [chan ];
1292+
1293+ if (channel -> gamma )
1294+ {
1295+ for (int counter = 0 ; counter < 256 ; counter ++ )
1296+ {
1297+
1298+ channel -> gamma [counter ] = (gammaFactor > 0 )? (int )(pow ((float )counter / (float )255.00 , gammaFactor ) * 255.00 + 0.5 ) : counter ;
1299+
1300+ }
1301+ }
1302+
1303+ }
1304+ }
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ void ws2811_fini(ws2811_t *ws2811); //< Tear
122122ws2811_return_t ws2811_render (ws2811_t * ws2811 ); //< Send LEDs off to hardware
123123ws2811_return_t ws2811_wait (ws2811_t * ws2811 ); //< Wait for DMA completion
124124const char * ws2811_get_return_t_str (const ws2811_return_t state ); //< Get string representation of the given return state
125+ void setCustomGammaFactor (ws2811_t * ws2811 , double gammaFactor ); //Set a custom Gamma correction array based on a gamma correction factor
125126
126127#ifdef __cplusplus
127128}
You can’t perform that action at this time.
0 commit comments