Skip to content

Blaster

LEDControl

Control RGB LEDs

__init__(self) special

Initializes RGB strip and turn all leds blue

Source code in controls/leds.py
def __init__(self):
    """
        Initializes RGB strip and turn all leds blue
    """
    self.led = RgbLedHAL()
    self.led_numbers = 12  # half stripe
    self.all_leds_blue()

all_leds_blue(self)

Turns all LEDs blue

Source code in controls/leds.py
def all_leds_blue(self):
    """
        Turns all LEDs blue
    """
    self.led.configure_all_leds([10, 0, 10])

all_leds_green(self)

Turns all LEDs green

Source code in controls/leds.py
def all_leds_green(self):
    """
        Turns all LEDs green
    """
    self.led.configure_all_leds([10, 0, 0])

display_joystick_pos(self, pos)

Switch LEDs on and off depending on joystick position

Parameters:

Name Type Description Default
pos

position of joystick, between -1 and 1

required
Source code in controls/leds.py
def display_joystick_pos(self, pos):
    """
        Switch LEDs on and off depending on joystick position

        Parameters:
            pos: position of joystick, between -1 and 1
    """
    pos = pos * self.led_numbers
    self.led.configure_individual_leds([10, 0, 10], pos)

score_leds(self, time) async

Blink score LEDs

Source code in controls/leds.py
async def score_leds(self, time: float):
    """
        Blink score LEDs
    """

    self.led.led_score_on([10, 0, 0])
    await asyncio.sleep(time)
    self.led.led_score_off()

switch_off_leds(self)

Switches all LEDs off

Source code in controls/leds.py
def switch_off_leds(self):
    """
        Switches all LEDs off
    """
    self.led.close()
Back to top