Exemplo n.º 1
0
def __get_test_cycle_colors__() -> list:
    base_colors_test = [
        weather.LOW,
        weather.RED,
        weather.BLUE,
        weather.GREEN,
        weather.YELLOW,
        weather.WHITE,
        weather.GRAY,
        weather.DARK_YELLOW,
    ]

    colors_to_init = []

    for color in base_colors_test:
        is_global_dimming = configuration.get_brightness_proportion() < 1.0
        color_to_cycle = colors[color]
        colors_to_init.append(color_to_cycle)
        if is_global_dimming:
            colors_to_init.append(__get_dimmed_color__(color_to_cycle))
        colors_to_init.append(
            __get_night_color_to_render__(color_to_cycle, [0.0, 0.0]))
        if is_global_dimming:
            colors_to_init.append(
                __get_dimmed_color__(
                    __get_night_color_to_render__(color_to_cycle, [0.0, 0.0])))

    colors_to_init.append(colors[weather.OFF])

    return colors_to_init
def __get_dimmed_color__(
    starting_color: list
) -> list:
    """
    Given a starting color, get the version that is dimmed.

    Arguments:
        starting_color {list} -- The starting color that will be dimmed.

    Returns:
        list -- The color with the dimming adjustment.
    """
    dimmed_color = []
    brightness_adjustment = configuration.get_brightness_proportion()
    for color in starting_color:
        reduced_color = float(color) * brightness_adjustment

        # Some colors are floats, some are integers.
        # Make sure we keep everything the same.
        if isinstance(color, int):
            reduced_color = int(reduced_color)

        dimmed_color.append(reduced_color)

    return dimmed_color
Exemplo n.º 3
0
def get_mix_and_color(color_by_category, airport):
    """
    Gets the proportion of color mixes (dark to NIGHT, NIGHT to color) and the final color to render.

    Arguments:
        color_by_category {tuple} -- the initial color decided upon by weather.
        airport {string} -- The station identifier.

    Returns:
        tuple -- proportion, color to render
    """

    color_to_render = color_by_category
    proportions = weather.get_twilight_transition(airport)

    if configuration.get_night_lights():
        color_to_render = __get_night_color_to_render__(
            color_by_category, proportions)

    final_color = []
    brightness_adjustment = configuration.get_brightness_proportion()
    for color in color_to_render:
        reduced_color = float(color) * brightness_adjustment

        # Some colors are floats, some are integers.
        # Make sure we keep everything the same.
        if isinstance(color, int):
            reduced_color = int(reduced_color)

        final_color.append(reduced_color)

    return proportions, final_color
    def __get_brightness_adjusted_color__(self, station: str,
                                          starting_color: list) -> list:
        proportions, color_to_render = get_mix_and_color(
            starting_color, station)
        brightness_adjustment = configuration.get_brightness_proportion()
        final_color = colors_lib.get_brightness_adjusted_color(
            color_to_render, brightness_adjustment)

        return final_color
Exemplo n.º 5
0
    def render_station(self, station: str, is_blink: bool = False):
        """
        Renders a station based on the pressure.

        Arguments:
            station {string} -- The identifier of the station.
        """

        metar = weather.get_metar(station)
        pressure = weather.get_pressure(metar)
        color_to_render = get_color_by_pressure(pressure)
        final_color = colors_lib.get_brightness_adjusted_color(
            color_to_render, configuration.get_brightness_proportion())

        self.__renderer__.set_leds(self.__stations__[station], final_color)
def __get_test_cycle_colors__() -> list:
    base_colors_test = [
        colors_lib.MAGENTA,
        colors_lib.RED,
        colors_lib.BLUE,
        colors_lib.GREEN,
        colors_lib.YELLOW,
        colors_lib.WHITE,
        colors_lib.GRAY,
        colors_lib.DARK_YELLOW
    ]

    colors_to_init = []

    for color in base_colors_test:
        is_global_dimming = configuration.get_brightness_proportion() < 1.0
        color_to_cycle = rgb_colors[color]
        colors_to_init.append(color_to_cycle)
        if is_global_dimming:
            colors_to_init.append(__get_dimmed_color__(color_to_cycle))

    colors_to_init.append(rgb_colors[colors_lib.OFF])

    return colors_to_init
def get_mix_and_color(color_by_category, airport):
    """
    Gets the proportion of color mixes (dark to NIGHT, NIGHT to color) and the final color to render.

    Arguments:
        color_by_category {tuple} -- the initial color decided upon by weather.
        airport {string} -- The station identifier.

    Returns:
        tuple -- proportion, color to render
    """

    color_to_render = color_by_category
    proportions = weather.get_twilight_transition(airport)

    if configuration.get_night_lights():
        color_to_render = __get_night_color_to_render__(
            color_by_category, proportions)

    brightness_adjustment = configuration.get_brightness_proportion()
    final_color = colors_lib.get_brightness_adjusted_color(
        color_to_render, brightness_adjustment)

    return proportions, final_color