예제 #1
0
파일: virtualdmd.py 프로젝트: mini338/mpf
    def __init__(self, slide, machine, dmd_object=None, x=None, y=None, h_pos=None, v_pos=None, layer=0, **kwargs):

        super(VirtualDMD, self).__init__(slide, x, y, h_pos, v_pos, layer)

        if not dmd_object:
            self.dmd_object = machine.display.displays["dmd"]
        else:
            self.dmd_object = dmd_object

        self.config = kwargs

        self.name = "VirtualDMD"

        if self.dmd_object.depth == 8:

            if "pixel_color" not in kwargs:
                self.config["pixel_color"] = "ff5500"

            if "dark_color" not in self.config:
                self.config["dark_color"] = "221100"

            if "pixel_spacing" not in self.config:
                self.config["pixel_spacing"] = 2

            # convert hex colors to list of ints
            self.config["pixel_color"] = Util.hex_string_to_list(self.config["pixel_color"])
            self.config["dark_color"] = Util.hex_string_to_list(self.config["dark_color"])

            # This needs to match the source DMD or it could get weird
            self.config["shades"] = self.dmd_object.config["shades"]

            self.palette = mpf.media_controller.display_modules.dmd.create_palette(
                bright_color=self.config["pixel_color"],
                dark_color=self.config["dark_color"],
                steps=self.config["shades"],
            )

        if "width" in self.config and "height" not in self.config:
            self.config["height"] = self.config["width"] / 4
        elif "height" in self.config and "width" not in self.config:
            self.config["width"] = self.config["height"] * 4
        elif "width" not in self.config and "height" not in self.config:
            self.config["width"] = 512
            self.config["height"] = 128

        # Create a Pygame surface for the on screen DMD
        self.element_surface = pygame.Surface(
            (self.config["width"], self.config["height"]), depth=self.dmd_object.depth
        )

        if self.dmd_object.depth == 8:
            self.element_surface.set_palette(self.palette)

        self.layer = layer
        self.set_position(x, y, h_pos, v_pos)
예제 #2
0
파일: display.py 프로젝트: HarryXS/mpf
    def adjust_colors(self, **kwargs):
        """Takes a settings dictionary and converts the object and background
        colors into a format Pygame can use.

        Args:
            **kwargs: A settings dictionary for this display element. Specific
                key / value pairs this method uses are shade, bg_shade, color,
                and bg_color.

        This method sets the adjusted_color and adjusted_bg_color attributes.

        """

        if self.slide.depth == 8:
            if 'shade' in kwargs:
                self.adjusted_color = (kwargs['shade'], 0, 0)
            else:
                self.adjusted_color = (15, 0, 0)  # todo default config

            if 'bg_shade' in kwargs:
                self.adjusted_bg_color = (kwargs['bg_shade'], 0, 0)
            else:
                self.adjusted_bg_color = None

        else:  # 24-bit
            if 'color' in kwargs:
                color_list = Util.hex_string_to_list(kwargs['color'])
                self.adjusted_color = (color_list[0], color_list[1],
                                       color_list[2])
            else:
                self.adjusted_color = (255, 255, 255)  # todo default config

            if 'bg_color' in kwargs:
                color_list = Util.hex_string_to_list(kwargs['color'])
                self.adjusted_bg_color = (color_list[0], color_list[1],
                                          color_list[2])
            else:
                self.adjusted_bg_color = None
예제 #3
0
    def adjust_colors(self, **kwargs):
        """Takes a settings dictionary and converts the object and background
        colors into a format Pygame can use.

        Args:
            **kwargs: A settings dictionary for this display element. Specific
                key / value pairs this method uses are shade, bg_shade, color,
                and bg_color.

        This method sets the adjusted_color and adjusted_bg_color attributes.

        """

        if self.slide.depth == 8:
            if 'shade' in kwargs:
                self.adjusted_color = (kwargs['shade'], 0, 0)
            else:
                self.adjusted_color = (15, 0, 0)  # todo default config

            if 'bg_shade' in kwargs:
                self.adjusted_bg_color = (kwargs['bg_shade'], 0, 0)
            else:
                self.adjusted_bg_color = None

        else:  # 24-bit
            if 'color' in kwargs:
                color_list = Util.hex_string_to_list(kwargs['color'])
                self.adjusted_color = (color_list[0], color_list[1],
                                       color_list[2])
            else:
                self.adjusted_color = (255, 255, 255)  # todo default config

            if 'bg_color' in kwargs:
                color_list = Util.hex_string_to_list(kwargs['color'])
                self.adjusted_bg_color = (color_list[0], color_list[1],
                                          color_list[2])
            else:
                self.adjusted_bg_color = None
예제 #4
0
파일: display.py 프로젝트: HarryXS/mpf
    def adjust_color(self, color, transparent=False):
        if self.slide.depth == 8:
            if color:  # Non-black
                return ((color, 0, 0))

            elif transparent:
                return None

            else:  # Black
                return ((0, 0, 0))

        else:  # 24-bit
            if color:  # Non-black
                color_list = Util.hex_string_to_list(color)
                return ((color_list[0], color_list[1], color_list[2]))

            elif transparent:
                return None

            else:  # Black
                return ((0, 0, 0))
예제 #5
0
    def adjust_color(self, color, transparent=False):
        if self.slide.depth == 8:
            if color:  # Non-black
                return ((color, 0, 0))

            elif transparent:
                return None

            else:  # Black
                return ((0, 0, 0))

        else:  # 24-bit
            if color:  # Non-black
                color_list = Util.hex_string_to_list(color)
                return ((color_list[0], color_list[1], color_list[2]))

            elif transparent:
                return None

            else:  # Black
                return ((0, 0, 0))
예제 #6
0
    def __init__(self, machine, name, config, collection=None, validate=True):
        config['number_str'] = str(config['number']).upper()
        super(LED, self).__init__(machine, name, config, collection,
                                  platform_section='leds', validate=validate)

        self.config['default_color'] = Util.hex_string_to_list(
            input_string=self.config['default_color'],
            output_length=3)

        self.hw_driver = self.platform.configure_led(self.config)

        self.fade_in_progress = False
        self.fade_task = None
        self.fade_destination_color = [0.0, 0.0, 0.0]
        self.fade_end_time = None

        self.state = {  # current state of this LED
                        'color': [0.0, 0.0, 0.0],
                        'priority': 0,
                        'destination_color': [0.0, 0.0, 0.0],
                        'destination_time': 0.0,
                        'start_color': [0.0, 0.0, 0.0],
                        'start_time': 0.0
                     }

        self.cache = {  # cached state of last manual command
                        'color': [0.0, 0.0, 0.0],
                        'priority': 0,
                        'destination_color': [0.0, 0.0, 0.0],
                        'destination_time': 0.0,
                        'start_color': [0.0, 0.0, 0.0],
                        'start_time': 0.0
                     }

        self.set_brightness_compensation(self.config['brightness_compensation'])

        self.current_color = []  # one item for each element, 0-255
예제 #7
0
    def __init__(self,
                 slide,
                 machine,
                 dmd_object=None,
                 x=None,
                 y=None,
                 h_pos=None,
                 v_pos=None,
                 layer=0,
                 **kwargs):

        super(VirtualDMD, self).__init__(slide, x, y, h_pos, v_pos, layer)

        if not dmd_object:
            self.dmd_object = machine.display.displays['dmd']
        else:
            self.dmd_object = dmd_object

        self.config = kwargs

        self.name = 'VirtualDMD'

        if self.dmd_object.depth == 8:

            if 'pixel_color' not in kwargs:
                self.config['pixel_color'] = 'ff5500'

            if 'dark_color' not in self.config:
                self.config['dark_color'] = '221100'

            if 'pixel_spacing' not in self.config:
                self.config['pixel_spacing'] = 2

            # convert hex colors to list of ints
            self.config['pixel_color'] = Util.hex_string_to_list(
                self.config['pixel_color'])
            self.config['dark_color'] = Util.hex_string_to_list(
                self.config['dark_color'])

            # This needs to match the source DMD or it could get weird
            self.config['shades'] = self.dmd_object.config['shades']

            self.palette = mpf.media_controller.display_modules.dmd.create_palette(
                bright_color=self.config['pixel_color'],
                dark_color=self.config['dark_color'],
                steps=self.config['shades'])

        if ('width' in self.config and 'height' not in self.config):
            self.config['height'] = self.config['width'] / 4
        elif ('height' in self.config and 'width' not in self.config):
            self.config['width'] = self.config['height'] * 4
        elif ('width' not in self.config and 'height' not in self.config):
            self.config['width'] = 512
            self.config['height'] = 128

        # Create a Pygame surface for the on screen DMD
        self.element_surface = pygame.Surface(
            (self.config['width'], self.config['height']),
            depth=self.dmd_object.depth)

        if self.dmd_object.depth == 8:
            self.element_surface.set_palette(self.palette)

        self.layer = layer
        self.set_position(x, y, h_pos, v_pos)