-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrpi_pcm_ws281x.i
43 lines (34 loc) · 1.08 KB
/
rpi_pcm_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
// SWIG interface file to define rpi_pcm_ws281x library python wrapper.
// Author: Tony DiCola (tony@tonydicola.com), Jeremy Garff (jer@jers.net)
// Define module name rpi_pcm_ws281x. This will actually be imported under
// the name _rpi_pcm_ws281x following the SWIG & Python conventions.
%module rpi_pcm_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 "lib/ws2811-pcm.h"
%}
// Process ws2811.h header and export all included functions.
%include "lib/ws2811-pcm.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;
}
%}