From 125e056e7e2a58698782e29830ee97a7a1da38c7 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 23 Sep 2021 14:30:43 -0400 Subject: [PATCH] Update examples to use rainbowio --- README.rst | 17 ++--------------- examples/ble_magic_light_simpletest.py | 20 +++----------------- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/README.rst b/README.rst index 97956da..e6b2a77 100644 --- a/README.rst +++ b/README.rst @@ -59,7 +59,7 @@ Usage Example .. code:: python - """This demo connects to a magic light and has it do a color wheel.""" + """This demo connects to a magic light and has it do a colorwheel.""" import adafruit_ble import _bleio @@ -82,19 +82,6 @@ Usage Example # Start advertising before messing with the display so that we can connect immediately. radio = adafruit_ble.BLERadio() - def wheel(pos): - # Input a value 0 to 255 to get a color value. - # The colours are a transition r - g - b - back to r. - if pos < 0 or pos > 255: - return (0, 0, 0) - if pos < 85: - return (255 - pos * 3, pos * 3, 0) - if pos < 170: - pos -= 85 - return (0, 255 - pos * 3, pos * 3) - pos -= 170 - return (pos * 3, 0, 255 - pos * 3) - active_connection, pixels = find_connection() current_notification = None app_icon_file = None @@ -114,7 +101,7 @@ Usage Example i = 0 while active_connection.connected: - pixels[0] = wheel(i % 256) + pixels[0] = colorwheel(i % 256) i += 1 active_connection = None diff --git a/examples/ble_magic_light_simpletest.py b/examples/ble_magic_light_simpletest.py index 40515b6..b227d6f 100644 --- a/examples/ble_magic_light_simpletest.py +++ b/examples/ble_magic_light_simpletest.py @@ -1,7 +1,8 @@ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT -"""This demo connects to a magic light and has it do a color wheel.""" +"""This demo connects to a magic light and has it do a colorwheel.""" +from rainbowio import colorwheel import adafruit_ble import _bleio @@ -26,21 +27,6 @@ def find_connection(): # Start advertising before messing with the display so that we can connect immediately. radio = adafruit_ble.BLERadio() - -def wheel(pos): - # Input a value 0 to 255 to get a color value. - # The colours are a transition r - g - b - back to r. - if pos < 0 or pos > 255: - return (0, 0, 0) - if pos < 85: - return (255 - pos * 3, pos * 3, 0) - if pos < 170: - pos -= 85 - return (0, 255 - pos * 3, pos * 3) - pos -= 170 - return (pos * 3, 0, 255 - pos * 3) - - active_connection, pixels = find_connection() current_notification = None app_icon_file = None @@ -60,7 +46,7 @@ def wheel(pos): i = 0 while active_connection.connected: - pixels[0] = wheel(i % 256) + pixels[0] = colorwheel(i % 256) i += 1 active_connection = None