Skip to content

Commit 5a2ca6c

Browse files
committed
Remove dependency to simpleio
1 parent dbdff9b commit 5a2ca6c

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

adafruit_rgbled.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
* Adafruit's SimpleIO library: https://github.com/adafruit/Adafruit_CircuitPython_SimpleIO
2222
"""
2323
from pwmio import PWMOut
24-
from simpleio import map_range
2524

2625
__version__ = "0.0.0+auto.0"
2726
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGBLED.git"
@@ -137,19 +136,19 @@ def color(self, value):
137136
self._current_color = value
138137
if isinstance(value, tuple):
139138
for i in range(0, 3):
140-
color = int(map_range(value[i], 0, 255, 0, 65535))
139+
color = int(max(0, min(65535, value[i] * 257)))
141140
if self._invert_pwm:
142141
color -= 65535
143142
self._rgb_led_pins[i].duty_cycle = abs(color)
144143
elif isinstance(value, int):
145-
if value >> 24:
144+
if value > 0xFFFFFF:
146145
raise ValueError("Only bits 0->23 valid for integer input")
147146
r = value >> 16
148147
g = (value >> 8) & 0xFF
149148
b = value & 0xFF
150149
rgb = [r, g, b]
151150
for color in range(0, 3):
152-
rgb[color] = int(map_range(rgb[color], 0, 255, 0, 65535))
151+
rgb[color] = max(0, min(65535, rgb[color] * 257))
153152
if self._invert_pwm:
154153
rgb[color] -= 65535
155154
self._rgb_led_pins[color].duty_cycle = abs(rgb[color])

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
# SPDX-License-Identifier: Unlicense
44

55
Adafruit-Blinka
6-
adafruit-circuitpython-simpleio

0 commit comments

Comments
 (0)