|
17 | 17 |
|
18 | 18 | * Adafruit CircuitPython firmware for the supported boards:
|
19 | 19 | https://github.com/adafruit/circuitpython/releases
|
20 |
| -
|
21 |
| -* Adafruit's SimpleIO library: https://github.com/adafruit/Adafruit_CircuitPython_SimpleIO |
22 | 20 | """
|
23 | 21 | try:
|
24 | 22 | from typing import Union
|
|
29 | 27 | pass
|
30 | 28 |
|
31 | 29 | from pwmio import PWMOut
|
32 |
| -from simpleio import map_range |
33 | 30 |
|
34 | 31 | __version__ = "0.0.0+auto.0"
|
35 | 32 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGBLED.git"
|
@@ -149,19 +146,19 @@ def color(self, value: Union[int, tuple]):
|
149 | 146 | self._current_color = value
|
150 | 147 | if isinstance(value, tuple):
|
151 | 148 | for i in range(0, 3):
|
152 |
| - color = int(map_range(value[i], 0, 255, 0, 65535)) |
| 149 | + color = int(max(0, min(65535, value[i] * 257))) |
153 | 150 | if self._invert_pwm:
|
154 | 151 | color -= 65535
|
155 | 152 | self._rgb_led_pins[i].duty_cycle = abs(color)
|
156 | 153 | elif isinstance(value, int):
|
157 |
| - if value >> 24: |
| 154 | + if value > 0xFFFFFF: |
158 | 155 | raise ValueError("Only bits 0->23 valid for integer input")
|
159 | 156 | r = value >> 16
|
160 | 157 | g = (value >> 8) & 0xFF
|
161 | 158 | b = value & 0xFF
|
162 | 159 | rgb = [r, g, b]
|
163 | 160 | for color in range(0, 3):
|
164 |
| - rgb[color] = int(map_range(rgb[color], 0, 255, 0, 65535)) |
| 161 | + rgb[color] = max(0, min(65535, rgb[color] * 257)) |
165 | 162 | if self._invert_pwm:
|
166 | 163 | rgb[color] -= 65535
|
167 | 164 | self._rgb_led_pins[color].duty_cycle = abs(rgb[color])
|
|
0 commit comments