Skip to content

Commit 8770cdd

Browse files
authored
Merge pull request #23 from adafruit/REUSE
Ran pre-commit, added licenses
2 parents be3ffb1 + 4d78570 commit 8770cdd

21 files changed

+500
-120
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
15
*.mpy
26
.idea
37
__pycache__
@@ -8,4 +12,4 @@ bundles
812
*.DS_Store
913
.eggs
1014
dist
11-
**/*.egg-info
15+
**/*.egg-info

.pylintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
15
[MASTER]
26

37
# A comma-separated list of package or module names from where C extensions may

.readthedocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
15
python:
26
version: 3
37
requirements_file: requirements.txt

CODE_OF_CONDUCT.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2014 Coraline Ada Ehmke
3+
SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
4+
SPDX-License-Identifier: CC-BY-4.0
5+
-->
6+
17
# Adafruit Community Code of Conduct
28

39
## Our Pledge
@@ -43,7 +49,7 @@ Examples of unacceptable behavior by participants include:
4349

4450
The goal of the standards and moderation guidelines outlined here is to build
4551
and maintain a respectful community. We ask that you don’t just aim to be
46-
"technically unimpeachable", but rather try to be your best self.
52+
"technically unimpeachable", but rather try to be your best self.
4753

4854
We value many things beyond technical expertise, including collaboration and
4955
supporting others within our community. Providing a positive experience for
@@ -74,9 +80,9 @@ You may report in the following ways:
7480
In any situation, you may send an email to <[email protected]>.
7581

7682
On the Adafruit Discord, you may send an open message from any channel
77-
to all Community Moderators by tagging @community moderators. You may
78-
also send an open message from any channel, or a direct message to
79-
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
83+
to all Community Moderators by tagging @community moderators. You may
84+
also send an open message from any channel, or a direct message to
85+
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
8086
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
8187

8288
Email and direct message reports will be kept confidential.

LICENSES/CC-BY-4.0.txt

Lines changed: 324 additions & 0 deletions
Large diffs are not rendered by default.

LICENSES/MIT.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
MIT License Copyright (c) <year> <copyright holders>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice (including the next
11+
paragraph) shall be included in all copies or substantial portions of the
12+
Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
17+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19+
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

LICENSES/Unlicense.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or distribute
4+
this software, either in source code form or as a compiled binary, for any
5+
purpose, commercial or non-commercial, and by any means.
6+
7+
In jurisdictions that recognize copyright laws, the author or authors of this
8+
software dedicate any and all copyright interest in the software to the public
9+
domain. We make this dedication for the benefit of the public at large and
10+
to the detriment of our heirs and successors. We intend this dedication to
11+
be an overt act of relinquishment in perpetuity of all present and future
12+
rights to this software under copyright law.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
17+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
19+
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information,
20+
please refer to <https://unlicense.org/>

README.rst.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
3+
SPDX-License-Identifier: MIT

adafruit_fancyled/adafruit_fancyled.py

Lines changed: 70 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
# The MIT License (MIT)
1+
# SPDX-FileCopyrightText: 2017 PaintYourDragon for Adafruit Industries
22
#
3-
# Copyright (c) 2017 PaintYourDragon for Adafruit Industries
4-
#
5-
# Permission is hereby granted, free of charge, to any person obtaining a copy
6-
# of this software and associated documentation files (the "Software"), to deal
7-
# in the Software without restriction, including without limitation the rights
8-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
# copies of the Software, and to permit persons to whom the Software is
10-
# furnished to do so, subject to the following conditions:
11-
#
12-
# The above copyright notice and this permission notice shall be included in
13-
# all copies or substantial portions of the Software.
14-
#
15-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
# THE SOFTWARE.
3+
# SPDX-License-Identifier: MIT
4+
225
"""
236
`adafruit_fancyled.adafruit_fancyled`
247
====================================================
@@ -48,19 +31,19 @@
4831
class CRGB:
4932
"""Color stored in Red, Green, Blue color space.
5033
51-
One of two ways: separate red, gren, blue values (either as integers
52-
(0 to 255 range) or floats (0.0 to 1.0 range), either type is
53-
'clamped' to valid range and stored internally in the normalized
54-
(float) format), OR can accept a CHSV color as input, which will be
55-
converted and stored in RGB format.
34+
One of two ways: separate red, gren, blue values (either as integers
35+
(0 to 255 range) or floats (0.0 to 1.0 range), either type is
36+
'clamped' to valid range and stored internally in the normalized
37+
(float) format), OR can accept a CHSV color as input, which will be
38+
converted and stored in RGB format.
5639
57-
Following statements are equivalent - all return red:
40+
Following statements are equivalent - all return red:
5841
59-
.. code-block:: python
42+
.. code-block:: python
6043
61-
c = CRGB(255, 0, 0)
62-
c = CRGB(1.0, 0.0, 0.0)
63-
c = CRGB(CHSV(0.0, 1.0, 1.0))
44+
c = CRGB(255, 0, 0)
45+
c = CRGB(1.0, 0.0, 0.0)
46+
c = CRGB(CHSV(0.0, 1.0, 1.0))
6447
"""
6548

6649
def __init__(self, red, green=0.0, blue=0.0):
@@ -131,7 +114,7 @@ def __getitem__(self, key):
131114
def pack(self):
132115
"""'Pack' a `CRGB` color into a 24-bit RGB integer.
133116
134-
:returns: 24-bit integer a la ``0x00RRGGBB``.
117+
:returns: 24-bit integer a la ``0x00RRGGBB``.
135118
"""
136119

137120
return (
@@ -144,21 +127,21 @@ def pack(self):
144127
class CHSV:
145128
"""Color stored in Hue, Saturation, Value color space.
146129
147-
Accepts hue as float (any range) or integer (0-256 -> 0.0-1.0) with
148-
no clamping performed (hue can 'wrap around'), saturation and value
149-
as float (0.0 to 1.0) or integer (0 to 255), both are clamped and
150-
stored internally in the normalized (float) format. Latter two are
151-
optional, can pass juse hue and saturation/value will default to 1.0.
130+
Accepts hue as float (any range) or integer (0-256 -> 0.0-1.0) with
131+
no clamping performed (hue can 'wrap around'), saturation and value
132+
as float (0.0 to 1.0) or integer (0 to 255), both are clamped and
133+
stored internally in the normalized (float) format. Latter two are
134+
optional, can pass juse hue and saturation/value will default to 1.0.
152135
153-
Unlike `CRGB` (which can take a `CHSV` as input), there's currently
154-
no equivalent RGB-to-HSV conversion, mostly because it's a bit like
155-
trying to reverse a hash...there may be multiple HSV solutions for a
156-
given RGB input.
136+
Unlike `CRGB` (which can take a `CHSV` as input), there's currently
137+
no equivalent RGB-to-HSV conversion, mostly because it's a bit like
138+
trying to reverse a hash...there may be multiple HSV solutions for a
139+
given RGB input.
157140
158-
This might be OK as long as conversion precedence is documented,
159-
but otherwise (and maybe still) could cause confusion as certain
160-
HSV->RGB->HSV translations won't have the same input and output.
161-
"""
141+
This might be OK as long as conversion precedence is documented,
142+
but otherwise (and maybe still) could cause confusion as certain
143+
HSV->RGB->HSV translations won't have the same input and output.
144+
"""
162145

163146
def __init__(self, h, s=1.0, v=1.0):
164147
if isinstance(h, float):
@@ -197,28 +180,27 @@ def __getitem__(self, key):
197180
def pack(self):
198181
"""'Pack' a `CHSV` color into a 24-bit RGB integer.
199182
200-
:returns: 24-bit integer a la ``0x00RRGGBB``.
183+
:returns: 24-bit integer a la ``0x00RRGGBB``.
201184
"""
202185

203186
# Convert CHSV to CRGB, return packed result
204187
return CRGB(self).pack()
205188

206189

207190
def clamp(val, lower, upper):
208-
"""Constrain value within a numeric range (inclusive).
209-
"""
191+
"""Constrain value within a numeric range (inclusive)."""
210192
return max(lower, min(val, upper))
211193

212194

213195
def normalize(val, inplace=False):
214196
"""Convert 8-bit (0 to 255) value to normalized (0.0 to 1.0) value.
215197
216-
Accepts integer, 0 to 255 range (input is clamped) or a list or tuple
217-
of integers. In list case, 'inplace' can be used to control whether
218-
the original list is modified (True) or a new list is generated and
219-
returned (False).
198+
Accepts integer, 0 to 255 range (input is clamped) or a list or tuple
199+
of integers. In list case, 'inplace' can be used to control whether
200+
the original list is modified (True) or a new list is generated and
201+
returned (False).
220202
221-
Returns float, 0.0 to 1.0 range, or list of floats (or None if inplace).
203+
Returns float, 0.0 to 1.0 range, or list of floats (or None if inplace).
222204
"""
223205

224206
if isinstance(val, int):
@@ -239,12 +221,12 @@ def normalize(val, inplace=False):
239221
def denormalize(val, inplace=False):
240222
"""Convert normalized (0.0 to 1.0) value to 8-bit (0 to 255) value
241223
242-
Accepts float, 0.0 to 1.0 range or a list or tuple of floats. In
243-
list case, 'inplace' can be used to control whether the original list
244-
is modified (True) or a new list is generated and returned (False).
224+
Accepts float, 0.0 to 1.0 range or a list or tuple of floats. In
225+
list case, 'inplace' can be used to control whether the original list
226+
is modified (True) or a new list is generated and returned (False).
245227
246-
Returns integer, 0 to 255 range, or list of integers (or None if
247-
inplace).
228+
Returns integer, 0 to 255 range, or list of integers (or None if
229+
inplace).
248230
"""
249231

250232
# 'Denormalizing' math varies slightly from normalize(). This is on
@@ -269,9 +251,9 @@ def denormalize(val, inplace=False):
269251
def unpack(val):
270252
"""'Unpack' a 24-bit color into a `CRGB` instance.
271253
272-
:param int val: 24-bit integer a la ``0x00RRGGBB``.
273-
:returns: CRGB color.
274-
:rtype: CRGB
254+
:param int val: 24-bit integer a la ``0x00RRGGBB``.
255+
:returns: CRGB color.
256+
:rtype: CRGB
275257
"""
276258

277259
# See notes in normalize() for math explanation. Large constants here
@@ -286,10 +268,10 @@ def unpack(val):
286268

287269
def mix(color1, color2, weight2=0.5):
288270
"""Blend between two colors using given ratio. Accepts two colors (each
289-
may be `CRGB`, `CHSV` or packed integer), and weighting (0.0 to 1.0)
290-
of second color.
271+
may be `CRGB`, `CHSV` or packed integer), and weighting (0.0 to 1.0)
272+
of second color.
291273
292-
:returns: `CRGB` color in most cases, `CHSV` if both inputs are `CHSV`.
274+
:returns: `CRGB` color in most cases, `CHSV` if both inputs are `CHSV`.
293275
"""
294276

295277
clamp(weight2, 0.0, 1.0)
@@ -337,31 +319,31 @@ def mix(color1, color2, weight2=0.5):
337319

338320
def gamma_adjust(val, gamma_value=None, brightness=1.0, inplace=False):
339321
"""Provides gamma adjustment for single values, `CRGB` and `CHSV` types
340-
and lists of any of these.
341-
342-
Works in one of three ways:
343-
1. Accepts a single normalized level (0.0 to 1.0) and optional
344-
gamma-adjustment factor (float usu. > 1.0, default if
345-
unspecified is GFACTOR) and brightness (float 0.0 to 1.0,
346-
default is 1.0). Returns a single normalized gamma-corrected
347-
brightness level (0.0 to 1.0).
348-
2. Accepts a single `CRGB` or `CHSV` type, optional single gamma
349-
factor OR a (R,G,B) gamma tuple (3 values usu. > 1.0), optional
350-
single brightness factor OR a (R,G,B) brightness tuple. The
351-
input tuples are RGB even when a `CHSV` color is passed. Returns
352-
a normalized gamma-corrected `CRGB` type (NOT `CHSV`!).
353-
3. Accept a list or tuple of normalized levels, `CRGB` or `CHSV`
354-
types (and optional gamma and brightness levels or tuples
355-
applied to all). Returns a list of gamma-corrected values or
356-
`CRGB` types (NOT `CHSV`!).
357-
358-
In cases 2 and 3, if the input is a list (NOT a tuple!), the 'inplace'
359-
flag determines whether a new tuple/list is calculated and returned,
360-
or the existing value is modified in-place. By default this is
361-
'False'. If you try to inplace-modify a tuple, an exception is raised.
362-
363-
In cases 2 and 3, there is NO return value if 'inplace' is True --
364-
the original values are modified.
322+
and lists of any of these.
323+
324+
Works in one of three ways:
325+
1. Accepts a single normalized level (0.0 to 1.0) and optional
326+
gamma-adjustment factor (float usu. > 1.0, default if
327+
unspecified is GFACTOR) and brightness (float 0.0 to 1.0,
328+
default is 1.0). Returns a single normalized gamma-corrected
329+
brightness level (0.0 to 1.0).
330+
2. Accepts a single `CRGB` or `CHSV` type, optional single gamma
331+
factor OR a (R,G,B) gamma tuple (3 values usu. > 1.0), optional
332+
single brightness factor OR a (R,G,B) brightness tuple. The
333+
input tuples are RGB even when a `CHSV` color is passed. Returns
334+
a normalized gamma-corrected `CRGB` type (NOT `CHSV`!).
335+
3. Accept a list or tuple of normalized levels, `CRGB` or `CHSV`
336+
types (and optional gamma and brightness levels or tuples
337+
applied to all). Returns a list of gamma-corrected values or
338+
`CRGB` types (NOT `CHSV`!).
339+
340+
In cases 2 and 3, if the input is a list (NOT a tuple!), the 'inplace'
341+
flag determines whether a new tuple/list is calculated and returned,
342+
or the existing value is modified in-place. By default this is
343+
'False'. If you try to inplace-modify a tuple, an exception is raised.
344+
345+
In cases 2 and 3, there is NO return value if 'inplace' is True --
346+
the original values are modified.
365347
"""
366348
# pylint: disable=too-many-branches
367349

0 commit comments

Comments
 (0)