Skip to content

Commit 57dd42c

Browse files
authored
Merge pull request #8 from adafruit/rainbowio
Update examples to use rainbowio
2 parents 8f8ffb8 + 125e056 commit 57dd42c

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

README.rst

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Usage Example
5959

6060
.. code:: python
6161
62-
"""This demo connects to a magic light and has it do a color wheel."""
62+
"""This demo connects to a magic light and has it do a colorwheel."""
6363
import adafruit_ble
6464
import _bleio
6565
@@ -82,19 +82,6 @@ Usage Example
8282
# Start advertising before messing with the display so that we can connect immediately.
8383
radio = adafruit_ble.BLERadio()
8484
85-
def wheel(pos):
86-
# Input a value 0 to 255 to get a color value.
87-
# The colours are a transition r - g - b - back to r.
88-
if pos < 0 or pos > 255:
89-
return (0, 0, 0)
90-
if pos < 85:
91-
return (255 - pos * 3, pos * 3, 0)
92-
if pos < 170:
93-
pos -= 85
94-
return (0, 255 - pos * 3, pos * 3)
95-
pos -= 170
96-
return (pos * 3, 0, 255 - pos * 3)
97-
9885
active_connection, pixels = find_connection()
9986
current_notification = None
10087
app_icon_file = None
@@ -114,7 +101,7 @@ Usage Example
114101
115102
i = 0
116103
while active_connection.connected:
117-
pixels[0] = wheel(i % 256)
104+
pixels[0] = colorwheel(i % 256)
118105
i += 1
119106
120107
active_connection = None

examples/ble_magic_light_simpletest.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4-
"""This demo connects to a magic light and has it do a color wheel."""
4+
"""This demo connects to a magic light and has it do a colorwheel."""
5+
from rainbowio import colorwheel
56
import adafruit_ble
67
import _bleio
78

@@ -26,21 +27,6 @@ def find_connection():
2627
# Start advertising before messing with the display so that we can connect immediately.
2728
radio = adafruit_ble.BLERadio()
2829

29-
30-
def wheel(pos):
31-
# Input a value 0 to 255 to get a color value.
32-
# The colours are a transition r - g - b - back to r.
33-
if pos < 0 or pos > 255:
34-
return (0, 0, 0)
35-
if pos < 85:
36-
return (255 - pos * 3, pos * 3, 0)
37-
if pos < 170:
38-
pos -= 85
39-
return (0, 255 - pos * 3, pos * 3)
40-
pos -= 170
41-
return (pos * 3, 0, 255 - pos * 3)
42-
43-
4430
active_connection, pixels = find_connection()
4531
current_notification = None
4632
app_icon_file = None
@@ -60,7 +46,7 @@ def wheel(pos):
6046

6147
i = 0
6248
while active_connection.connected:
63-
pixels[0] = wheel(i % 256)
49+
pixels[0] = colorwheel(i % 256)
6450
i += 1
6551

6652
active_connection = None

0 commit comments

Comments
 (0)