-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NeoPixel emulation option for true color terminals, default to 20…
…0 pixels
- Loading branch information
1 parent
a36c9bf
commit c364bcb
Showing
6 changed files
with
98 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ mqtt: | |
max_reconnect_delay: 60 | ||
|
||
driver: | ||
num_pixels: 50 | ||
virtual: false | ||
num_pixels: 200 | ||
pin: "D18" | ||
order: "RGB" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import tcolorpy | ||
import adafruit_pixelbuf | ||
|
||
__version__ = "0.1.0" | ||
|
||
RGB = "RGB" | ||
GRB = "GRB" | ||
RGBW = "RGBW" | ||
GRBW = "GRBW" | ||
|
||
|
||
class NeoPixel(adafruit_pixelbuf.PixelBuf): | ||
"""NeoPixel Emulator | ||
Semi-compatible with the Adafruit CircuitPython Neopixel Module | ||
""" | ||
|
||
def __init__( | ||
self, | ||
pin, | ||
n: int, | ||
*, | ||
bpp: int = 3, | ||
brightness: float = 1.0, | ||
auto_write: bool = True, | ||
pixel_order: str = "RGB" | ||
): | ||
super().__init__(n, byteorder=pixel_order, brightness=brightness, auto_write=auto_write) | ||
|
||
def deinit(self) -> None: | ||
pass | ||
|
||
def __enter__(self): | ||
return self | ||
|
||
def __repr__(self): | ||
return "[" + ", ".join([str(x) for x in self]) + "]" | ||
|
||
@property | ||
def n(self) -> int: | ||
""" Get the number of pixels """ | ||
return len(self) | ||
|
||
def write(self) -> None: | ||
""" Same as .show(), deprecated """ | ||
self.show() | ||
|
||
def _transmit(self, _: bytearray) -> None: | ||
termout = "" | ||
for pixel in self: | ||
termout += tcolorpy.tcolor("█", '#{:02x}{:02x}{:02x}'.format(*[int(i * self.brightness) for i in pixel])) | ||
print(termout) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
adafruit-circuitpython-neopixel~=6.3.11 | ||
paho-mqtt~=2.0.0 | ||
pyyaml~=6.0.1 | ||
paho-mqtt<2.0.0 | ||
pyyaml~=6.0.1 | ||
tcolorpy~=0.1.6 |