本文整理汇总了Python中mpf.system.utility_functions.Util.pwm32_to_hex_string方法的典型用法代码示例。如果您正苦于以下问题:Python Util.pwm32_to_hex_string方法的具体用法?Python Util.pwm32_to_hex_string怎么用?Python Util.pwm32_to_hex_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpf.system.utility_functions.Util
的用法示例。
在下文中一共展示了Util.pwm32_to_hex_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: merge_driver_settings
# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import pwm32_to_hex_string [as 别名]
def merge_driver_settings(self,
pulse_ms=None,
pwm_on_ms=None,
pwm_off_ms=None,
pulse_power=None,
hold_power=None,
pulse_power32=None,
hold_power32=None,
pulse_pwm_mask=None,
hold_pwm_mask=None,
recycle_ms=None,
activation_time=None,
**kwargs
):
if pwm_on_ms:
raise ValueError("The setting 'pwm_on_ms' is not valid with the "
"FAST platform. Use a hold_power or hold_pwm_mask"
" instead.")
if pwm_off_ms:
raise ValueError("The setting 'pwm_off_ms' is not valid with the "
"FAST platform. Use a hold_power or hold_pwm_mask"
" instead.")
if pulse_power32:
raise NotImplementedError('"pulse_power32" has not been '
'implemented yet')
if hold_power32:
raise NotImplementedError('"hold_power32" has not been '
'implemented yet')
return_dict = dict()
return_dict['pwm32'] = None
if activation_time is not None:
if activation_time > 25500:
raise ValueError('Max FAST timed_hold time is 25.5s')
# FAST activation times are ms * 100
return_dict['activation_time'] = str(activation_time / 100)
if recycle_ms is not None:
return_dict['recycle_ms'] = (Util.int_to_hex_string(recycle_ms))
if pulse_ms is not None:
return_dict['pulse_ms'] = Util.int_to_hex_string(pulse_ms)
if pulse_pwm_mask:
pulse_pwm_mask = str(pulse_pwm_mask)
if len(pulse_pwm_mask) == 32:
return_dict['pwm1'] = Util.bin_str_to_hex_str(pulse_pwm_mask, 8)
elif len(pulse_pwm_mask) == 8:
return_dict['pwm1'] = Util.bin_str_to_hex_str(pulse_pwm_mask, 2)
else:
raise ValueError("pulse_pwm_mask must either be 8 or 32 bits")
elif pulse_power32 is not None:
return_dict['pwm32'] = Util.pwm32_to_hex_string(pulse_power32)
elif pulse_power is not None:
return_dict['pwm1'] = Util.pwm8_to_hex_string(pulse_power)
if hold_pwm_mask:
hold_pwm_mask = str(hold_pwm_mask)
if len(hold_pwm_mask) == 32:
return_dict['pwm2'] = Util.bin_str_to_hex_str(hold_pwm_mask, 8)
elif len(hold_pwm_mask) == 8:
return_dict['pwm2'] = Util.bin_str_to_hex_str(hold_pwm_mask, 2)
else:
raise ValueError("hold_pwm_mask must either be 8 or 32 bits")
elif hold_power32 is not None:
return_dict['pwm32'] = Util.pwm32_to_hex_string(hold_power32)
elif hold_power is not None:
return_dict['pwm2'] = Util.pwm8_to_hex_string(hold_power)
return return_dict