Skip to content

Update examples to use rainbowio #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
20 changes: 3 additions & 17 deletions examples/ble_magic_light_simpletest.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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