File tree Expand file tree Collapse file tree 2 files changed +5
-32
lines changed Expand file tree Collapse file tree 2 files changed +5
-32
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ Usage Example
59
59
60
60
.. code :: python
61
61
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 ."""
63
63
import adafruit_ble
64
64
import _bleio
65
65
@@ -82,19 +82,6 @@ Usage Example
82
82
# Start advertising before messing with the display so that we can connect immediately.
83
83
radio = adafruit_ble.BLERadio()
84
84
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
-
98
85
active_connection, pixels = find_connection()
99
86
current_notification = None
100
87
app_icon_file = None
@@ -114,7 +101,7 @@ Usage Example
114
101
115
102
i = 0
116
103
while active_connection.connected:
117
- pixels[0 ] = wheel (i % 256 )
104
+ pixels[0 ] = colorwheel (i % 256 )
118
105
i += 1
119
106
120
107
active_connection = None
Original file line number Diff line number Diff line change 1
1
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2
2
# SPDX-License-Identifier: MIT
3
3
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
5
6
import adafruit_ble
6
7
import _bleio
7
8
@@ -26,21 +27,6 @@ def find_connection():
26
27
# Start advertising before messing with the display so that we can connect immediately.
27
28
radio = adafruit_ble .BLERadio ()
28
29
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
-
44
30
active_connection , pixels = find_connection ()
45
31
current_notification = None
46
32
app_icon_file = None
@@ -60,7 +46,7 @@ def wheel(pos):
60
46
61
47
i = 0
62
48
while active_connection .connected :
63
- pixels [0 ] = wheel (i % 256 )
49
+ pixels [0 ] = colorwheel (i % 256 )
64
50
i += 1
65
51
66
52
active_connection = None
You can’t perform that action at this time.
0 commit comments