本文整理汇总了Python中mpf.system.utility_functions.Util.normalize_hex_string方法的典型用法代码示例。如果您正苦于以下问题:Python Util.normalize_hex_string方法的具体用法?Python Util.normalize_hex_string怎么用?Python Util.normalize_hex_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpf.system.utility_functions.Util
的用法示例。
在下文中一共展示了Util.normalize_hex_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_led
# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import normalize_hex_string [as 别名]
def configure_led(self, config):
if not self.rgb_connection:
self.log.critical("A request was made to configure a FAST LED, "
"but no connection to an LED processor is "
"available")
sys.exit()
if not self.flag_led_tick_registered:
self.machine.events.add_handler('timer_tick', self.update_leds)
self.flag_led_tick_registered = True
# if the LED number is in <channel> - <led> format, convert it to a
# FAST hardware number
if '-' in config['number_str']:
num = config['number_str'].split('-')
config['number'] = (int(num[0]) * 64) + int(num[1])
self.config['config_number_format'] = 'int'
else:
config['number'] = str(config['number'])
if self.config['config_number_format'] == 'int':
config['number'] = Util.int_to_hex_string(config['number'])
else:
config['number'] = Util.normalize_hex_string(config['number'])
this_fast_led = FASTDirectLED(config['number'])
self.fast_leds.add(this_fast_led)
return this_fast_led
示例2: configure_matrixlight
# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import normalize_hex_string [as 别名]
def configure_matrixlight(self, config):
if not self.net_connection:
self.log.critical("A request was made to configure a FAST matrix "
"light, but no connection to a NET processor is "
"available")
sys.exit()
if self.machine_type == 'wpc': # translate number to FAST light num
config['number'] = self.wpc_light_map.get(
config['number_str'].upper())
elif self.config['config_number_format'] == 'int':
config['number'] = Util.int_to_hex_string(config['number'])
else:
config['number'] = Util.normalize_hex_string(config['number'])
return (FASTMatrixLight(config['number'], self.net_connection.send),
config['number'])
示例3: configure_driver
# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import normalize_hex_string [as 别名]
def configure_driver(self, config, device_type='coil'):
if not self.net_connection:
self.log.critical("A request was made to configure a FAST driver, "
"but no connection to a NET processor is "
"available")
sys.exit()
# If we have WPC driver boards, look up the driver number
if self.machine_type == 'wpc':
config['number'] = self.wpc_driver_map.get(
config['number_str'].upper())
if ('connection' in config and
config['connection'].lower() == 'network'):
config['connection'] = 1
else:
config['connection'] = 0 # local driver (default for WPC)
# If we have FAST IO boards, we need to make sure we have hex strings
elif self.machine_type == 'fast':
if self.config['config_number_format'] == 'int':
config['number'] = Util.int_to_hex_string(config['number'])
else:
config['number'] = Util.normalize_hex_string(config['number'])
# Now figure out the connection type
if ('connection' in config and
config['connection'].lower() == 'local'):
config['connection'] = 0
else:
config['connection'] = 1 # network driver (default for FAST)
else:
self.log.critical("Invalid machine type: {0{}}".format(
self.machine_type))
sys.exit()
return (FASTDriver(config, self.net_connection.send, self.machine),
(config['number'], config['connection']))
示例4: configure_switch
# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import normalize_hex_string [as 别名]
def configure_switch(self, config):
"""Configures the switch object for a FAST Pinball controller.
FAST Controllers support two types of switches: `local` and `network`.
Local switches are switches that are connected to the FAST controller
board itself, and network switches are those connected to a FAST I/O
board.
MPF needs to know which type of switch is this is. You can specify the
switch's connection type in the config file via the ``connection:``
setting (either ``local`` or ``network``).
If a connection type is not specified, this method will use some
intelligence to try to figure out which default should be used.
If the DriverBoard type is ``fast``, then it assumes the default is
``network``. If it's anything else (``wpc``, ``system11``, ``bally``,
etc.) then it assumes the connection type is ``local``. Connection types
can be mixed and matched in the same machine.
"""
if not self.net_connection:
self.log.critical("A request was made to configure a FAST switch, "
"but no connection to a NET processor is "
"available")
sys.exit()
if self.machine_type == 'wpc': # translate switch number to FAST switch
config['number'] = self.wpc_switch_map.get(
config['number_str'].upper())
if 'connection' not in config:
config['connection'] = 0 # local switch (default for WPC)
else:
config['connection'] = 1 # network switch
elif self.machine_type == 'fast':
if 'connection' not in config:
config['connection'] = 1 # network switch (default for FAST)
else:
config['connection'] = 0 # local switch
if self.config['config_number_format'] == 'int':
config['number'] = Util.int_to_hex_string(config['number'])
else:
config['number'] = Util.normalize_hex_string(config['number'])
# convert the switch number into a tuple which is:
# (switch number, connection)
config['number'] = (config['number'], config['connection'])
if not config['debounce_open']:
config['debounce_open'] = self.config['default_debounce_open']
if not config['debounce_close']:
config['debounce_close'] = self.config['default_debounce_close']
self.log.debug("FAST Switch hardware tuple: %s", config['number'])
switch = FASTSwitch(number=config['number'],
debounce_open=config['debounce_open'],
debounce_close=config['debounce_close'],
sender=self.net_connection.send)
return switch, config['number']