Skip to content

Commit

Permalink
Update LED colors
Browse files Browse the repository at this point in the history
  • Loading branch information
chronis10 authored Oct 6, 2024
1 parent b06921f commit e573a22
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions fossbot_lib/real_robot/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()


0 comments on commit e573a22

Please sign in to comment.