Skip to content
GitLab
Explore
Sign in
Commits on Source (3)
Add constructor of Color
· 3a257c1a
Aljaž Srebrnič
authored
Oct 21, 2018
3a257c1a
Clear colors on init
· 3ed2f8ed
Aljaž Srebrnič
authored
Oct 21, 2018
3ed2f8ed
Fix typos/small mistakes
· 389dd7b4
Aljaž Srebrnič
authored
Oct 21, 2018
389dd7b4
Show whitespace changes
Inline
Side-by-side
lighting.py
View file @
389dd7b4
...
...
@@ -15,6 +15,11 @@ class Color:
red
:
int
blue
:
int
def
__init__
(
self
,
green
,
red
,
blue
):
self
.
green
=
green
self
.
red
=
red
self
.
blue
=
blue
def
as_tuple
(
self
):
return
self
.
green
,
self
.
red
,
self
.
blue
...
...
@@ -29,20 +34,21 @@ class ColorManager(Thread):
def
__init__
(
self
):
super
().
__init__
()
self
.
spi
.
open
(
1
,
0
)
ws2812
.
write2812
(
self
.
spi
,
[(
0
,
0
,
0
)
*
4
])
def
get_color
(
self
):
if
self
.
current_color
.
green
+
self
.
current_rand
>
80
:
self
.
current_rand
=
-
randint
(
1
,
8
)
self
.
current_color
=
Color
(
80
,
255
,
self
.
current_color
.
blue
)
elif
self
.
current_color
.
green
+
self
.
current_rand
<
0
:
rand
=
randint
(
1
,
8
)
self
.
current_
rand
=
randint
(
1
,
8
)
self
.
current_color
=
Color
(
0
,
255
,
self
.
current_color
.
blue
)
else
:
self
.
current_color
.
green
+=
rand
self
.
current_color
.
green
+=
self
.
current_
rand
self
.
current_color
.
red
=
255
self
.
current_color
.
blue
=
self
.
unscaled_blue
*
self
.
current_color
.
green
//
255
if
self
.
unscaled_blue
<
100
:
self
.
unscaled_blue
++
self
.
unscaled_blue
+=
1
def
fade
(
self
):
if
self
.
current_color
.
red
>
0
:
...
...