Example #1
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'] = LightController.hexstring_to_list(
                self.config['pixel_color'])
            self.config['dark_color'] = LightController.hexstring_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)
Example #2
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 = LightController.hexstring_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 = LightController.hexstring_to_list(kwargs['color'])
                self.adjusted_bg_color = (color_list[0], color_list[1],
                                          color_list[2])
            else:
                self.adjusted_bg_color = None
Example #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 = LightController.hexstring_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 = LightController.hexstring_to_list(kwargs["color"])
                self.adjusted_bg_color = (color_list[0], color_list[1], color_list[2])
            else:
                self.adjusted_bg_color = None
Example #4
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'] = LightController.hexstring_to_list(
                self.config['pixel_color'])
            self.config['dark_color'] = LightController.hexstring_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)