Skip to content

Commit de702ff

Browse files
committed
Fix LED group name overlap with color name
1 parent 53d8aa1 commit de702ff

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

ev3dev/brickpi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ class Leds(object):
5050
blue_one = Led(name='brickpi1:blue:ev3dev')
5151
blue_two = Led(name='brickpi2:blue:ev3dev')
5252

53-
BLUE_ONE = (blue_one, )
54-
BLUE_TWO = (blue_two, )
53+
ONE = ( blue_one )
54+
TWO = ( blue_two )
5555

56-
BLUE = (1, )
56+
BLUE = ( 1 )
5757

5858
@staticmethod
5959
def set_color(group, color, pct=1):

ev3dev/ev3.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ class Leds(object):
5252
green_left = Led(name='ev3-left1:green:ev3dev')
5353
green_right = Led(name='ev3-right1:green:ev3dev')
5454

55-
LEFT = (red_left, green_left, )
56-
RIGHT = (red_right, green_right, )
57-
58-
RED = (1, 0, )
59-
GREEN = (0, 1, )
60-
AMBER = (1, 1, )
61-
ORANGE = (1, 0.5, )
62-
YELLOW = (0.5, 1, )
55+
LEFT = ( red_left, green_left )
56+
RIGHT = ( red_right, green_right )
57+
58+
RED = ( 1, 0 )
59+
GREEN = ( 0, 1 )
60+
AMBER = ( 1, 1 )
61+
ORANGE = ( 1, 0.5 )
62+
YELLOW = ( 0.5, 1 )
6363

6464
@staticmethod
6565
def set_color(group, color, pct=1):

templates/led-colors.liquid

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@
33
{{instanceName}} = Led(name='{{instance.systemName}}'){%
44
endfor %}
55
{% for group in currentClass.groups %}{%
6-
assign groupName = group.name | upcase | underscore_spaces %}
7-
{{ groupName }} = ({% for e in group.entries %}{%
8-
assign instance = e | downcase | underscore_spaces
9-
%}{{ instance }}, {%
10-
endfor %}){%
6+
assign groupName = group.name | upcase | underscore_spaces %}{%
7+
assign ledNames = '' %}{%
8+
for name in group.entries %}{%
9+
capture ledNames %}{{ ledNames }}, {{ name | downcase | underscore_spaces }}{%
10+
endcapture %}{%
11+
endfor %}
12+
{{ groupName }} = ( {{ ledNames | remove_first:', ' }} ){%
1113
endfor %}
1214
{% for color in currentClass.colors %}{%
13-
assign colorName = color.name | upcase | underscore_spaces %}
14-
{{ colorName }} = ({% for v in color.value %}{{ v }}, {%endfor %}){%
15+
assign colorName = color.name | upcase | underscore_spaces %}{%
16+
assign mixRatio = '' %}{%
17+
for mix in color.mix %}{%
18+
capture mixRatio %}{{ mixRatio }}, {{ mix.value }}{%
19+
endcapture %}{%
20+
endfor %}
21+
{{ colorName }} = ( {{ mixRatio | remove_first:', ' }} ){%
1522
endfor %}
1623

1724
@staticmethod

0 commit comments

Comments
 (0)