JoyPi-RGB-Matrix-RaspberryPi 1.0.0__tar.gz → 1.0.2__tar.gz
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.
- joypi_rgb_matrix_raspberrypi-1.0.2/.gitignore +2 -0
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/PKG-INFO +6 -4
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/README.md +26 -24
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/examples/rgbmatrix.py +8 -4
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/pyproject.toml +1 -1
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/src/JoyPi_RGB_Matrix_RaspberryPi/RGB_Matrix.py +25 -10
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/src/JoyPi_RGB_Matrix_RaspberryPi/_PixelStrip.py +59 -43
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/.gitattributes +0 -0
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/LICENSE +0 -0
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/src/JoyPi_RGB_Matrix_RaspberryPi/_LEDTransferData.py +0 -0
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/src/JoyPi_RGB_Matrix_RaspberryPi/_RGBW.py +0 -0
- {joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/src/JoyPi_RGB_Matrix_RaspberryPi/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: JoyPi_RGB_Matrix_RaspberryPi
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: This library enables usage of RGB matrix with RP2040 microcontroller chip on the Raspberry Pi.
|
|
5
5
|
Project-URL: Homepage, https://github.com/joy-it/JoyPi_RGB_Matrix_RaspberryPi
|
|
6
6
|
Project-URL: Issues, https://github.com/joy-it/JoyPi_RGB_Matrix_RaspberryPi/issues
|
|
@@ -20,13 +20,15 @@ This library enables usage of RGB matrix with RP2040 microcontroller chip on the
|
|
|
20
20
|
## Installation
|
|
21
21
|
You can install this library from PyPI.
|
|
22
22
|
To install it for the current user on your Raspberry Pi, use the following command:
|
|
23
|
-
```
|
|
24
|
-
pip install
|
|
23
|
+
```bash
|
|
24
|
+
pip install JoyPi-RGB-Matrix-RaspberryPi
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Library Guide
|
|
28
28
|
- `LEDMatrix( count = 64, brightness = 10, right_border = [7,15,23,31,39,47,55,63], left_border = [0,8,16,24,32,40,48,56])`- initialize LED matrix with default values for Joy-Pi
|
|
29
29
|
- `clean()` - clears the LED matrix
|
|
30
|
+
- `setBrightness(brightness)` - set brightness to a certain level (0-255)
|
|
31
|
+
- `getPixelNum()` - returns number of pixel of led matrix
|
|
30
32
|
- `setPixel(position, colour)` - sets specific pixel to a selected colour
|
|
31
33
|
- `RGB_on(colour)` - sets the complete matrix to one selected colour
|
|
32
34
|
- `RGB_off()` - turns the complete matrix off
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
# JoyPi_RGB_Matrix_RaspberryPi
|
|
2
|
-
This library enables usage of RGB matrix with RP2040 microcontroller chip on the Raspberry Pi.
|
|
3
|
-
|
|
4
|
-
>[!WARNING]
|
|
5
|
-
> This library was written for the usage of the LED matrix of the Joy-Pi Advanced 2 and Joy-Pi Note 2. Both Joy-Pis have the RP2040 microcontroller chip to control the LED matrix. This is to ensure compatibility with the Raspberry Pi 5 because the library which was used beforehand is not compatible up to this date.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
You can install this library from PyPI.
|
|
9
|
-
To install it for the current user on your Raspberry Pi, use the following command:
|
|
10
|
-
```
|
|
11
|
-
pip install
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Library Guide
|
|
15
|
-
- `LEDMatrix( count = 64, brightness = 10, right_border = [7,15,23,31,39,47,55,63], left_border = [0,8,16,24,32,40,48,56])`- initialize LED matrix with default values for Joy-Pi
|
|
16
|
-
- `clean()` - clears the LED matrix
|
|
17
|
-
- `
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
20
|
-
- `
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
23
|
-
- `
|
|
24
|
-
- `
|
|
1
|
+
# JoyPi_RGB_Matrix_RaspberryPi
|
|
2
|
+
This library enables usage of RGB matrix with RP2040 microcontroller chip on the Raspberry Pi.
|
|
3
|
+
|
|
4
|
+
>[!WARNING]
|
|
5
|
+
> This library was written for the usage of the LED matrix of the Joy-Pi Advanced 2 and Joy-Pi Note 2. Both Joy-Pis have the RP2040 microcontroller chip to control the LED matrix. This is to ensure compatibility with the Raspberry Pi 5 because the library which was used beforehand is not compatible up to this date.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
You can install this library from PyPI.
|
|
9
|
+
To install it for the current user on your Raspberry Pi, use the following command:
|
|
10
|
+
```bash
|
|
11
|
+
pip install JoyPi-RGB-Matrix-RaspberryPi
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Library Guide
|
|
15
|
+
- `LEDMatrix( count = 64, brightness = 10, right_border = [7,15,23,31,39,47,55,63], left_border = [0,8,16,24,32,40,48,56])`- initialize LED matrix with default values for Joy-Pi
|
|
16
|
+
- `clean()` - clears the LED matrix
|
|
17
|
+
- `setBrightness(brightness)` - set brightness to a certain level (0-255)
|
|
18
|
+
- `getPixelNum()` - returns number of pixel of led matrix
|
|
19
|
+
- `setPixel(position, colour)` - sets specific pixel to a selected colour
|
|
20
|
+
- `RGB_on(colour)` - sets the complete matrix to one selected colour
|
|
21
|
+
- `RGB_off()` - turns the complete matrix off
|
|
22
|
+
- `rainbow(wait_ms=20, iterations=1)` - rainbow effect on the whole matrix with default values
|
|
23
|
+
- `colourWipe(colour, wait_ms=50)` - Move selected colour pixel by pixel onto the matrix with default speed
|
|
24
|
+
- `theaterChase( colour, wait_ms=50, iterations=10)` - chaser animation with a selected colour with deafult speed
|
|
25
|
+
- `show()` - displays set pixels
|
|
26
|
+
- `demo1()` - demo program version 1
|
|
25
27
|
- `demo2()` - demo program version 2
|
{joypi_rgb_matrix_raspberrypi-1.0.0 → joypi_rgb_matrix_raspberrypi-1.0.2}/examples/rgbmatrix.py
RENAMED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# Required modules are inserted and configured
|
|
2
2
|
from JoyPi_RGB_Matrix_RaspberryPi import RGB_Matrix
|
|
3
3
|
import time
|
|
4
|
-
import
|
|
4
|
+
import busio
|
|
5
|
+
import board
|
|
5
6
|
|
|
6
7
|
# open I2C connection
|
|
7
|
-
|
|
8
|
+
i2c = busio.I2C(board.SCL, board.SDA)
|
|
8
9
|
# Create object matrix
|
|
9
|
-
matrix = RGB_Matrix(
|
|
10
|
+
matrix = RGB_Matrix(i2c)
|
|
11
|
+
|
|
12
|
+
# set brightness to 100 (0-255)
|
|
13
|
+
matrix.setBrightness(100)
|
|
10
14
|
|
|
11
15
|
# colourWipe animation with different colors
|
|
12
16
|
print("colourWipe animation")
|
|
@@ -47,4 +51,4 @@ time.sleep(5)
|
|
|
47
51
|
|
|
48
52
|
# Clear matrix
|
|
49
53
|
print("Clear LEDs")
|
|
50
|
-
matrix.clean()
|
|
54
|
+
matrix.clean()
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
from ._RGBW import RGBW
|
|
2
2
|
from ._PixelStrip import PixelStrip
|
|
3
3
|
import time
|
|
4
|
+
import busio
|
|
4
5
|
|
|
5
6
|
class RGB_Matrix:
|
|
6
7
|
"""
|
|
7
8
|
New version using the I2C-based PixelStrip instead of rpi_ws281x.
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
|
-
def __init__(self,
|
|
11
|
+
def __init__(self, i2c: busio.I2C, i2c_adress = 0x66, count = 64, brightness = 10,
|
|
11
12
|
right_border = [7,15,23,31,39,47,55,63], left_border = [0,8,16,24,32,40,48,56]):
|
|
12
13
|
"""
|
|
13
14
|
initiliaze LED matrix
|
|
@@ -26,8 +27,7 @@ class RGB_Matrix:
|
|
|
26
27
|
self.LEFT_BORDER = left_border
|
|
27
28
|
|
|
28
29
|
# Create the I2C-based PixelStrip instance
|
|
29
|
-
self.strip = PixelStrip(num=self.LED_COUNT, brightness=self.LED_BRIGHTNESS,
|
|
30
|
-
bus = bus, bus_id = bus_id, i2c_adress=i2c_adress)
|
|
30
|
+
self.strip = PixelStrip(num=self.LED_COUNT, i2c=i2c, brightness=self.LED_BRIGHTNESS, i2c_adress=i2c_adress)
|
|
31
31
|
self.strip.begin()
|
|
32
32
|
|
|
33
33
|
def clean(self):
|
|
@@ -51,7 +51,7 @@ class RGB_Matrix:
|
|
|
51
51
|
|
|
52
52
|
:param colour: RGBW value 32 bit integer
|
|
53
53
|
"""
|
|
54
|
-
for i in range(self.strip.
|
|
54
|
+
for i in range(self.strip.getNumPixels()):
|
|
55
55
|
self.strip.setPixelColor(i, colour)
|
|
56
56
|
self.strip.show()
|
|
57
57
|
|
|
@@ -59,7 +59,7 @@ class RGB_Matrix:
|
|
|
59
59
|
"""
|
|
60
60
|
turn all LEDs in matrix off
|
|
61
61
|
"""
|
|
62
|
-
for i in range(self.strip.
|
|
62
|
+
for i in range(self.strip.getNumPixels()):
|
|
63
63
|
self.strip.setPixelColor(i, RGBW(0, 0, 0, 0))
|
|
64
64
|
self.strip.show()
|
|
65
65
|
|
|
@@ -86,7 +86,7 @@ class RGB_Matrix:
|
|
|
86
86
|
:param iterations: iterations of animation
|
|
87
87
|
"""
|
|
88
88
|
for j in range(256 * iterations):
|
|
89
|
-
for i in range(self.strip.
|
|
89
|
+
for i in range(self.strip.getNumPixels()):
|
|
90
90
|
self.strip.setPixelColor(i, self.wheel((i + j) & 255))
|
|
91
91
|
self.strip.show()
|
|
92
92
|
time.sleep(wait_ms / 1000.0)
|
|
@@ -98,7 +98,7 @@ class RGB_Matrix:
|
|
|
98
98
|
:param color: RGB value to set pixels to
|
|
99
99
|
:param wait_ms: time between each pixel
|
|
100
100
|
"""
|
|
101
|
-
for i in range(self.strip.
|
|
101
|
+
for i in range(self.strip.getNumPixels()):
|
|
102
102
|
self.strip.setPixelColor(i, color)
|
|
103
103
|
self.strip.show()
|
|
104
104
|
time.sleep(wait_ms / 1000.0)
|
|
@@ -113,11 +113,11 @@ class RGB_Matrix:
|
|
|
113
113
|
"""
|
|
114
114
|
for j in range(iterations):
|
|
115
115
|
for q in range(3):
|
|
116
|
-
for i in range(0, self.strip.
|
|
116
|
+
for i in range(0, self.strip.getNumPixels(), 3):
|
|
117
117
|
self.strip.setPixelColor(i + q, color)
|
|
118
118
|
self.strip.show()
|
|
119
119
|
time.sleep(wait_ms / 1000.0)
|
|
120
|
-
for i in range(0, self.strip.
|
|
120
|
+
for i in range(0, self.strip.getNumPixels(), 3):
|
|
121
121
|
self.strip.setPixelColor(i + q, 0)
|
|
122
122
|
|
|
123
123
|
def demo1(self):
|
|
@@ -151,4 +151,19 @@ class RGB_Matrix:
|
|
|
151
151
|
self.strip.setPixelColor(i, RGBW(255, 0, 0, 0))
|
|
152
152
|
self.strip.show()
|
|
153
153
|
except KeyboardInterrupt:
|
|
154
|
-
self.clean()
|
|
154
|
+
self.clean()
|
|
155
|
+
|
|
156
|
+
def setBrightness(self, brightness):
|
|
157
|
+
"""
|
|
158
|
+
Set brightness of all pixels
|
|
159
|
+
|
|
160
|
+
:param brightness: brightness level (0-255)
|
|
161
|
+
"""
|
|
162
|
+
self.strip.setBrightness(brightness)
|
|
163
|
+
self.strip.show()
|
|
164
|
+
|
|
165
|
+
def getPixelNum(self):
|
|
166
|
+
"""
|
|
167
|
+
Get number of pixels in matrix
|
|
168
|
+
"""
|
|
169
|
+
return self.strip.getNumPixels()
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from ._LEDTransferData import LEDTransferData
|
|
2
2
|
from enum import Enum
|
|
3
|
-
import
|
|
3
|
+
import busio
|
|
4
|
+
from adafruit_bus_device import i2c_device
|
|
4
5
|
import time
|
|
5
6
|
|
|
6
7
|
class FunctionEnum(Enum):
|
|
@@ -16,26 +17,25 @@ class FunctionEnum(Enum):
|
|
|
16
17
|
SETPIXELCOLOR = 1
|
|
17
18
|
FILL = 2
|
|
18
19
|
SETBRIGHTNESS = 3
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
SENDALLPIXRGB5 = 16
|
|
20
|
+
GAMMA8 = 4
|
|
21
|
+
GAMMA32 = 5
|
|
22
|
+
NUMPIXEL = 6
|
|
23
|
+
COLORHSV = 7
|
|
24
|
+
CLEAR = 8
|
|
25
|
+
SENDDATA2SHOW = 9
|
|
26
|
+
SENDALLPIXRGB0 = 10
|
|
27
|
+
SENDALLPIXRGB1 = 11
|
|
28
|
+
SENDALLPIXRGB2 = 12
|
|
29
|
+
SENDALLPIXRGB3 = 13
|
|
30
|
+
SENDALLPIXRGB4 = 14
|
|
31
|
+
SENDALLPIXRGB5 = 15
|
|
32
32
|
|
|
33
33
|
class PixelStrip:
|
|
34
34
|
"""
|
|
35
35
|
Controls a strip of LEDs (WS281x / SK6812) via I2C.
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
|
-
def __init__(self, num,
|
|
38
|
+
def __init__(self, num, i2c: busio.I2C, brightness=255, i2c_adress = 0x66):
|
|
39
39
|
"""
|
|
40
40
|
initilize LED controll class
|
|
41
41
|
|
|
@@ -43,8 +43,8 @@ class PixelStrip:
|
|
|
43
43
|
:param brightness: brightness of all pixels
|
|
44
44
|
"""
|
|
45
45
|
self.num = num
|
|
46
|
-
self.
|
|
47
|
-
self.
|
|
46
|
+
self.address = i2c_adress
|
|
47
|
+
self.device = i2c_device.I2CDevice(i2c, self.address)
|
|
48
48
|
self.transfer_data = LEDTransferData()
|
|
49
49
|
self.transfer_data.setBright(brightness)
|
|
50
50
|
|
|
@@ -61,25 +61,45 @@ class PixelStrip:
|
|
|
61
61
|
|
|
62
62
|
:param cmd: block of data to send
|
|
63
63
|
"""
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
64
|
+
data = bytes([
|
|
65
|
+
cmd & 0xFF,
|
|
66
|
+
0x0C,
|
|
67
|
+
self.transfer_data.func & 0xFF,
|
|
68
|
+
self.transfer_data.pos & 0xFF,
|
|
69
|
+
self.transfer_data.r & 0xFF,
|
|
70
|
+
self.transfer_data.g & 0xFF,
|
|
71
|
+
self.transfer_data.b & 0xFF,
|
|
72
|
+
self.transfer_data.w & 0xFF,
|
|
73
|
+
self.transfer_data.c & 0xFF,
|
|
74
|
+
self.transfer_data.bright & 0xFF,
|
|
75
|
+
self.transfer_data.first & 0xFF,
|
|
76
|
+
self.transfer_data.count & 0xFF,
|
|
77
|
+
self.transfer_data.data & 0xFF,
|
|
78
|
+
self.transfer_data.data1 & 0xFF,
|
|
79
|
+
])
|
|
80
|
+
with self.device as bus_device:
|
|
81
|
+
bus_device.write(data)
|
|
80
82
|
time.sleep(0.003) # Hardware timing delay
|
|
81
83
|
self.transfer_data.clean()
|
|
82
84
|
|
|
85
|
+
def _write(self, cmd, data):
|
|
86
|
+
"""
|
|
87
|
+
Send a command byte followed by a data block
|
|
88
|
+
"""
|
|
89
|
+
buffer = bytes([cmd & 0xFF, len(data) & 0xFF] + [value & 0xFF for value in data])
|
|
90
|
+
with self.device as bus_device:
|
|
91
|
+
bus_device.write(buffer)
|
|
92
|
+
time.sleep(0.003)
|
|
93
|
+
|
|
94
|
+
def _read(self):
|
|
95
|
+
"""
|
|
96
|
+
Read one byte from the I2C device
|
|
97
|
+
"""
|
|
98
|
+
data = bytearray(1)
|
|
99
|
+
with self.device as bus_device:
|
|
100
|
+
bus_device.readinto(data)
|
|
101
|
+
return data[0]
|
|
102
|
+
|
|
83
103
|
def __len__(self):
|
|
84
104
|
"""
|
|
85
105
|
Return the total number of pixels
|
|
@@ -205,11 +225,7 @@ class PixelStrip:
|
|
|
205
225
|
for i in range(6):
|
|
206
226
|
start = 32 * i
|
|
207
227
|
end = start + 32
|
|
208
|
-
self.
|
|
209
|
-
self.Address,
|
|
210
|
-
FunctionEnum.SENDALLPIXRGB0.value + i,
|
|
211
|
-
rgb[start:end]
|
|
212
|
-
)
|
|
228
|
+
self._write( FunctionEnum.SENDALLPIXRGB0.value + i, rgb[start:end])
|
|
213
229
|
|
|
214
230
|
def fill(self, r=0, g=0, b=0, w=0, first=0, end=64):
|
|
215
231
|
"""
|
|
@@ -252,7 +268,7 @@ class PixelStrip:
|
|
|
252
268
|
self.transfer_data.setFunc(FunctionEnum.SETBRIGHTNESS.value)
|
|
253
269
|
self.send(0x00)
|
|
254
270
|
|
|
255
|
-
def
|
|
271
|
+
def getNumPixels(self):
|
|
256
272
|
"""
|
|
257
273
|
Return the number of pixels in this strip
|
|
258
274
|
"""
|
|
@@ -267,7 +283,7 @@ class PixelStrip:
|
|
|
267
283
|
self.transfer_data.setFunc(FunctionEnum.GAMMA8.value)
|
|
268
284
|
self.transfer_data.setData(x)
|
|
269
285
|
self.send(0x01)
|
|
270
|
-
return self.
|
|
286
|
+
return self._read()
|
|
271
287
|
|
|
272
288
|
def getGamma32(self, x):
|
|
273
289
|
"""
|
|
@@ -278,9 +294,9 @@ class PixelStrip:
|
|
|
278
294
|
self.transfer_data.setFunc(FunctionEnum.GAMMA32.value)
|
|
279
295
|
self.transfer_data.setData(x)
|
|
280
296
|
self.send(0x01)
|
|
281
|
-
return self.
|
|
297
|
+
return self._read()
|
|
282
298
|
|
|
283
|
-
def
|
|
299
|
+
def getColorHSV(self, x):
|
|
284
300
|
"""
|
|
285
301
|
Converts an HSV color value into the device-specific RGB format.
|
|
286
302
|
|
|
@@ -289,4 +305,4 @@ class PixelStrip:
|
|
|
289
305
|
self.transfer_data.setFunc(FunctionEnum.COLORHSV.value)
|
|
290
306
|
self.transfer_data.setData(x)
|
|
291
307
|
self.send(0x01)
|
|
292
|
-
return self.
|
|
308
|
+
return self._read()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|