diff --git a/adafruit_led_animation/__init__.py b/adafruit_led_animation/__init__.py index d9247bb..05102ca 100644 --- a/adafruit_led_animation/__init__.py +++ b/adafruit_led_animation/__init__.py @@ -36,6 +36,7 @@ except (ImportError, NotImplementedError): Implementation of monotonic_ms for platforms without time.monotonic_ns """ return int(monotonic() * MS_PER_SECOND) + except (ImportError, NotImplementedError): from time import time_ns diff --git a/adafruit_led_animation/color.py b/adafruit_led_animation/color.py index 2d36ccc..1a506d1 100755 --- a/adafruit_led_animation/color.py +++ b/adafruit_led_animation/color.py @@ -27,15 +27,16 @@ Implementation Notes try: from rainbowio import colorwheel # pylint: disable=unused-import except (ImportError, ModuleNotFoundError): + def colorwheel(pos): # ref: https://github.com/adafruit/circuitpython/blob/main/shared-module/rainbowio/__init__.c pos = pos - ((pos // 256) * 256) shift1 = 0 shift2 = 0 - if (pos < 85): + if pos < 85: shift1 = 8 shift2 = 16 - elif (pos < 170): + elif pos < 170: pos -= 85 shift1 = 0 shift2 = 8 @@ -47,6 +48,7 @@ except (ImportError, ModuleNotFoundError): p = p if (p < 256) else 255 return (p << shift1) | ((255 - p) << shift2) + RED = (255, 0, 0) """Red.""" YELLOW = (255, 150, 0)