From e573a220e938d620a7b3c7be0131949612fe7b3f Mon Sep 17 00:00:00 2001 From: Christos Chronis Date: Sun, 6 Oct 2024 10:28:22 +0300 Subject: [PATCH] Update LED colors --- fossbot_lib/real_robot/control.py | 71 ++++++++++++++++--------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/fossbot_lib/real_robot/control.py b/fossbot_lib/real_robot/control.py index f59f532..d6289a5 100644 --- a/fossbot_lib/real_robot/control.py +++ b/fossbot_lib/real_robot/control.py @@ -330,11 +330,11 @@ def set_off(self) -> None: class LedRGB(control_interfaces.LedRGBInterface): ''' - Class LedRGB(pin_r,pin_b,pin_g) -> Led control + Class LedRGB(pin_r, pin_b, pin_g) -> Led control set_on(color): sets led to input color. ''' - def __init__(self, pin_r: int = 16, pin_b: int = 19, pin_g: int = 12,anode:bool = False) -> None: + def __init__(self, pin_r: int = 16, pin_b: int = 19, pin_g: int = 12, anode: bool = False) -> None: self.p_r = GenOutput(pin_r) self.p_b = GenOutput(pin_b) self.p_g = GenOutput(pin_g) @@ -346,80 +346,81 @@ def __init__(self, pin_r: int = 16, pin_b: int = 19, pin_g: int = 12,anode:bool def set_on(self, color: str) -> None: ''' - Changes the color of a led - Param: color: the wanted color - For closing the led, use color == 'closed' + Changes the color of a LED. + Param: color: the desired color. + For turning off the LED, use color == 'closed'. ''' if color == 'red': if self.anode: - self.p_r.set_off() - self.p_b.set_on() - self.p_g.set_on() - else: self.p_r.set_on() self.p_b.set_off() self.p_g.set_off() - elif color == 'green': - if self.anode: - self.p_r.set_on() - self.p_b.set_on() - self.p_g.set_off() else: self.p_r.set_off() - self.p_b.set_off() + self.p_b.set_on() self.p_g.set_on() - elif color == 'blue': + elif color == 'green': if self.anode: - self.p_r.set_on() + self.p_r.set_off() self.p_b.set_off() self.p_g.set_on() else: - self.p_r.set_off() + self.p_r.set_on() self.p_b.set_on() self.p_g.set_off() - elif color == 'white': + elif color == 'blue': if self.anode: self.p_r.set_off() - self.p_b.set_off() + self.p_b.set_on() self.p_g.set_off() else: self.p_r.set_on() - self.p_b.set_on() - self.p_g.set_on() - elif color == 'violet': - if self.anode: - self.p_r.set_off() self.p_b.set_off() self.p_g.set_on() - else: + elif color == 'white': + if self.anode: self.p_r.set_on() self.p_b.set_on() + self.p_g.set_on() + else: + self.p_r.set_off() + self.p_b.set_off() self.p_g.set_off() - elif color == 'cyan': + elif color == 'violet': if self.anode: self.p_r.set_on() - self.p_b.set_off() + self.p_b.set_on() self.p_g.set_off() else: self.p_r.set_off() - self.p_b.set_on() + self.p_b.set_off() self.p_g.set_on() - elif color == 'yellow': + elif color == 'cyan': if self.anode: self.p_r.set_off() self.p_b.set_on() - self.p_g.set_off() + self.p_g.set_on() else: self.p_r.set_on() self.p_b.set_off() - self.p_g.set_on() - - elif color == 'closed': + self.p_g.set_off() + elif color == 'yellow': if self.anode: self.p_r.set_on() - self.p_b.set_on() + self.p_b.set_off() self.p_g.set_on() else: + self.p_r.set_off() + self.p_b.set_on() + self.p_g.set_off() + elif color == 'closed': + if self.anode: self.p_r.set_off() self.p_b.set_off() self.p_g.set_off() + else: + self.p_r.set_on() + self.p_b.set_on() + self.p_g.set_on() + +