当前位置: 首页>>代码示例>>Python>>正文


Python Config.hexstring_to_list方法代码示例

本文整理汇总了Python中mpf.system.config.Config.hexstring_to_list方法的典型用法代码示例。如果您正苦于以下问题:Python Config.hexstring_to_list方法的具体用法?Python Config.hexstring_to_list怎么用?Python Config.hexstring_to_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpf.system.config.Config的用法示例。


在下文中一共展示了Config.hexstring_to_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import hexstring_to_list [as 别名]
    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'] = Config.hexstring_to_list(
                self.config['pixel_color'])
            self.config['dark_color'] = Config.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)
开发者ID:jherrm,项目名称:mpf,代码行数:62,代码来源:virtualdmd.py

示例2: adjust_colors

# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import hexstring_to_list [as 别名]
    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 = Config.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 = Config.hexstring_to_list(kwargs['color'])
                self.adjusted_bg_color = (color_list[0], color_list[1],
                                          color_list[2])
            else:
                self.adjusted_bg_color = None
开发者ID:jherrm,项目名称:mpf,代码行数:40,代码来源:display.py

示例3: __init__

# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import hexstring_to_list [as 别名]
    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"] = Config.hexstring_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
开发者ID:jherrm,项目名称:mpf,代码行数:38,代码来源:led.py


注:本文中的mpf.system.config.Config.hexstring_to_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。