本文整理汇总了Python中CHIP_IO.SOFTPWM.start方法的典型用法代码示例。如果您正苦于以下问题:Python SOFTPWM.start方法的具体用法?Python SOFTPWM.start怎么用?Python SOFTPWM.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHIP_IO.SOFTPWM
的用法示例。
在下文中一共展示了SOFTPWM.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_start_pwm
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_start_pwm(self):
PWM.start("XIO-P7", 50, 10)
base = GPIO.get_gpio_base() + 7
gfile = '/sys/class/gpio/gpio%d' % base
assert os.path.exists(gfile)
direction = open(gfile + '/direction').read()
assert(direction == 'out\n')
PWM.cleanup()
示例2: __init__
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def __init__(self, pin, freq=500, duty_min=49.0, duty_max=90.0, stop_on_zero=False):
self.pin = pin
self.freq = freq
self.duty_min = duty_min
self.duty_max = duty_max
self.stop_on_zero = stop_on_zero
sleep(0.1)
PWM.start(pin, 0, 500)
示例3: test_pwm_duty_cycle_invalid_value_negative
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_duty_cycle_invalid_value_negative(self):
PWM.start("XIO-P7", 0)
with pytest.raises(ValueError):
PWM.set_duty_cycle("XIO-P7", -1)
PWM.cleanup()
示例4: test_pwm_start_invalid_polarity_type
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_invalid_polarity_type(self):
with pytest.raises(TypeError):
PWM.start("XIO-P7", 0, 100, "1")
示例5: test_pwm_start_invalid_positive_polarity
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_invalid_positive_polarity(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", 0, 100, 2)
示例6: test_pwm_start_negative_polarity
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_negative_polarity(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", 0, 100, -1)
示例7: test_pwm_start_invalid_frequency_string
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_invalid_frequency_string(self):
with pytest.raises(TypeError):
PWM.start("XIO-P7", 0, "1")
示例8: test_pwm_start_invalid_frequency_negative
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_invalid_frequency_negative(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", 0, -1)
示例9: test_start_pwm
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_start_pwm(self):
PWM.start("XIO-P7", 50, 10)
assert os.path.exists('/sys/class/gpio/gpio415')
direction = open('/sys/class/gpio/gpio415/direction').read()
assert direction == 'out\n'
PWM.cleanup()
示例10: test_pwm_start_invalid_duty_cycle_high
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_invalid_duty_cycle_high(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", 101)
示例11: test_pwm_start_valid_duty_cycle_max
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_valid_duty_cycle_max(self):
# testing an exception isn't thrown
PWM.start("XIO-P7", 100)
PWM.cleanup()
示例12: test_pwm_start_invalid_duty_cycle_negative
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_invalid_duty_cycle_negative(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", -1)
示例13: test_pwm_start_invalid_pwm_key
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_start_invalid_pwm_key(self):
with pytest.raises(ValueError):
PWM.start("P8_25", -1)
示例14: test_pwm_frequency_invalid_value_string
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_frequency_invalid_value_string(self):
PWM.start("XIO-P7", 0)
with pytest.raises(TypeError):
PWM.set_frequency("XIO-P7", "11")
PWM.cleanup()
示例15: test_pwm_duty_cycle_invalid_value_string
# 需要导入模块: from CHIP_IO import SOFTPWM [as 别名]
# 或者: from CHIP_IO.SOFTPWM import start [as 别名]
def test_pwm_duty_cycle_invalid_value_string(self):
PWM.start("XIO-P7", 0)
with pytest.raises(TypeError):
PWM.set_duty_cycle("XIO-P7", "a")
PWM.cleanup()