in status_led_pkg/status_led_pkg/status_led_node.py [0:0]
def effect_two_color_siren(self,
led_index=constants.DEFAULT_LED_INDEX,
color1=constants.LEDColors.RED,
color2=constants.LEDColors.BLUE,
delay=0.1):
"""Main function implementing the blink color effect with the colors and the led index
passed as parameter.
Args:
led_index (int, optional): LED index to identify the status LED.
Defaults to constants.DEFAULT_LED_INDEX.
color1 (str, optional): First color to set. Defaults to constants.LEDColors.RED.
color2 (str, optional): Second color to set. Defaults to constants.LEDColors.BLUE.
delay (float, optional): Time in seconds to hold each color for the blink effect.
Defaults to 0.1.
"""
led = self.get_led(led_index)
stop = self.stop[led_index]
if color1 in constants.LED_COLOR_VALUES and color2 in constants.LED_COLOR_VALUES:
while not stop.isSet():
led.rgb(constants.LED_COLOR_VALUES[color1])
time.sleep(delay)
led.rgb(constants.LED_COLOR_VALUES[color2])
time.sleep(delay)
led.off()
else:
self.get_logger().error(f"Colors not supported: {color1} {color2}")