ws2812 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +19 -3
- data/Rakefile +0 -7
- data/examples/gamma-vs-direct.rb +3 -3
- data/ext/ws2812/clk.h +1 -1
- data/ext/ws2812/dma.h +2 -2
- data/ext/ws2812/gpio.h +1 -1
- data/ext/ws2812/lowlevel_wrap.c +102 -142
- data/ext/ws2812/mailbox.c +19 -29
- data/ext/ws2812/mailbox.h +0 -7
- data/ext/ws2812/pwm.h +1 -1
- data/ext/ws2812/ws2811.c +14 -16
- data/ext/ws2812/ws2811.h +1 -2
- data/lib/ws2812.rb +1 -1
- metadata +11 -17
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: e39a82b0bca3478139d613c71a9391f6897fe818
|
|
4
|
+
data.tar.gz: 93b56a48d2f0a479fb40bf899d4a6e6e10582238
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a53401e7e986463d426fcbbf403cb16bda51deaa8edb2a6d0c28f5f8f95d58166bb78fd427ea65992b6b768a1ada8c78b2523bb98964fb941b25d9b42eca33f1
|
|
7
|
+
data.tar.gz: e0e1198ed35a8b8a5944cff9cab294a18de8452e7022a05b3144a38c43f1b73e40046ab00f95b8107f82e6765946cd9146c270c301c501b0ffd189fa22d3f186
|
data/README.md
CHANGED
|
@@ -9,10 +9,25 @@ These WS281x LEDs are sometimes also known as NeoPixels.
|
|
|
9
9
|
|
|
10
10
|
# Installation
|
|
11
11
|
As this is a published Ruby gem,
|
|
12
|
-
```
|
|
12
|
+
```bash
|
|
13
13
|
gem install ws2812
|
|
14
14
|
```
|
|
15
|
-
should be enough.
|
|
15
|
+
should be enough. But the examples will be hidden in 'gems' dir.
|
|
16
|
+
|
|
17
|
+
If you want to avoid the gem route, the following works just as well:
|
|
18
|
+
```bash
|
|
19
|
+
git clone https://github.com/wejn/ws2812
|
|
20
|
+
cd ws2812
|
|
21
|
+
# Assuming raspbian here; otherwise make sure you have 'mkmf'
|
|
22
|
+
# and can compile exts (failing that "rake compile" will bomb on you)
|
|
23
|
+
sudo apt-get update
|
|
24
|
+
sudo apt-get install -y ruby-full
|
|
25
|
+
# .
|
|
26
|
+
sudo gem install rake rake-compiler
|
|
27
|
+
rake compile
|
|
28
|
+
# and then, to demo it:
|
|
29
|
+
sudo ruby examples/digiclock.rb
|
|
30
|
+
```
|
|
16
31
|
|
|
17
32
|
# Examples
|
|
18
33
|
See the [examples](https://github.com/wejn/ws2812/tree/master/examples)
|
|
@@ -23,7 +38,8 @@ GNU General Public License v. 2, see [LICENSE.txt](LICENSE.txt).
|
|
|
23
38
|
|
|
24
39
|
# Authors
|
|
25
40
|
This gem (all of the ruby code and some tweaks to the C extension) was
|
|
26
|
-
created by Michal Jirků <box@wejn.org
|
|
41
|
+
originally created by Michal Jirků <box@wejn.org>, later extended by
|
|
42
|
+
Philip Howard <phil@gadgetoid.com> to support newer Pi-s.
|
|
27
43
|
|
|
28
44
|
And it wouldn't be possible without the original UnicornHAT repo.
|
|
29
45
|
|
data/Rakefile
CHANGED
data/examples/gamma-vs-direct.rb
CHANGED
|
@@ -6,7 +6,7 @@ require 'ws2812'
|
|
|
6
6
|
n = 64 # num leds
|
|
7
7
|
ws = Ws2812::Basic.new(n, 18) # +n+ leds at pin 18, using defaults
|
|
8
8
|
ws.open
|
|
9
|
-
ws.brightness =
|
|
9
|
+
ws.brightness = 128
|
|
10
10
|
if ARGV.first
|
|
11
11
|
puts 'Using direct mode.'
|
|
12
12
|
puts 'Remove all positional parameters to switch to gamma-corrected mode.'
|
|
@@ -17,14 +17,14 @@ else
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# up...
|
|
20
|
-
0.upto(
|
|
20
|
+
0.upto(128) do |i|
|
|
21
21
|
ws[0..63] = Ws2812::Color.new(i, i, i)
|
|
22
22
|
ws.show
|
|
23
23
|
sleep 0.01
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# and down...
|
|
27
|
-
|
|
27
|
+
128.downto(0) do |i|
|
|
28
28
|
ws[0..63] = Ws2812::Color.new(i, i, i)
|
|
29
29
|
ws.show
|
|
30
30
|
sleep 0.01
|
data/ext/ws2812/clk.h
CHANGED
|
@@ -51,7 +51,7 @@ typedef struct {
|
|
|
51
51
|
#define CM_PWM_DIV_PASSWD (0x5a << 24)
|
|
52
52
|
#define CM_PWM_DIV_DIVI(val) ((val & 0xfff) << 12)
|
|
53
53
|
#define CM_PWM_DIV_DIVF(val) ((val & 0xfff) << 0)
|
|
54
|
-
}
|
|
54
|
+
} cm_pwm_t;
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
#define CM_PWM_OFFSET (0x001010a0)
|
data/ext/ws2812/dma.h
CHANGED
|
@@ -46,7 +46,7 @@ typedef struct
|
|
|
46
46
|
uint32_t stride;
|
|
47
47
|
uint32_t nextconbk;
|
|
48
48
|
uint32_t resvd_0x18[2];
|
|
49
|
-
}
|
|
49
|
+
} dma_cb_t;
|
|
50
50
|
|
|
51
51
|
/*
|
|
52
52
|
* DMA register set
|
|
@@ -95,7 +95,7 @@ typedef struct
|
|
|
95
95
|
#define RPI_DMA_STRIDE_S_STRIDE(val) ((val & 0xffff) << 0)
|
|
96
96
|
uint32_t nextconbk;
|
|
97
97
|
uint32_t debug;
|
|
98
|
-
}
|
|
98
|
+
} dma_t;
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
#define DMA0_OFFSET (0x00007000)
|
data/ext/ws2812/gpio.h
CHANGED
data/ext/ws2812/lowlevel_wrap.c
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* ----------------------------------------------------------------------------
|
|
2
2
|
* This file was automatically generated by SWIG (http://www.swig.org).
|
|
3
|
-
* Version 2.0.
|
|
4
|
-
*
|
|
5
|
-
* This file is not intended to be easily readable and contains a number of
|
|
3
|
+
* Version 2.0.12
|
|
4
|
+
*
|
|
5
|
+
* This file is not intended to be easily readable and contains a number of
|
|
6
6
|
* coding conventions designed to improve portability and efficiency. Do not make
|
|
7
|
-
* changes to this file unless you know what you are doing--modify the SWIG
|
|
8
|
-
* interface file instead.
|
|
7
|
+
* changes to this file unless you know what you are doing--modify the SWIG
|
|
8
|
+
* interface file instead.
|
|
9
9
|
* ----------------------------------------------------------------------------- */
|
|
10
10
|
|
|
11
11
|
#define SWIGRUBY
|
|
@@ -41,28 +41,28 @@
|
|
|
41
41
|
#ifndef SWIGUNUSED
|
|
42
42
|
# if defined(__GNUC__)
|
|
43
43
|
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
|
44
|
-
# define SWIGUNUSED __attribute__ ((__unused__))
|
|
44
|
+
# define SWIGUNUSED __attribute__ ((__unused__))
|
|
45
45
|
# else
|
|
46
46
|
# define SWIGUNUSED
|
|
47
47
|
# endif
|
|
48
48
|
# elif defined(__ICC)
|
|
49
|
-
# define SWIGUNUSED __attribute__ ((__unused__))
|
|
49
|
+
# define SWIGUNUSED __attribute__ ((__unused__))
|
|
50
50
|
# else
|
|
51
|
-
# define SWIGUNUSED
|
|
51
|
+
# define SWIGUNUSED
|
|
52
52
|
# endif
|
|
53
53
|
#endif
|
|
54
54
|
|
|
55
55
|
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
|
56
56
|
# if defined(_MSC_VER)
|
|
57
57
|
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
|
58
|
-
# endif
|
|
58
|
+
# endif
|
|
59
59
|
#endif
|
|
60
60
|
|
|
61
61
|
#ifndef SWIGUNUSEDPARM
|
|
62
62
|
# ifdef __cplusplus
|
|
63
63
|
# define SWIGUNUSEDPARM(p)
|
|
64
64
|
# else
|
|
65
|
-
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
|
65
|
+
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
|
66
66
|
# endif
|
|
67
67
|
#endif
|
|
68
68
|
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
# define SWIGSTDCALL __stdcall
|
|
106
106
|
# else
|
|
107
107
|
# define SWIGSTDCALL
|
|
108
|
-
# endif
|
|
108
|
+
# endif
|
|
109
109
|
#endif
|
|
110
110
|
|
|
111
111
|
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
|
@@ -150,28 +150,28 @@
|
|
|
150
150
|
#ifndef SWIGUNUSED
|
|
151
151
|
# if defined(__GNUC__)
|
|
152
152
|
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
|
153
|
-
# define SWIGUNUSED __attribute__ ((__unused__))
|
|
153
|
+
# define SWIGUNUSED __attribute__ ((__unused__))
|
|
154
154
|
# else
|
|
155
155
|
# define SWIGUNUSED
|
|
156
156
|
# endif
|
|
157
157
|
# elif defined(__ICC)
|
|
158
|
-
# define SWIGUNUSED __attribute__ ((__unused__))
|
|
158
|
+
# define SWIGUNUSED __attribute__ ((__unused__))
|
|
159
159
|
# else
|
|
160
|
-
# define SWIGUNUSED
|
|
160
|
+
# define SWIGUNUSED
|
|
161
161
|
# endif
|
|
162
162
|
#endif
|
|
163
163
|
|
|
164
164
|
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
|
165
165
|
# if defined(_MSC_VER)
|
|
166
166
|
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
|
167
|
-
# endif
|
|
167
|
+
# endif
|
|
168
168
|
#endif
|
|
169
169
|
|
|
170
170
|
#ifndef SWIGUNUSEDPARM
|
|
171
171
|
# ifdef __cplusplus
|
|
172
172
|
# define SWIGUNUSEDPARM(p)
|
|
173
173
|
# else
|
|
174
|
-
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
|
174
|
+
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
|
175
175
|
# endif
|
|
176
176
|
#endif
|
|
177
177
|
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
# define SWIGSTDCALL __stdcall
|
|
215
215
|
# else
|
|
216
216
|
# define SWIGSTDCALL
|
|
217
|
-
# endif
|
|
217
|
+
# endif
|
|
218
218
|
#endif
|
|
219
219
|
|
|
220
220
|
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
|
@@ -252,7 +252,7 @@
|
|
|
252
252
|
You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
|
|
253
253
|
creating a static or dynamic library from the SWIG runtime code.
|
|
254
254
|
In 99.9% of the cases, SWIG just needs to declare them as 'static'.
|
|
255
|
-
|
|
255
|
+
|
|
256
256
|
But only do this if strictly necessary, ie, if you have problems
|
|
257
257
|
with your compiler or suchlike.
|
|
258
258
|
*/
|
|
@@ -278,16 +278,16 @@
|
|
|
278
278
|
#define SWIG_POINTER_OWN 0x1
|
|
279
279
|
|
|
280
280
|
|
|
281
|
-
/*
|
|
281
|
+
/*
|
|
282
282
|
Flags/methods for returning states.
|
|
283
|
-
|
|
284
|
-
The SWIG conversion methods, as ConvertPtr, return an integer
|
|
283
|
+
|
|
284
|
+
The SWIG conversion methods, as ConvertPtr, return an integer
|
|
285
285
|
that tells if the conversion was successful or not. And if not,
|
|
286
286
|
an error code can be returned (see swigerrors.swg for the codes).
|
|
287
|
-
|
|
287
|
+
|
|
288
288
|
Use the following macros/flags to set or process the returning
|
|
289
289
|
states.
|
|
290
|
-
|
|
290
|
+
|
|
291
291
|
In old versions of SWIG, code such as the following was usually written:
|
|
292
292
|
|
|
293
293
|
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
|
|
@@ -320,23 +320,23 @@
|
|
|
320
320
|
} else {
|
|
321
321
|
// fail code
|
|
322
322
|
}
|
|
323
|
-
|
|
323
|
+
|
|
324
324
|
I.e., now SWIG_ConvertPtr can return new objects and you can
|
|
325
325
|
identify the case and take care of the deallocation. Of course that
|
|
326
326
|
also requires SWIG_ConvertPtr to return new result values, such as
|
|
327
327
|
|
|
328
|
-
int SWIG_ConvertPtr(obj, ptr,...) {
|
|
329
|
-
if (<obj is ok>) {
|
|
330
|
-
if (<need new object>) {
|
|
331
|
-
*ptr = <ptr to new allocated object>;
|
|
332
|
-
return SWIG_NEWOBJ;
|
|
333
|
-
} else {
|
|
334
|
-
*ptr = <ptr to old object>;
|
|
335
|
-
return SWIG_OLDOBJ;
|
|
336
|
-
}
|
|
337
|
-
} else {
|
|
338
|
-
return SWIG_BADOBJ;
|
|
339
|
-
}
|
|
328
|
+
int SWIG_ConvertPtr(obj, ptr,...) {
|
|
329
|
+
if (<obj is ok>) {
|
|
330
|
+
if (<need new object>) {
|
|
331
|
+
*ptr = <ptr to new allocated object>;
|
|
332
|
+
return SWIG_NEWOBJ;
|
|
333
|
+
} else {
|
|
334
|
+
*ptr = <ptr to old object>;
|
|
335
|
+
return SWIG_OLDOBJ;
|
|
336
|
+
}
|
|
337
|
+
} else {
|
|
338
|
+
return SWIG_BADOBJ;
|
|
339
|
+
}
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
|
|
@@ -350,17 +350,17 @@
|
|
|
350
350
|
int fooi(int);
|
|
351
351
|
|
|
352
352
|
and you call
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
food(1) // cast rank '1' (1 -> 1.0)
|
|
355
355
|
fooi(1) // cast rank '0'
|
|
356
356
|
|
|
357
357
|
just use the SWIG_AddCast()/SWIG_CheckState()
|
|
358
358
|
*/
|
|
359
359
|
|
|
360
|
-
#define SWIG_OK (0)
|
|
360
|
+
#define SWIG_OK (0)
|
|
361
361
|
#define SWIG_ERROR (-1)
|
|
362
362
|
#define SWIG_IsOK(r) (r >= 0)
|
|
363
|
-
#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
|
|
363
|
+
#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
|
|
364
364
|
|
|
365
365
|
/* The CastRankLimit says how many bits are used for the cast rank */
|
|
366
366
|
#define SWIG_CASTRANKLIMIT (1 << 8)
|
|
@@ -391,14 +391,14 @@
|
|
|
391
391
|
# endif
|
|
392
392
|
# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
|
|
393
393
|
# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
|
|
394
|
-
SWIGINTERNINLINE int SWIG_AddCast(int r) {
|
|
394
|
+
SWIGINTERNINLINE int SWIG_AddCast(int r) {
|
|
395
395
|
return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
|
|
396
396
|
}
|
|
397
|
-
SWIGINTERNINLINE int SWIG_CheckState(int r) {
|
|
398
|
-
return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
|
|
397
|
+
SWIGINTERNINLINE int SWIG_CheckState(int r) {
|
|
398
|
+
return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
|
|
399
399
|
}
|
|
400
400
|
#else /* no cast-rank mode */
|
|
401
|
-
# define SWIG_AddCast
|
|
401
|
+
# define SWIG_AddCast(r) (r)
|
|
402
402
|
# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
|
|
403
403
|
#endif
|
|
404
404
|
|
|
@@ -442,7 +442,7 @@ typedef struct swig_module_info {
|
|
|
442
442
|
void *clientdata; /* Language specific module data */
|
|
443
443
|
} swig_module_info;
|
|
444
444
|
|
|
445
|
-
/*
|
|
445
|
+
/*
|
|
446
446
|
Compare two type names skipping the space characters, therefore
|
|
447
447
|
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
|
|
448
448
|
|
|
@@ -462,18 +462,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1,
|
|
|
462
462
|
|
|
463
463
|
/*
|
|
464
464
|
Check type equivalence in a name list like <name1>|<name2>|...
|
|
465
|
-
Return 0 if
|
|
465
|
+
Return 0 if equal, -1 if nb < tb, 1 if nb > tb
|
|
466
466
|
*/
|
|
467
467
|
SWIGRUNTIME int
|
|
468
|
-
|
|
469
|
-
int equiv =
|
|
468
|
+
SWIG_TypeCmp(const char *nb, const char *tb) {
|
|
469
|
+
int equiv = 1;
|
|
470
470
|
const char* te = tb + strlen(tb);
|
|
471
471
|
const char* ne = nb;
|
|
472
|
-
while (
|
|
472
|
+
while (equiv != 0 && *ne) {
|
|
473
473
|
for (nb = ne; *ne; ++ne) {
|
|
474
474
|
if (*ne == '|') break;
|
|
475
475
|
}
|
|
476
|
-
equiv =
|
|
476
|
+
equiv = SWIG_TypeNameComp(nb, ne, tb, te);
|
|
477
477
|
if (*ne) ++ne;
|
|
478
478
|
}
|
|
479
479
|
return equiv;
|
|
@@ -481,24 +481,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) {
|
|
|
481
481
|
|
|
482
482
|
/*
|
|
483
483
|
Check type equivalence in a name list like <name1>|<name2>|...
|
|
484
|
-
Return 0 if equal,
|
|
484
|
+
Return 0 if not equal, 1 if equal
|
|
485
485
|
*/
|
|
486
486
|
SWIGRUNTIME int
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
const char* te = tb + strlen(tb);
|
|
490
|
-
const char* ne = nb;
|
|
491
|
-
while (!equiv && *ne) {
|
|
492
|
-
for (nb = ne; *ne; ++ne) {
|
|
493
|
-
if (*ne == '|') break;
|
|
494
|
-
}
|
|
495
|
-
equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
|
|
496
|
-
if (*ne) ++ne;
|
|
497
|
-
}
|
|
498
|
-
return equiv;
|
|
487
|
+
SWIG_TypeEquiv(const char *nb, const char *tb) {
|
|
488
|
+
return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
|
|
499
489
|
}
|
|
500
490
|
|
|
501
|
-
|
|
502
491
|
/*
|
|
503
492
|
Check the typename
|
|
504
493
|
*/
|
|
@@ -526,7 +515,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) {
|
|
|
526
515
|
return 0;
|
|
527
516
|
}
|
|
528
517
|
|
|
529
|
-
/*
|
|
518
|
+
/*
|
|
530
519
|
Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
|
|
531
520
|
*/
|
|
532
521
|
SWIGRUNTIME swig_cast_info *
|
|
@@ -561,7 +550,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
|
|
|
561
550
|
return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
|
|
562
551
|
}
|
|
563
552
|
|
|
564
|
-
/*
|
|
553
|
+
/*
|
|
565
554
|
Dynamic pointer casting. Down an inheritance hierarchy
|
|
566
555
|
*/
|
|
567
556
|
SWIGRUNTIME swig_type_info *
|
|
@@ -605,7 +594,7 @@ SWIG_TypePrettyName(const swig_type_info *type) {
|
|
|
605
594
|
return type->name;
|
|
606
595
|
}
|
|
607
596
|
|
|
608
|
-
/*
|
|
597
|
+
/*
|
|
609
598
|
Set the clientdata field for a type
|
|
610
599
|
*/
|
|
611
600
|
SWIGRUNTIME void
|
|
@@ -613,14 +602,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
|
|
|
613
602
|
swig_cast_info *cast = ti->cast;
|
|
614
603
|
/* if (ti->clientdata == clientdata) return; */
|
|
615
604
|
ti->clientdata = clientdata;
|
|
616
|
-
|
|
605
|
+
|
|
617
606
|
while (cast) {
|
|
618
607
|
if (!cast->converter) {
|
|
619
608
|
swig_type_info *tc = cast->type;
|
|
620
609
|
if (!tc->clientdata) {
|
|
621
610
|
SWIG_TypeClientData(tc, clientdata);
|
|
622
611
|
}
|
|
623
|
-
}
|
|
612
|
+
}
|
|
624
613
|
cast = cast->next;
|
|
625
614
|
}
|
|
626
615
|
}
|
|
@@ -629,18 +618,18 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
|
|
|
629
618
|
SWIG_TypeClientData(ti, clientdata);
|
|
630
619
|
ti->owndata = 1;
|
|
631
620
|
}
|
|
632
|
-
|
|
621
|
+
|
|
633
622
|
/*
|
|
634
623
|
Search for a swig_type_info structure only by mangled name
|
|
635
624
|
Search is a O(log #types)
|
|
636
|
-
|
|
637
|
-
We start searching at module start, and finish searching when start == end.
|
|
625
|
+
|
|
626
|
+
We start searching at module start, and finish searching when start == end.
|
|
638
627
|
Note: if start == end at the beginning of the function, we go all the way around
|
|
639
628
|
the circular list.
|
|
640
629
|
*/
|
|
641
630
|
SWIGRUNTIME swig_type_info *
|
|
642
|
-
SWIG_MangledTypeQueryModule(swig_module_info *start,
|
|
643
|
-
swig_module_info *end,
|
|
631
|
+
SWIG_MangledTypeQueryModule(swig_module_info *start,
|
|
632
|
+
swig_module_info *end,
|
|
644
633
|
const char *name) {
|
|
645
634
|
swig_module_info *iter = start;
|
|
646
635
|
do {
|
|
@@ -649,11 +638,11 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
|
|
|
649
638
|
register size_t r = iter->size - 1;
|
|
650
639
|
do {
|
|
651
640
|
/* since l+r >= 0, we can (>> 1) instead (/ 2) */
|
|
652
|
-
register size_t i = (l + r) >> 1;
|
|
641
|
+
register size_t i = (l + r) >> 1;
|
|
653
642
|
const char *iname = iter->types[i]->name;
|
|
654
643
|
if (iname) {
|
|
655
644
|
register int compare = strcmp(name, iname);
|
|
656
|
-
if (compare == 0) {
|
|
645
|
+
if (compare == 0) {
|
|
657
646
|
return iter->types[i];
|
|
658
647
|
} else if (compare < 0) {
|
|
659
648
|
if (i) {
|
|
@@ -678,14 +667,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
|
|
|
678
667
|
Search for a swig_type_info structure for either a mangled name or a human readable name.
|
|
679
668
|
It first searches the mangled names of the types, which is a O(log #types)
|
|
680
669
|
If a type is not found it then searches the human readable names, which is O(#types).
|
|
681
|
-
|
|
682
|
-
We start searching at module start, and finish searching when start == end.
|
|
670
|
+
|
|
671
|
+
We start searching at module start, and finish searching when start == end.
|
|
683
672
|
Note: if start == end at the beginning of the function, we go all the way around
|
|
684
673
|
the circular list.
|
|
685
674
|
*/
|
|
686
675
|
SWIGRUNTIME swig_type_info *
|
|
687
|
-
SWIG_TypeQueryModule(swig_module_info *start,
|
|
688
|
-
swig_module_info *end,
|
|
676
|
+
SWIG_TypeQueryModule(swig_module_info *start,
|
|
677
|
+
swig_module_info *end,
|
|
689
678
|
const char *name) {
|
|
690
679
|
/* STEP 1: Search the name field using binary search */
|
|
691
680
|
swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
|
|
@@ -704,12 +693,12 @@ SWIG_TypeQueryModule(swig_module_info *start,
|
|
|
704
693
|
iter = iter->next;
|
|
705
694
|
} while (iter != end);
|
|
706
695
|
}
|
|
707
|
-
|
|
696
|
+
|
|
708
697
|
/* neither found a match */
|
|
709
698
|
return 0;
|
|
710
699
|
}
|
|
711
700
|
|
|
712
|
-
/*
|
|
701
|
+
/*
|
|
713
702
|
Pack binary data into a string
|
|
714
703
|
*/
|
|
715
704
|
SWIGRUNTIME char *
|
|
@@ -725,7 +714,7 @@ SWIG_PackData(char *c, void *ptr, size_t sz) {
|
|
|
725
714
|
return c;
|
|
726
715
|
}
|
|
727
716
|
|
|
728
|
-
/*
|
|
717
|
+
/*
|
|
729
718
|
Unpack binary data from a string
|
|
730
719
|
*/
|
|
731
720
|
SWIGRUNTIME const char *
|
|
@@ -739,21 +728,21 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|
|
739
728
|
uu = ((d - '0') << 4);
|
|
740
729
|
else if ((d >= 'a') && (d <= 'f'))
|
|
741
730
|
uu = ((d - ('a'-10)) << 4);
|
|
742
|
-
else
|
|
731
|
+
else
|
|
743
732
|
return (char *) 0;
|
|
744
733
|
d = *(c++);
|
|
745
734
|
if ((d >= '0') && (d <= '9'))
|
|
746
735
|
uu |= (d - '0');
|
|
747
736
|
else if ((d >= 'a') && (d <= 'f'))
|
|
748
737
|
uu |= (d - ('a'-10));
|
|
749
|
-
else
|
|
738
|
+
else
|
|
750
739
|
return (char *) 0;
|
|
751
740
|
*u = uu;
|
|
752
741
|
}
|
|
753
742
|
return c;
|
|
754
743
|
}
|
|
755
744
|
|
|
756
|
-
/*
|
|
745
|
+
/*
|
|
757
746
|
Pack 'void *' into a string buffer.
|
|
758
747
|
*/
|
|
759
748
|
SWIGRUNTIME char *
|
|
@@ -813,18 +802,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
|
|
|
813
802
|
#endif
|
|
814
803
|
|
|
815
804
|
/* Errors in SWIG */
|
|
816
|
-
#define SWIG_UnknownError -1
|
|
817
|
-
#define SWIG_IOError -2
|
|
818
|
-
#define SWIG_RuntimeError -3
|
|
819
|
-
#define SWIG_IndexError -4
|
|
820
|
-
#define SWIG_TypeError -5
|
|
821
|
-
#define SWIG_DivisionByZero -6
|
|
822
|
-
#define SWIG_OverflowError -7
|
|
823
|
-
#define SWIG_SyntaxError -8
|
|
824
|
-
#define SWIG_ValueError -9
|
|
805
|
+
#define SWIG_UnknownError -1
|
|
806
|
+
#define SWIG_IOError -2
|
|
807
|
+
#define SWIG_RuntimeError -3
|
|
808
|
+
#define SWIG_IndexError -4
|
|
809
|
+
#define SWIG_TypeError -5
|
|
810
|
+
#define SWIG_DivisionByZero -6
|
|
811
|
+
#define SWIG_OverflowError -7
|
|
812
|
+
#define SWIG_SyntaxError -8
|
|
813
|
+
#define SWIG_ValueError -9
|
|
825
814
|
#define SWIG_SystemError -10
|
|
826
815
|
#define SWIG_AttributeError -11
|
|
827
|
-
#define SWIG_MemoryError -12
|
|
816
|
+
#define SWIG_MemoryError -12
|
|
828
817
|
#define SWIG_NullReferenceError -13
|
|
829
818
|
|
|
830
819
|
|
|
@@ -1374,7 +1363,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
|
|
|
1374
1363
|
|
|
1375
1364
|
/* Runtime API */
|
|
1376
1365
|
|
|
1377
|
-
#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule()
|
|
1366
|
+
#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule(clientdata)
|
|
1378
1367
|
#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
|
|
1379
1368
|
|
|
1380
1369
|
|
|
@@ -1710,7 +1699,7 @@ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
|
|
|
1710
1699
|
}
|
|
1711
1700
|
|
|
1712
1701
|
SWIGRUNTIME swig_module_info *
|
|
1713
|
-
SWIG_Ruby_GetModule(void)
|
|
1702
|
+
SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata))
|
|
1714
1703
|
{
|
|
1715
1704
|
VALUE pointer;
|
|
1716
1705
|
swig_module_info *ret = 0;
|
|
@@ -1750,7 +1739,7 @@ SWIG_Ruby_SetModule(swig_module_info *pointer)
|
|
|
1750
1739
|
SWIGINTERN
|
|
1751
1740
|
int SWIG_Ruby_isCallable( VALUE proc )
|
|
1752
1741
|
{
|
|
1753
|
-
if ( rb_respond_to( proc, swig_call_id )
|
|
1742
|
+
if ( rb_respond_to( proc, swig_call_id ) )
|
|
1754
1743
|
return 1;
|
|
1755
1744
|
return 0;
|
|
1756
1745
|
}
|
|
@@ -1763,7 +1752,7 @@ int SWIG_Ruby_isCallable( VALUE proc )
|
|
|
1763
1752
|
SWIGINTERN
|
|
1764
1753
|
int SWIG_Ruby_arity( VALUE proc, int minimal )
|
|
1765
1754
|
{
|
|
1766
|
-
if ( rb_respond_to( proc, swig_arity_id )
|
|
1755
|
+
if ( rb_respond_to( proc, swig_arity_id ) )
|
|
1767
1756
|
{
|
|
1768
1757
|
VALUE num = rb_funcall( proc, swig_arity_id, 0 );
|
|
1769
1758
|
int arity = NUM2INT(num);
|
|
@@ -1817,7 +1806,7 @@ static VALUE mLowlevel;
|
|
|
1817
1806
|
#define SWIG_RUBY_THREAD_END_BLOCK
|
|
1818
1807
|
|
|
1819
1808
|
|
|
1820
|
-
#define SWIGVERSION
|
|
1809
|
+
#define SWIGVERSION 0x020012
|
|
1821
1810
|
#define SWIG_VERSION SWIGVERSION
|
|
1822
1811
|
|
|
1823
1812
|
|
|
@@ -2668,31 +2657,6 @@ fail:
|
|
|
2668
2657
|
}
|
|
2669
2658
|
|
|
2670
2659
|
|
|
2671
|
-
SWIGINTERN VALUE
|
|
2672
|
-
_wrap_ws2811_dma_error_get(VALUE self) {
|
|
2673
|
-
VALUE _val;
|
|
2674
|
-
|
|
2675
|
-
_val = SWIG_From_unsigned_SS_int((unsigned int)(ws2811_dma_error));
|
|
2676
|
-
return _val;
|
|
2677
|
-
}
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
SWIGINTERN VALUE
|
|
2681
|
-
_wrap_ws2811_dma_error_set(VALUE self, VALUE _val) {
|
|
2682
|
-
{
|
|
2683
|
-
unsigned int val;
|
|
2684
|
-
int res = SWIG_AsVal_unsigned_SS_int(_val, &val);
|
|
2685
|
-
if (!SWIG_IsOK(res)) {
|
|
2686
|
-
SWIG_exception_fail(SWIG_ArgError(res), "in variable '""ws2811_dma_error""' of type '""uint32_t""'");
|
|
2687
|
-
}
|
|
2688
|
-
ws2811_dma_error = (uint32_t)(val);
|
|
2689
|
-
}
|
|
2690
|
-
return _val;
|
|
2691
|
-
fail:
|
|
2692
|
-
return Qnil;
|
|
2693
|
-
}
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
2660
|
SWIGINTERN VALUE
|
|
2697
2661
|
_wrap_ws2811_wait(int argc, VALUE *argv, VALUE self) {
|
|
2698
2662
|
ws2811_t *arg1 = (ws2811_t *) 0 ;
|
|
@@ -2885,18 +2849,18 @@ static swig_cast_info *swig_cast_initial[] = {
|
|
|
2885
2849
|
|
|
2886
2850
|
/* -----------------------------------------------------------------------------
|
|
2887
2851
|
* Type initialization:
|
|
2888
|
-
* This problem is tough by the requirement that no dynamic
|
|
2889
|
-
* memory is used. Also, since swig_type_info structures store pointers to
|
|
2852
|
+
* This problem is tough by the requirement that no dynamic
|
|
2853
|
+
* memory is used. Also, since swig_type_info structures store pointers to
|
|
2890
2854
|
* swig_cast_info structures and swig_cast_info structures store pointers back
|
|
2891
|
-
* to swig_type_info structures, we need some lookup code at initialization.
|
|
2892
|
-
* The idea is that swig generates all the structures that are needed.
|
|
2893
|
-
* The runtime then collects these partially filled structures.
|
|
2894
|
-
* The SWIG_InitializeModule function takes these initial arrays out of
|
|
2855
|
+
* to swig_type_info structures, we need some lookup code at initialization.
|
|
2856
|
+
* The idea is that swig generates all the structures that are needed.
|
|
2857
|
+
* The runtime then collects these partially filled structures.
|
|
2858
|
+
* The SWIG_InitializeModule function takes these initial arrays out of
|
|
2895
2859
|
* swig_module, and does all the lookup, filling in the swig_module.types
|
|
2896
2860
|
* array with the correct data and linking the correct swig_cast_info
|
|
2897
2861
|
* structures together.
|
|
2898
2862
|
*
|
|
2899
|
-
* The generated swig_type_info structures are assigned staticly to an initial
|
|
2863
|
+
* The generated swig_type_info structures are assigned staticly to an initial
|
|
2900
2864
|
* array. We just loop through that array, and handle each type individually.
|
|
2901
2865
|
* First we lookup if this type has been already loaded, and if so, use the
|
|
2902
2866
|
* loaded structure instead of the generated one. Then we have to fill in the
|
|
@@ -2906,17 +2870,17 @@ static swig_cast_info *swig_cast_initial[] = {
|
|
|
2906
2870
|
* a column is one of the swig_cast_info structures for that type.
|
|
2907
2871
|
* The cast_initial array is actually an array of arrays, because each row has
|
|
2908
2872
|
* a variable number of columns. So to actually build the cast linked list,
|
|
2909
|
-
* we find the array of casts associated with the type, and loop through it
|
|
2873
|
+
* we find the array of casts associated with the type, and loop through it
|
|
2910
2874
|
* adding the casts to the list. The one last trick we need to do is making
|
|
2911
2875
|
* sure the type pointer in the swig_cast_info struct is correct.
|
|
2912
2876
|
*
|
|
2913
|
-
* First off, we lookup the cast->type name to see if it is already loaded.
|
|
2877
|
+
* First off, we lookup the cast->type name to see if it is already loaded.
|
|
2914
2878
|
* There are three cases to handle:
|
|
2915
2879
|
* 1) If the cast->type has already been loaded AND the type we are adding
|
|
2916
2880
|
* casting info to has not been loaded (it is in this module), THEN we
|
|
2917
2881
|
* replace the cast->type pointer with the type pointer that has already
|
|
2918
2882
|
* been loaded.
|
|
2919
|
-
* 2) If BOTH types (the one we are adding casting info to, and the
|
|
2883
|
+
* 2) If BOTH types (the one we are adding casting info to, and the
|
|
2920
2884
|
* cast->type) are loaded, THEN the cast info has already been loaded by
|
|
2921
2885
|
* the previous module so we just ignore it.
|
|
2922
2886
|
* 3) Finally, if cast->type has not already been loaded, then we add that
|
|
@@ -2942,8 +2906,6 @@ SWIG_InitializeModule(void *clientdata) {
|
|
|
2942
2906
|
swig_module_info *module_head, *iter;
|
|
2943
2907
|
int found, init;
|
|
2944
2908
|
|
|
2945
|
-
clientdata = clientdata;
|
|
2946
|
-
|
|
2947
2909
|
/* check to see if the circular list has been setup, if not, set it up */
|
|
2948
2910
|
if (swig_module.next==0) {
|
|
2949
2911
|
/* Initialize the swig_module */
|
|
@@ -2981,7 +2943,7 @@ SWIG_InitializeModule(void *clientdata) {
|
|
|
2981
2943
|
module_head->next = &swig_module;
|
|
2982
2944
|
}
|
|
2983
2945
|
|
|
2984
|
-
/* When multiple
|
|
2946
|
+
/* When multiple interpreters are used, a module could have already been initialized in
|
|
2985
2947
|
a different interpreter, but not yet have a pointer in this interpreter.
|
|
2986
2948
|
In this case, we do not want to continue adding types... everything should be
|
|
2987
2949
|
set up already */
|
|
@@ -2995,7 +2957,7 @@ SWIG_InitializeModule(void *clientdata) {
|
|
|
2995
2957
|
swig_type_info *type = 0;
|
|
2996
2958
|
swig_type_info *ret;
|
|
2997
2959
|
swig_cast_info *cast;
|
|
2998
|
-
|
|
2960
|
+
|
|
2999
2961
|
#ifdef SWIGRUNTIME_DEBUG
|
|
3000
2962
|
printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
|
|
3001
2963
|
#endif
|
|
@@ -3022,7 +2984,7 @@ SWIG_InitializeModule(void *clientdata) {
|
|
|
3022
2984
|
/* Insert casting types */
|
|
3023
2985
|
cast = swig_module.cast_initial[i];
|
|
3024
2986
|
while (cast->type) {
|
|
3025
|
-
|
|
2987
|
+
|
|
3026
2988
|
/* Don't need to add information already in the list */
|
|
3027
2989
|
ret = 0;
|
|
3028
2990
|
#ifdef SWIGRUNTIME_DEBUG
|
|
@@ -3179,8 +3141,6 @@ SWIGEXPORT void Init_lowlevel(void) {
|
|
|
3179
3141
|
rb_define_singleton_method(mLowlevel, "ws2811_direct_colors", _wrap_ws2811_direct_colors_get, 0);
|
|
3180
3142
|
rb_define_singleton_method(mLowlevel, "ws2811_direct_colors=", _wrap_ws2811_direct_colors_set, 1);
|
|
3181
3143
|
rb_define_module_function(mLowlevel, "ws2811_render", _wrap_ws2811_render, -1);
|
|
3182
|
-
rb_define_singleton_method(mLowlevel, "ws2811_dma_error", _wrap_ws2811_dma_error_get, 0);
|
|
3183
|
-
rb_define_singleton_method(mLowlevel, "ws2811_dma_error=", _wrap_ws2811_dma_error_set, 1);
|
|
3184
3144
|
rb_define_module_function(mLowlevel, "ws2811_wait", _wrap_ws2811_wait, -1);
|
|
3185
3145
|
rb_define_module_function(mLowlevel, "ws2811_led_get", _wrap_ws2811_led_get, -1);
|
|
3186
3146
|
rb_define_module_function(mLowlevel, "ws2811_led_set", _wrap_ws2811_led_set, -1);
|
data/ext/ws2812/mailbox.c
CHANGED
|
@@ -101,8 +101,7 @@ static int mbox_property(int file_desc, void *buf)
|
|
|
101
101
|
ret_val = ioctl(fd, IOCTL_MBOX_PROPERTY, buf);
|
|
102
102
|
|
|
103
103
|
if (ret_val < 0) {
|
|
104
|
-
|
|
105
|
-
// XXX: this is apparently the only error, so why would we bother anyone?
|
|
104
|
+
printf("ioctl_set_msg failed, errno %d: %m\n", errno);
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
#ifdef DEBUG
|
|
@@ -268,42 +267,33 @@ unsigned execute_qpu(int file_desc, unsigned num_qpus, unsigned control, unsigne
|
|
|
268
267
|
return p[5];
|
|
269
268
|
}
|
|
270
269
|
|
|
271
|
-
// mbox_open errors go here
|
|
272
|
-
int mbox_errno = MBOX_ERRNO_OK;
|
|
273
|
-
|
|
274
270
|
int mbox_open(void) {
|
|
275
271
|
int file_desc;
|
|
276
|
-
char
|
|
277
|
-
|
|
278
|
-
mbox_errno = MBOX_ERRNO_OK;
|
|
272
|
+
char filename[64];
|
|
279
273
|
|
|
280
274
|
// open a char device file used for communicating with kernel mbox driver
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
mbox_errno = MBOX_ERRNO_CANT_TEMPNAM;
|
|
284
|
-
goto err;
|
|
285
|
-
}
|
|
286
|
-
unlink(filename);
|
|
287
|
-
if (mknod(filename, S_IFCHR|0600, makedev(100, 0)) < 0) {
|
|
288
|
-
// printf("Failed to create mailbox device %s: %m\n", filename);
|
|
289
|
-
mbox_errno = MBOX_ERRNO_CANT_MKNOD;
|
|
290
|
-
goto err;
|
|
291
|
-
}
|
|
275
|
+
|
|
276
|
+
sprintf(filename, "/dev/vcio");
|
|
292
277
|
file_desc = open(filename, 0);
|
|
278
|
+
|
|
279
|
+
if( file_desc < 0 ){
|
|
280
|
+
printf("Failed to open %s, trying old method.\n", filename);
|
|
281
|
+
sprintf(filename, "/dev/mailbox-%d", getpid());
|
|
282
|
+
unlink(filename);
|
|
283
|
+
if (mknod(filename, S_IFCHR|0600, makedev(100, 0)) < 0) {
|
|
284
|
+
printf("Failed to create mailbox device %s: %m\n", filename);
|
|
285
|
+
return -1;
|
|
286
|
+
}
|
|
287
|
+
file_desc = open(filename, 0);
|
|
288
|
+
}
|
|
293
289
|
if (file_desc < 0) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
290
|
+
printf("Can't open device file %s: %m\n", filename);
|
|
291
|
+
//unlink(filename);
|
|
292
|
+
return -1;
|
|
297
293
|
}
|
|
298
|
-
unlink(filename);
|
|
294
|
+
//unlink(filename);
|
|
299
295
|
|
|
300
296
|
return file_desc;
|
|
301
|
-
err:
|
|
302
|
-
if (filename != NULL) {
|
|
303
|
-
unlink(filename);
|
|
304
|
-
free(filename);
|
|
305
|
-
}
|
|
306
|
-
return -1;
|
|
307
297
|
}
|
|
308
298
|
|
|
309
299
|
void mbox_close(int file_desc) {
|
data/ext/ws2812/mailbox.h
CHANGED
|
@@ -30,13 +30,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
30
30
|
#define MAJOR_NUM 100
|
|
31
31
|
#define IOCTL_MBOX_PROPERTY _IOWR(MAJOR_NUM, 0, char *)
|
|
32
32
|
|
|
33
|
-
#define MBOX_ERRNO_OK 0
|
|
34
|
-
#define MBOX_ERRNO_CANT_TEMPNAM 1
|
|
35
|
-
#define MBOX_ERRNO_CANT_MKNOD 2
|
|
36
|
-
#define MBOX_ERRNO_CANT_OPEN 3
|
|
37
|
-
// mbox_open errors go here
|
|
38
|
-
extern int mbox_errno;
|
|
39
|
-
|
|
40
33
|
int mbox_open(void);
|
|
41
34
|
void mbox_close(int file_desc);
|
|
42
35
|
|
data/ext/ws2812/pwm.h
CHANGED
data/ext/ws2812/ws2811.c
CHANGED
|
@@ -561,11 +561,6 @@ void ws2811_fini(ws2811_t *ws2811)
|
|
|
561
561
|
ws2811_cleanup(ws2811);
|
|
562
562
|
}
|
|
563
563
|
|
|
564
|
-
/**
|
|
565
|
-
* Contains any errors from executing ws2811_wait
|
|
566
|
-
*/
|
|
567
|
-
uint32_t ws2811_dma_error = 0;
|
|
568
|
-
|
|
569
564
|
/**
|
|
570
565
|
* Wait for any executing DMA operation to complete before returning.
|
|
571
566
|
*
|
|
@@ -585,19 +580,21 @@ int ws2811_wait(ws2811_t *ws2811)
|
|
|
585
580
|
|
|
586
581
|
if (dma->cs & RPI_DMA_CS_ERROR)
|
|
587
582
|
{
|
|
588
|
-
|
|
589
|
-
ws2811_dma_error = dma->debug;
|
|
583
|
+
fprintf(stderr, "DMA Error: %08x\n", dma->debug);
|
|
590
584
|
return -1;
|
|
591
585
|
}
|
|
592
586
|
|
|
593
587
|
return 0;
|
|
594
588
|
}
|
|
595
589
|
|
|
590
|
+
|
|
591
|
+
|
|
596
592
|
/**
|
|
597
593
|
* Setting to non-zero bypasses brightness
|
|
598
594
|
*/
|
|
599
595
|
uint8_t ws2811_direct_colors = 0;
|
|
600
596
|
|
|
597
|
+
|
|
601
598
|
/**
|
|
602
599
|
* Render the PWM DMA buffer from the user supplied LED arrays and start the DMA
|
|
603
600
|
* controller. This will update all LEDs on both PWM channels.
|
|
@@ -621,16 +618,17 @@ int ws2811_render(ws2811_t *ws2811)
|
|
|
621
618
|
for (i = 0; i < channel->count; i++) // Led
|
|
622
619
|
{
|
|
623
620
|
uint8_t color[] = {0, 0, 0};
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
// apply the gamma table
|
|
630
|
-
color[0] = (ws281x_gamma[color[0]] * scale) >> 8; // green
|
|
631
|
-
color[1] = (ws281x_gamma[color[1]] * scale) >> 8; // red
|
|
632
|
-
color[2] = (ws281x_gamma[color[2]] * scale) >> 8; // blue
|
|
621
|
+
|
|
622
|
+
if (ws2811_direct_colors == 0){
|
|
623
|
+
color[0] = (ws281x_gamma[((channel->leds[i] >> 8) & 0xff)] * scale) >> 8; // green
|
|
624
|
+
color[1] = (ws281x_gamma[((channel->leds[i] >> 16) & 0xff)] * scale) >> 8; // red
|
|
625
|
+
color[2] = (ws281x_gamma[((channel->leds[i] >> 0) & 0xff)] * scale) >> 8; // blue
|
|
633
626
|
}
|
|
627
|
+
else {
|
|
628
|
+
color[0] = (channel->leds[i] >> 8) & 0xff; // green
|
|
629
|
+
color[1] = (channel->leds[i] >> 16) & 0xff; // red
|
|
630
|
+
color[2] = (channel->leds[i] >> 0) & 0xff; // blue
|
|
631
|
+
};
|
|
634
632
|
|
|
635
633
|
for (j = 0; j < ARRAY_SIZE(color); j++) // Color
|
|
636
634
|
{
|
data/ext/ws2812/ws2811.h
CHANGED
|
@@ -59,9 +59,8 @@ typedef struct
|
|
|
59
59
|
|
|
60
60
|
int ws2811_init(ws2811_t *ws2811); //< Initialize buffers/hardware
|
|
61
61
|
void ws2811_fini(ws2811_t *ws2811); //< Tear it all down
|
|
62
|
-
extern uint8_t ws2811_direct_colors;
|
|
62
|
+
extern uint8_t ws2811_direct_colors; //< Set to non-zero to bypass "brightness" [gamma correction] altogether (default is 0)
|
|
63
63
|
int ws2811_render(ws2811_t *ws2811); //< Send LEDs off to hardware
|
|
64
|
-
extern uint32_t ws2811_dma_error; //< DMA errors from ws2811_wait go here
|
|
65
64
|
int ws2811_wait(ws2811_t *ws2811); //< Wait for DMA completion
|
|
66
65
|
|
|
67
66
|
|
data/lib/ws2812.rb
CHANGED
metadata
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ws2812
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.0.3
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Michal Jirků
|
|
@@ -17,33 +16,29 @@ dependencies:
|
|
|
17
16
|
- !ruby/object:Gem::Dependency
|
|
18
17
|
name: rake
|
|
19
18
|
requirement: !ruby/object:Gem::Requirement
|
|
20
|
-
none: false
|
|
21
19
|
requirements:
|
|
22
|
-
- -
|
|
20
|
+
- - ">="
|
|
23
21
|
- !ruby/object:Gem::Version
|
|
24
22
|
version: '0'
|
|
25
23
|
type: :development
|
|
26
24
|
prerelease: false
|
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
28
|
-
none: false
|
|
29
26
|
requirements:
|
|
30
|
-
- -
|
|
27
|
+
- - ">="
|
|
31
28
|
- !ruby/object:Gem::Version
|
|
32
29
|
version: '0'
|
|
33
30
|
- !ruby/object:Gem::Dependency
|
|
34
31
|
name: rake-compiler
|
|
35
32
|
requirement: !ruby/object:Gem::Requirement
|
|
36
|
-
none: false
|
|
37
33
|
requirements:
|
|
38
|
-
- -
|
|
34
|
+
- - ">="
|
|
39
35
|
- !ruby/object:Gem::Version
|
|
40
36
|
version: '0'
|
|
41
37
|
type: :development
|
|
42
38
|
prerelease: false
|
|
43
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
44
|
-
none: false
|
|
45
40
|
requirements:
|
|
46
|
-
- -
|
|
41
|
+
- - ">="
|
|
47
42
|
- !ruby/object:Gem::Version
|
|
48
43
|
version: '0'
|
|
49
44
|
description: Gem that encapsulates modified RPi ws281x library from UnicornHat to
|
|
@@ -54,7 +49,7 @@ extensions:
|
|
|
54
49
|
- ext/ws2812/extconf.rb
|
|
55
50
|
extra_rdoc_files: []
|
|
56
51
|
files:
|
|
57
|
-
- .gitignore
|
|
52
|
+
- ".gitignore"
|
|
58
53
|
- LICENSE.txt
|
|
59
54
|
- README.md
|
|
60
55
|
- Rakefile
|
|
@@ -89,26 +84,25 @@ files:
|
|
|
89
84
|
homepage: https://github.com/wejn/ws2812
|
|
90
85
|
licenses:
|
|
91
86
|
- GPL-2.0
|
|
87
|
+
metadata: {}
|
|
92
88
|
post_install_message:
|
|
93
89
|
rdoc_options: []
|
|
94
90
|
require_paths:
|
|
95
91
|
- lib
|
|
96
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
|
-
none: false
|
|
98
93
|
requirements:
|
|
99
|
-
- -
|
|
94
|
+
- - ">="
|
|
100
95
|
- !ruby/object:Gem::Version
|
|
101
96
|
version: '0'
|
|
102
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
|
-
none: false
|
|
104
98
|
requirements:
|
|
105
|
-
- -
|
|
99
|
+
- - ">="
|
|
106
100
|
- !ruby/object:Gem::Version
|
|
107
101
|
version: '0'
|
|
108
102
|
requirements: []
|
|
109
103
|
rubyforge_project:
|
|
110
|
-
rubygems_version:
|
|
104
|
+
rubygems_version: 2.2.2
|
|
111
105
|
signing_key:
|
|
112
|
-
specification_version:
|
|
106
|
+
specification_version: 4
|
|
113
107
|
summary: Ruby wrapper around WS2812 LED driver for Raspberry Pi
|
|
114
108
|
test_files: []
|