Skip to content

Commit 7b0ba28

Browse files
authored
Update template for special class (#303)
Use property value/type when available.
1 parent 7629e9a commit 7b0ba28

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

ev3dev-lang

ev3dev/core.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,27 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
18981898
# Raw Color Components. All LEDs rapidly cycling, appears white.
18991899
MODE_RGB_RAW = 'RGB-RAW'
19001900

1901+
# Red color.
1902+
COLOR_BLACK = 1
1903+
1904+
# Blue color.
1905+
COLOR_BLUE = 2
1906+
1907+
# Green color.
1908+
COLOR_GREEN = 3
1909+
1910+
# Yellow color.
1911+
COLOR_YELLOW = 4
1912+
1913+
# Red color.
1914+
COLOR_RED = 5
1915+
1916+
# White color.
1917+
COLOR_WHITE = 6
1918+
1919+
# Brown color.
1920+
COLOR_BROWN = 7
1921+
19011922

19021923
@property
19031924
def reflected_light_intensity(self):

templates/special-sensors.liquid

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,17 @@ endfor %}
4747
for value in prop.values %}{%
4848
for line in value.description %}
4949
# {{ line }}{%
50-
endfor %}
51-
{{ propName }}_{{ value.name | upcase | underscore_non_wc }} = '{{ value.name }}'
50+
endfor %}{%
51+
if value.value %}{%
52+
if value.type == 'int' %}{%
53+
capture val %}{{ value.value }}{% endcapture %}{%
54+
else %}{%
55+
capture val %}'{{ value.value }}'{% endcapture %}{%
56+
endif %}{%
57+
else %}{%
58+
capture val %}'{{ value.name }}'{% endcapture %}{%
59+
endif %}
60+
{{ propName }}_{{ value.name | upcase | underscore_non_wc }} = {{ val }}
5261
{% endfor %}{%
5362
endfor %}
5463
{% for mapping in currentClass.sensorValueMappings %}{%

0 commit comments

Comments
 (0)