From 02758607e26bedd356a0ff004d0493b1783950dd Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 28 May 2019 14:31:50 -0400 Subject: [PATCH 01/10] Import _pixelbuf/pypixelbuf variant --- README.rst | 44 ++++++++++ adafruit_dotstar.py | 205 +++++++++++++++----------------------------- 2 files changed, 115 insertions(+), 134 deletions(-) diff --git a/README.rst b/README.rst index e38ca5a..55b0913 100644 --- a/README.rst +++ b/README.rst @@ -53,6 +53,50 @@ This example demonstrates the library with the single built-in DotStar on the pixels = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1) pixels[0] = (10, 0, 0) + +This example demonstrates the library with the DotStar Feather Wing and bounces Blinka. + +`Feather M4 Express `_ and +`DotStar FeatherWing `_. + +.. code-block:: python + + import board + import adafruit_dotstar + import time + + + import adafruit_dotstar + dotstar = adafruit_dotstar.DotStar(board.D13, board.D11, 72, + pixel_order=adafruit_dotstar.BGR, + brightness=0.3, auto_write=False) + + blinka = ( + (0, 0x0f0716, 0x504069, 0x482e63, 0, 0), + (0, 0x3d1446, 0x502b74, 0x622f8c, 0, 0), + (0, 0x2e021b, 0x2e021b, 0x2e021b, 0, 0), + (0, 0, 0x2e021b, 0x2e021b, 0, 0), + (0, 0x591755, 0x912892, 0x3f205c, 0x282828, 0x301844), + (0x65206b, 0x932281, 0x6e318f, 0x6d2b7e, 0x7e2686, 0x8c2c8f), + (0x7c2d8c, 0xa21c81, 0x6b308e, 0x74257b, 0x7b2482, 0x742f8d), + (0x23051a, 0x5c0f45, 0x81227b, 0x551a5b, 0x691b5d, 0x4d0c39), + ) + offset = 0 + direction = 1 + while True: + dotstar.fill(0) + for y, row in enumerate(blinka): + for x, value in enumerate(row): + n = x * 12 + (y + offset) + dotstar[n] = row[x] + dotstar.show() + time.sleep(0.1) + offset += direction + if offset > 4 or offset < 0: + direction = -direction + offset += direction + + Contributing ============ diff --git a/adafruit_dotstar.py b/adafruit_dotstar.py index 6e1109a..6007c64 100755 --- a/adafruit_dotstar.py +++ b/adafruit_dotstar.py @@ -3,6 +3,7 @@ # Copyright (c) 2016 Damien P. George (original Neopixel object) # Copyright (c) 2017 Ladyada # Copyright (c) 2017 Scott Shawcroft for Adafruit Industries +# Copyright (c) 2019 Roy Hooper # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,27 +24,22 @@ # THE SOFTWARE. """ -`adafruit_dotstar` - DotStar strip driver -==================================================== +`adafruit_dotstar` - DotStar strip driver (for CircuitPython 4.0+ with _pixelbuf) +================================================================================= -* Author(s): Damien P. George, Limor Fried & Scott Shawcroft +* Author(s): Damien P. George, Limor Fried, Scott Shawcroft, Roy Hooper """ import busio import digitalio +try: + from _pixelbuf import PixelBuf, RGB, RBG, GRB, GBR, BRG, BGR, LRGB, LRBG, LGRB, LGBR, LBRG, LBGR +except ImportError: + from pypixelbuf import PixelBuf, RGB, RBG, GRB, GBR, BRG, BGR, LRGB, LRBG, LGRB, LGBR, LBRG, LBGR __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DotStar.git" START_HEADER_SIZE = 4 -LED_START = 0b11100000 # Three "1" bits, followed by 5 brightness bits - -# Pixel color order constants -RGB = (0, 1, 2) -RBG = (0, 2, 1) -GRB = (1, 0, 2) -GBR = (1, 2, 0) -BRG = (2, 0, 1) -BGR = (2, 1, 0) class DotStar: @@ -56,14 +52,9 @@ class DotStar: :param float brightness: Brightness of the pixels between 0.0 and 1.0 :param bool auto_write: True if the dotstars should immediately change when set. If False, `show` must be called explicitly. - :param tuple pixel_order: Set the pixel order on the strip - different - strips implement this differently. If you send red, and it looks blue - or green on the strip, modify this! It should be one of the values - above. - :param int baudrate: Desired clock rate if using hardware SPI (ignored if - using 'soft' SPI). This is only a recommendation; the actual clock - rate may be slightly different depending on what the system hardware - can provide. + :param ByteOrder pixel_order: Set the pixel order on the strip - different + strips implement this differently. If you send red, and it looks blue + or green on the strip, modify this! It should be one of the values above Example for Gemma M0: @@ -96,36 +87,43 @@ def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True, self.dpin.direction = digitalio.Direction.OUTPUT self.cpin.direction = digitalio.Direction.OUTPUT self.cpin.value = False - self._n = n + self.n = n # Supply one extra clock cycle for each two pixels in the strip. - self.end_header_size = n // 16 + end_header_size = n // 16 if n % 16 != 0: - self.end_header_size += 1 - self._buf = bytearray(n * 4 + START_HEADER_SIZE + self.end_header_size) - self.end_header_index = len(self._buf) - self.end_header_size + end_header_size += 1 + bufsize = 4 * n + START_HEADER_SIZE + end_header_size + end_header_index = bufsize - end_header_size self.pixel_order = pixel_order + + self._buf = bytearray(bufsize) + self._rawbuf = bytearray(bufsize) + # Four empty bytes to start. for i in range(START_HEADER_SIZE): - self._buf[i] = 0x00 - # Mark the beginnings of each pixel. - for i in range(START_HEADER_SIZE, self.end_header_index, 4): - self._buf[i] = 0xff + self._rawbuf[i] = 0x00 # 0xff bytes at the end. - for i in range(self.end_header_index, len(self._buf)): - self._buf[i] = 0xff - self._brightness = 1.0 - # Set auto_write to False temporarily so brightness setter does _not_ - # call show() while in __init__. - self.auto_write = False - self.brightness = brightness - self.auto_write = auto_write + for i in range(end_header_index, bufsize): + self._rawbuf[i] = 0xff + # Mark the beginnings of each pixel. + # for i in range(START_HEADER_SIZE, end_header_index, 4): + # self._rawbuf[i] = 0xff + self._buf[:] = self._rawbuf[:] + + writer = self._spi.write if self._spi else self._ds_writebytes + def write_fn(*_): + self._spi.write(self._buf) + + self._pb = PixelBuf(n, self._buf, byteorder=pixel_order, + rawbuf=self._rawbuf, write_function=write_fn, offset=START_HEADER_SIZE, + write_args=(), brightness=brightness, auto_write=auto_write, dotstar=True) + + if self.auto_write: + self.show() def deinit(self): """Blank out the DotStars and release the resources.""" - self.auto_write = False - for i in range(START_HEADER_SIZE, self.end_header_index): - if i % 4 != 0: - self._buf[i] = 0 + self.fill(0) self.show() if self._spi: self._spi.deinit() @@ -143,10 +141,16 @@ def __repr__(self): return "[" + ", ".join([str(x) for x in self]) + "]" def _set_item(self, index, value): + if isinstance(index, slice): + start, stop, step = index.indices(self.n) + self._pb[start:stop:step] = value + self._pb[index] = value + + def __setitem__(self, index, value): """ value can be one of three things: a (r,g,b) list/tuple - a (r,g,b, brightness) list/tuple + a (r,g,b, brightness) list/tuple (if bpp=4, pixel_order=LBGR) a single, longer int that contains RGB values, like 0xFFFFFF brightness, if specified should be a float 0-1 @@ -158,85 +162,42 @@ def _set_item(self, index, value): slower clock than the rest of the LEDs. This can cause problems in Persistence of Vision Applications """ - - offset = index * 4 + START_HEADER_SIZE - rgb = value - if isinstance(value, int): - rgb = (value >> 16, (value >> 8) & 0xff, value & 0xff) - - if len(rgb) == 4: - brightness = value[3] - # Ignore value[3] below. - else: - brightness = 1 - - # LED startframe is three "1" bits, followed by 5 brightness bits - # then 8 bits for each of R, G, and B. The order of those 3 are configurable and - # vary based on hardware - # same as math.ceil(brightness * 31) & 0b00011111 - # Idea from https://www.codeproject.com/Tips/700780/Fast-floor-ceiling-functions - brightness_byte = 32 - int(32 - brightness * 31) & 0b00011111 - self._buf[offset] = brightness_byte | LED_START - self._buf[offset + 1] = rgb[self.pixel_order[0]] - self._buf[offset + 2] = rgb[self.pixel_order[1]] - self._buf[offset + 3] = rgb[self.pixel_order[2]] - - def __setitem__(self, index, val): if isinstance(index, slice): - start, stop, step = index.indices(self._n) - length = stop - start - if step != 0: - # same as math.ceil(length / step) - # Idea from https://fizzbuzzer.com/implement-a-ceil-function/ - length = (length + step - 1) // step - if len(val) != length: - raise ValueError("Slice and input sequence size do not match.") - for val_i, in_i in enumerate(range(start, stop, step)): - self._set_item(in_i, val[val_i]) - else: - self._set_item(index, val) - - if self.auto_write: - self.show() + start, stop, step = index.indices(self.n) + self._pb[start:stop:step] = value + self._pb[index] = value def __getitem__(self, index): if isinstance(index, slice): - out = [] - for in_i in range(*index.indices(self._n)): - out.append( - tuple(self._buf[in_i * 4 + (3 - i) + START_HEADER_SIZE] for i in range(3))) - return out - if index < 0: - index += len(self) - if index >= self._n or index < 0: - raise IndexError - offset = index * 4 - return tuple(self._buf[offset + (3 - i) + START_HEADER_SIZE] - for i in range(3)) - - def __len__(self): - return self._n + start, stop, step = index.indices(self.n) + return self._pb[start:stop:step] + return self._pb[index] @property def brightness(self): - """Overall brightness of the pixel""" - return self._brightness - + return self._pb.brightness + @brightness.setter def brightness(self, brightness): - self._brightness = min(max(brightness, 0.0), 1.0) - if self.auto_write: - self.show() + self._pb.brightness = brightness + + @property + def auto_write(self): + return self._pb.auto_write + + @auto_write.setter + def auto_write(self, auto_write): + self._pb.auto_write = auto_write + + def show(self): + self._pb.show() + + def __len__(self): + return self.n def fill(self, color): """Colors all pixels the given ***color***.""" - auto_write = self.auto_write - self.auto_write = False - for i in range(self._n): - self[i] = color - if auto_write: - self.show() - self.auto_write = auto_write + self._pb[0:self.n] = (color, ) * self.n def _ds_writebytes(self, buf): for b in buf: @@ -245,28 +206,4 @@ def _ds_writebytes(self, buf): self.dpin.value = (b & 0x80) self.cpin.value = False b = b << 1 - - def show(self): - """Shows the new colors on the pixels themselves if they haven't already - been autowritten. - - The colors may or may not be showing after this function returns because - it may be done asynchronously.""" - # Create a second output buffer if we need to compute brightness - buf = self._buf - if self.brightness < 1.0: - buf = bytearray(self._buf) - # Four empty bytes to start. - for i in range(START_HEADER_SIZE): - buf[i] = 0x00 - for i in range(START_HEADER_SIZE, self.end_header_index): - buf[i] = self._buf[i] if i % 4 == 0 else int(self._buf[i] * self._brightness) - # Four 0xff bytes at the end. - for i in range(self.end_header_index, len(buf)): - buf[i] = 0xff - - if self._spi: - self._spi.write(buf) - else: - self._ds_writebytes(buf) - self.cpin.value = False + self.cpin.value = False From 198e70d33d51a6ece368ca691b209330f8a9f63c Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 3 Oct 2019 21:01:46 -0400 Subject: [PATCH 02/10] Fix import for new _pixelbuf api --- adafruit_dotstar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_dotstar.py b/adafruit_dotstar.py index 6007c64..3daad0c 100755 --- a/adafruit_dotstar.py +++ b/adafruit_dotstar.py @@ -32,7 +32,7 @@ import busio import digitalio try: - from _pixelbuf import PixelBuf, RGB, RBG, GRB, GBR, BRG, BGR, LRGB, LRBG, LGRB, LGBR, LBRG, LBGR + from _pixelbuf import PixelBuf, RGBD as RGB, RBGD as RBG, GRBD as GRB, GBRD as GBR, BRGD as BRG, BGRD as BGR except ImportError: from pypixelbuf import PixelBuf, RGB, RBG, GRB, GBR, BRG, BGR, LRGB, LRBG, LGRB, LGBR, LBRG, LBGR @@ -116,7 +116,7 @@ def write_fn(*_): self._pb = PixelBuf(n, self._buf, byteorder=pixel_order, rawbuf=self._rawbuf, write_function=write_fn, offset=START_HEADER_SIZE, - write_args=(), brightness=brightness, auto_write=auto_write, dotstar=True) + write_args=(), brightness=brightness, auto_write=auto_write) if self.auto_write: self.show() From dd29815841badcffe1107de191e5efd59bd47de0 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 29 Nov 2019 20:00:30 -0500 Subject: [PATCH 03/10] subclass from Pixelbuf and add changes from master --- adafruit_dotstar.py | 124 ++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 86 deletions(-) diff --git a/adafruit_dotstar.py b/adafruit_dotstar.py index 24777ef..aa58e13 100755 --- a/adafruit_dotstar.py +++ b/adafruit_dotstar.py @@ -24,25 +24,33 @@ # THE SOFTWARE. """ -`adafruit_dotstar` - DotStar strip driver (for CircuitPython 4.0+ with _pixelbuf) +`adafruit_dotstar` - DotStar strip driver (for CircuitPython 5.0+ with _pixelbuf) ================================================================================= -* Author(s): Damien P. George, Limor Fried, Scott Shawcroft, Roy Hooper +* Author(s): Damien P. George, Limor Fried, Scott Shawcroft & Roy Hooper """ import busio import digitalio try: - from _pixelbuf import PixelBuf, RGBD as RGB, RBGD as RBG, GRBD as GRB, GBRD as GBR, BRGD as BRG, BGRD as BGR + from _pixelbuf import PixelBuf except ImportError: - from pypixelbuf import PixelBuf, RGB, RBG, GRB, GBR, BRG, BGR, LRGB, LRBG, LGRB, LGBR, LBRG, LBGR + from pypixelbuf import PixelBuf __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DotStar.git" START_HEADER_SIZE = 4 +RBG = 'PRBG' +RGB = 'PRGB' +GRB = 'PGRB' +GBR = 'PGBR' +BRG = 'PBRG' +BGR = 'PBGR' +BGR = 'PBGR' -class DotStar: + +class DotStar(PixelBuf): """ A sequence of dotstars. @@ -52,10 +60,13 @@ class DotStar: :param float brightness: Brightness of the pixels between 0.0 and 1.0 :param bool auto_write: True if the dotstars should immediately change when set. If False, `show` must be called explicitly. - :param ByteOrder pixel_order: Set the pixel order on the strip - different + :param str pixel_order: Set the pixel order on the strip - different strips implement this differently. If you send red, and it looks blue - or green on the strip, modify this! It should be one of the values above - + or green on the strip, modify this! It should be one of the values above. + :param int baudrate: Desired clock rate if using hardware SPI (ignored if + using 'soft' SPI). This is only a recommendation; the actual clock + rate may be slightly different depending on what the system hardware + can provide. Example for Gemma M0: @@ -88,6 +99,7 @@ def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True, self.cpin.direction = digitalio.Direction.OUTPUT self.cpin.value = False self.n = n + # Supply one extra clock cycle for each two pixels in the strip. end_header_size = n // 16 if n % 16 != 0: @@ -106,20 +118,28 @@ def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True, for i in range(end_header_index, bufsize): self._rawbuf[i] = 0xff # Mark the beginnings of each pixel. - # for i in range(START_HEADER_SIZE, end_header_index, 4): - # self._rawbuf[i] = 0xff + for i in range(START_HEADER_SIZE, end_header_index, 4): + self._rawbuf[i] = 0xff self._buf[:] = self._rawbuf[:] - writer = self._spi.write if self._spi else self._ds_writebytes - def write_fn(*_): - self._spi.write(self._buf) + super(DotStar, self).__init__(n, self._buf, byteorder=pixel_order, + rawbuf=self._rawbuf, offset=START_HEADER_SIZE, + brightness=brightness, auto_write=auto_write) - self._pb = PixelBuf(n, self._buf, byteorder=pixel_order, - rawbuf=self._rawbuf, write_function=write_fn, offset=START_HEADER_SIZE, - write_args=(), brightness=brightness, auto_write=auto_write) + def show(self): + if self._spi: + self._spi.write(self._buf) + else: + self.ds_writebytes() - if self.auto_write: - self.show() + def _ds_writebytes(self): + for b in self.buf: + for _ in range(8): + self.dpin.value = (b & 0x80) + self.cpin.value = True + self.cpin.value = False + b = b << 1 + self.cpin.value = False def deinit(self): """Blank out the DotStars and release the resources.""" @@ -139,71 +159,3 @@ def __exit__(self, exception_type, exception_value, traceback): def __repr__(self): return "[" + ", ".join([str(x) for x in self]) + "]" - - def _set_item(self, index, value): - if isinstance(index, slice): - start, stop, step = index.indices(self.n) - self._pb[start:stop:step] = value - self._pb[index] = value - - def __setitem__(self, index, value): - """ - value can be one of three things: - a (r,g,b) list/tuple - a (r,g,b, brightness) list/tuple (if bpp=4, pixel_order=LBGR) - a single, longer int that contains RGB values, like 0xFFFFFF - brightness, if specified should be a float 0-1 - - Set a pixel value. You can set per-pixel brightness here, if it's not passed it - will use the max value for pixel brightness value, which is a good default. - - Important notes about the per-pixel brightness - it's accomplished by - PWMing the entire output of the LED, and that PWM is at a much - slower clock than the rest of the LEDs. This can cause problems in - Persistence of Vision Applications - """ - if isinstance(index, slice): - start, stop, step = index.indices(self.n) - self._pb[start:stop:step] = value - self._pb[index] = value - - def __getitem__(self, index): - if isinstance(index, slice): - start, stop, step = index.indices(self.n) - return self._pb[start:stop:step] - return self._pb[index] - - @property - def brightness(self): - return self._pb.brightness - - @brightness.setter - def brightness(self, brightness): - self._pb.brightness = brightness - - @property - def auto_write(self): - return self._pb.auto_write - - @auto_write.setter - def auto_write(self, auto_write): - self._pb.auto_write = auto_write - - def show(self): - self._pb.show() - - def __len__(self): - return self.n - - def fill(self, color): - """Colors all pixels the given ***color***.""" - self._pb[0:self.n] = (color, ) * self.n - - def _ds_writebytes(self, buf): - for b in buf: - for _ in range(8): - self.dpin.value = (b & 0x80) - self.cpin.value = True - self.cpin.value = False - b = b << 1 - self.cpin.value = False From 84f138f99d37d149be3c0d43b3b8dd8bfc7abd44 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 30 Nov 2019 12:23:28 -0500 Subject: [PATCH 04/10] fix docstring --- adafruit_dotstar.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adafruit_dotstar.py b/adafruit_dotstar.py index aa58e13..0034bea 100755 --- a/adafruit_dotstar.py +++ b/adafruit_dotstar.py @@ -127,6 +127,14 @@ def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True, brightness=brightness, auto_write=auto_write) def show(self): + """Shows the new colors on the pixels themselves if they haven't already + been autowritten. + + The colors may or may not be showing after this method returns because + it may be done asynchronously. + + This method is called automatically if auto_write is set to True. + """ if self._spi: self._spi.write(self._buf) else: From 99d89ae70cb122a0f590546dd18c682d3ef5d2b6 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 30 Nov 2019 19:34:46 -0500 Subject: [PATCH 05/10] update pylintrc from cookiecutter --- .pylintrc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.pylintrc b/.pylintrc index 88388a6..039eaec 100644 --- a/.pylintrc +++ b/.pylintrc @@ -18,6 +18,7 @@ ignore-patterns= #init-hook= # Use multiple processes to speed up Pylint. +# jobs=1 jobs=2 # List of plugins (as comma separated values of python modules names) to load, @@ -50,6 +51,7 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" +# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error # Enable the message, report, category or checker with the given id(s). You can @@ -117,7 +119,8 @@ spelling-store-unknown-words=no [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO +# notes=FIXME,XXX,TODO +notes=FIXME,XXX [TYPECHECK] @@ -200,6 +203,7 @@ redefining-builtins-modules=six.moves,future.builtins [FORMAT] # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +# expected-line-ending-format= expected-line-ending-format=LF # Regexp for a line that is allowed to be longer than the limit. @@ -272,9 +276,11 @@ class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ # Naming hint for class names +# class-name-hint=[A-Z_][a-zA-Z0-9]+$ class-name-hint=[A-Z_][a-zA-Z0-9_]+$ # Regular expression matching correct class names +# class-rgx=[A-Z_][a-zA-Z0-9]+$ class-rgx=[A-Z_][a-zA-Z0-9_]+$ # Naming hint for constant names @@ -294,7 +300,8 @@ function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Good variable names which should always be accepted, separated by a comma -good-names=r,g,b,i,j,k,n,ex,Run,_ +# good-names=i,j,k,ex,Run,_ +good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ # Include a hint for the correct naming format with invalid-name include-naming-hint=no @@ -391,6 +398,7 @@ valid-metaclass-classmethod-first-arg=mcs max-args=5 # Maximum number of attributes for a class (see R0902). +# max-attributes=7 max-attributes=11 # Maximum number of boolean expressions in a if statement @@ -415,7 +423,7 @@ max-returns=6 max-statements=50 # Minimum number of public methods for a class (see R0903). -min-public-methods=2 +min-public-methods=1 [EXCEPTIONS] From ba06384b47d34d397bebb31a9224f31a09eb1285 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 30 Nov 2019 19:40:45 -0500 Subject: [PATCH 06/10] make sphinx happy about pypixelbuf not existing yet --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 81225e3..e539d9b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,7 +15,7 @@ 'sphinx.ext.viewcode', ] -# autodoc_mock_imports = ["digitalio", "busio"] +autodoc_mock_imports = ["pypixelbuf"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None), 'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} From 0509ac9cc9a9d3471166345293b502095546265b Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 17:31:41 -0500 Subject: [PATCH 07/10] use the native pixelbuf fill helper --- adafruit_dotstar.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/adafruit_dotstar.py b/adafruit_dotstar.py index 0034bea..48f0643 100755 --- a/adafruit_dotstar.py +++ b/adafruit_dotstar.py @@ -32,9 +32,9 @@ import busio import digitalio try: - from _pixelbuf import PixelBuf + import _pixelbuf except ImportError: - from pypixelbuf import PixelBuf + import pypixelbuf as _pixelbuf __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DotStar.git" @@ -50,7 +50,7 @@ BGR = 'PBGR' -class DotStar(PixelBuf): +class DotStar(_pixelbuf.PixelBuf): """ A sequence of dotstars. @@ -167,3 +167,7 @@ def __exit__(self, exception_type, exception_value, traceback): def __repr__(self): return "[" + ", ".join([str(x) for x in self]) + "]" + + def fill(self, color): + """Colors all pixels the given ***color***.""" + _pixelbuf.fill(self, color) From 49f57d3cdfbc99aadac10bdcee8a6f8e8337f864 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 1 Jan 2020 20:15:12 -0500 Subject: [PATCH 08/10] fix import - adafruit_pypixelbuf --- adafruit_dotstar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_dotstar.py b/adafruit_dotstar.py index 48f0643..fe36046 100755 --- a/adafruit_dotstar.py +++ b/adafruit_dotstar.py @@ -34,7 +34,7 @@ try: import _pixelbuf except ImportError: - import pypixelbuf as _pixelbuf + import adafruit_pypixelbuf as _pixelbuf __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DotStar.git" From 010e691868d7306c07d3097ebeee18c0bf0a6b70 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 7 Jan 2020 19:54:09 -0500 Subject: [PATCH 09/10] add adafruit-pypixelbuf to deps --- requirements.txt | 1 + setup.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3031961..3c95591 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Adafruit-Blinka adafruit-circuitpython-busdevice +adafruit-circuitpython-pypixelbuf diff --git a/setup.py b/setup.py index a3f6e94..d4a2fec 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,8 @@ author='Adafruit Industries', author_email='circuitpython@adafruit.com', - install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'], + install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice', + 'adafruit-circuitpython-pypixelbuf'], # Choose your license license='MIT', From a9c8fbbd8f5c1c499962ffe34865554186c2cde4 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Tue, 7 Jan 2020 20:03:48 -0500 Subject: [PATCH 10/10] copy pylintrc from master --- .pylintrc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.pylintrc b/.pylintrc index 039eaec..88388a6 100644 --- a/.pylintrc +++ b/.pylintrc @@ -18,7 +18,6 @@ ignore-patterns= #init-hook= # Use multiple processes to speed up Pylint. -# jobs=1 jobs=2 # List of plugins (as comma separated values of python modules names) to load, @@ -51,7 +50,6 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error # Enable the message, report, category or checker with the given id(s). You can @@ -119,8 +117,7 @@ spelling-store-unknown-words=no [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. -# notes=FIXME,XXX,TODO -notes=FIXME,XXX +notes=FIXME,XXX,TODO [TYPECHECK] @@ -203,7 +200,6 @@ redefining-builtins-modules=six.moves,future.builtins [FORMAT] # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -# expected-line-ending-format= expected-line-ending-format=LF # Regexp for a line that is allowed to be longer than the limit. @@ -276,11 +272,9 @@ class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ # Naming hint for class names -# class-name-hint=[A-Z_][a-zA-Z0-9]+$ class-name-hint=[A-Z_][a-zA-Z0-9_]+$ # Regular expression matching correct class names -# class-rgx=[A-Z_][a-zA-Z0-9]+$ class-rgx=[A-Z_][a-zA-Z0-9_]+$ # Naming hint for constant names @@ -300,8 +294,7 @@ function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Good variable names which should always be accepted, separated by a comma -# good-names=i,j,k,ex,Run,_ -good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ +good-names=r,g,b,i,j,k,n,ex,Run,_ # Include a hint for the correct naming format with invalid-name include-naming-hint=no @@ -398,7 +391,6 @@ valid-metaclass-classmethod-first-arg=mcs max-args=5 # Maximum number of attributes for a class (see R0902). -# max-attributes=7 max-attributes=11 # Maximum number of boolean expressions in a if statement @@ -423,7 +415,7 @@ max-returns=6 max-statements=50 # Minimum number of public methods for a class (see R0903). -min-public-methods=1 +min-public-methods=2 [EXCEPTIONS]