This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
ws2812-rpi-python.cpp
72 lines (66 loc) · 3.53 KB
/
ws2812-rpi-python.cpp
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
/*
###############################################################################
# #
# WS2812-RPi #
# ========== #
# A C++ library for driving WS2812 RGB LED's (known as 'NeoPixels' by #
# Adafruit) directly from a Raspberry Pi with accompanying Python wrapper #
# Copyright (C) 2014 Rob Kent #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
*/
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
using namespace boost::python;
#include "ws2812-rpi.h"
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
setPixelColor1, NeoPixel::setPixelColor, 4, 4
)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
setPixelColor2, NeoPixel::setPixelColor, 2, 2
)
BOOST_PYTHON_MODULE(NeoPixel){
class_<Color_t>("Color")
.def_readwrite("r", &Color_t::r)
.def_readwrite("g", &Color_t::g)
.def_readwrite("b", &Color_t::b);
class_<std::vector<Color_t> >("Color_t_vector")
.def(vector_indexing_suite<std::vector<Color_t> >());
class_<NeoPixel>("NeoPixel", init<unsigned int>())
.def("begin", &NeoPixel::begin)
.def("show", &NeoPixel::show)
.def("setPixelColor",
static_cast<unsigned char(NeoPixel::*)(unsigned int, unsigned char, unsigned char, unsigned char)>(&NeoPixel::setPixelColor),
setPixelColor1())
.def("setPixelColor",
static_cast<unsigned char(NeoPixel::*)(unsigned int, Color_t)>(&NeoPixel::setPixelColor),
setPixelColor2())
.def("setBrightness", &NeoPixel::setBrightness)
.def("getPixels", &NeoPixel::getPixels)
.def("getBrightness", &NeoPixel::getBrightness)
.def("getPixelColor", &NeoPixel::getPixelColor)
.def("numPixels", &NeoPixel::numPixels)
.def("clear", &NeoPixel::clear)
.def("colorWipe", &NeoPixel::colorWipe)
.def("rainbow", &NeoPixel::rainbow)
.def("rainbowCycle", &NeoPixel::rainbowCycle)
.def("theaterChase", &NeoPixel::theaterChase)
.def("theaterChaseRainbow", &NeoPixel::theaterChaseRainbow)
.def("gradient", &NeoPixel::gradient)
.def("bars", &NeoPixel::bars)
.def("effectsDemo", &NeoPixel::effectsDemo)
;
}