forked from onlaj/Piano-LED-Visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpi_ws281x.i
48 lines (38 loc) · 1.18 KB
/
rpi_ws281x.i
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
// SWIG interface file to define rpi_ws281x library python wrapper.
// Author: Tony DiCola ([email protected]), Jeremy Garff ([email protected])
// Define module name rpi_ws281x. This will actually be imported under
// the name _rpi_ws281x following the SWIG & Python conventions.
%module rpi_ws281x
// Include standard SWIG types & array support for support of uint32_t
// parameters and arrays.
%include "stdint.i"
%include "carrays.i"
// Declare functions which will be exported as anything in the ws2811.h header.
%{
#include "../ws2811.h"
%}
// Process ws2811.h header and export all included functions.
%include "../ws2811.h"
%inline %{
uint32_t ws2811_led_get(ws2811_channel_t *channel, int lednum)
{
if (lednum >= channel->count)
{
return -1;
}
return channel->leds[lednum];
}
int ws2811_led_set(ws2811_channel_t *channel, int lednum, uint32_t color)
{
if (lednum >= channel->count)
{
return -1;
}
channel->leds[lednum] = color;
return 0;
}
ws2811_channel_t *ws2811_channel_get(ws2811_t *ws, int channelnum)
{
return &ws->channel[channelnum];
}
%}