Skip to content

Commit 5534662

Browse files
authored
Merge pull request #24 from CedarGroveStudios/master
Add support for Crickit's on-board NeoPixel
2 parents d7d57c1 + 3609d7d commit 5534662

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Usage Example
5858
This examples shows how to control all the devices supported by the library.
5959
In most cases you just need a couple of imports.
6060

61-
.. code-block :: python
61+
.. code-block:: python
6262
6363
# This is a mock example showing typical usage of the library for each kind of device.
6464
@@ -103,6 +103,11 @@ In most cases you just need a couple of imports.
103103
crickit.init_neopixel(8)
104104
crickit.neopixel.fill((100, 100, 100))
105105
106+
# Set the Crickit's on-board NeoPixel to a dim purple.
107+
crickit.onboard_pixel.brightness = 0.01
108+
crickit.onboard_pixel[0] = (255, 24, 255)
109+
# or
110+
crickit.onboard_pixel.fill((255, 24, 255))
106111
107112
Contributing
108113
============

adafruit_crickit.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
_TOUCH4 = const(7)
9494

9595
_NEOPIXEL = const(20)
96+
_SS_PIXEL = const(27)
9697

9798
#pylint: disable=too-few-public-methods
9899
class CrickitTouchIn:
@@ -164,6 +165,7 @@ def __init__(self, seesaw):
164165
# Used to find existing devices.
165166
self._devices = dict()
166167
self._neopixel = None
168+
self._onboard_pixel = None
167169

168170
@property
169171
def seesaw(self):
@@ -369,6 +371,19 @@ def init_neopixel(self, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_orde
369371
brightness=brightness, auto_write=auto_write,
370372
pixel_order=pixel_order)
371373

374+
@property
375+
def onboard_pixel(self):
376+
"""```adafruit_seesaw.neopixel`` object on the Seesaw on-board NeoPixel.
377+
Initialize on-board NeoPixel and clear upon first use.
378+
"""
379+
if not self._onboard_pixel:
380+
from adafruit_seesaw.neopixel import NeoPixel
381+
self._onboard_pixel = NeoPixel(self._seesaw, _SS_PIXEL, 1, bpp=3,
382+
brightness=1.0, auto_write=True,
383+
pixel_order=None)
384+
self._onboard_pixel.fill((0, 0, 0))
385+
return self._onboard_pixel
386+
372387
def reset(self):
373388
"""Reset the whole Crickit board."""
374389
self._seesaw.sw_reset()

0 commit comments

Comments
 (0)