Skip to content

Commit def43ba

Browse files
committed
mod: get_color_label split in hsv2label(h,s,v) and get_color_label()
1 parent 44a61c7 commit def43ba

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

arduino_alvik.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,15 @@ def get_color(self, color_format: str = 'rgb') -> (float, float, float):
839839
elif color_format == 'hsv':
840840
return self.rgb2hsv(*self._normalize_color(*self.get_color_raw()))
841841

842+
def get_color_label(self) -> str:
843+
"""
844+
Returns the label of the color as recognized by the sensor
845+
:return:
846+
"""
847+
return self.hsv2label(*self.get_color(color_format='hsv'))
848+
842849
@staticmethod
843-
def get_color_label(h, s, v) -> str:
850+
def hsv2label(h, s, v) -> str:
844851
"""
845852
Returns the color label corresponding to the given normalized HSV color input
846853
:param h:

examples/read_color_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
r, g, b = alvik.get_color()
1111
h, s, v = alvik.get_color('hsv')
1212
print(f'RED: {r}, Green: {g}, Blue: {b}, HUE: {h}, SAT: {s}, VAL: {v}')
13-
print(f'COLOR LABEL: {alvik.get_color_label(h, s, v)}')
13+
print(f'COLOR LABEL: {alvik.get_color_label()}')
1414
sleep_ms(100)
1515
except KeyboardInterrupt as e:
1616
print('over')

0 commit comments

Comments
 (0)