本文整理汇总了Python中CHIP_IO.SOFTPWM类的典型用法代码示例。如果您正苦于以下问题:Python SOFTPWM类的具体用法?Python SOFTPWM怎么用?Python SOFTPWM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SOFTPWM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: speed
def speed(self, val):
self._speed = val
if val == 0 and not self.stop_on_zero:
duty = 0
else:
duty = int(map(val, -1.0, 1.0, self.duty_min, self.duty_max))
PWM.set_duty_cycle(self.pin, duty)
示例2: test_start_pwm
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()
示例3: __init__
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)
示例4: test_pwm_start_negative_polarity
def test_pwm_start_negative_polarity(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", 0, 100, -1)
示例5: test_pwm_start_invalid_frequency_string
def test_pwm_start_invalid_frequency_string(self):
with pytest.raises(TypeError):
PWM.start("XIO-P7", 0, "1")
示例6: test_pwm_start_invalid_frequency_negative
def test_pwm_start_invalid_frequency_negative(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", 0, -1)
示例7: test_start_pwm
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()
示例8: test_pwm_duty_cycle_invalid_value_string
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()
示例9: test_pwm_duty_cycle_invalid_key
def test_pwm_duty_cycle_invalid_key(self):
with pytest.raises(ValueError):
PWM.set_duty_cycle("P9_15", 100)
PWM.cleanup()
示例10: test_pwm_duty_cycle_non_setup_key
def test_pwm_duty_cycle_non_setup_key(self):
with pytest.raises(RuntimeError):
PWM.set_duty_cycle("XIO-P7", 100)
PWM.cleanup()
示例11: test_pwm_start_invalid_pwm_key
def test_pwm_start_invalid_pwm_key(self):
with pytest.raises(ValueError):
PWM.start("P8_25", -1)
示例12: test_pwm_frequency_invalid_value_string
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()
示例13: setup_method
def setup_method(self, test_method):
PWM.cleanup()
示例14: test_pwm_start_invalid_positive_polarity
def test_pwm_start_invalid_positive_polarity(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", 0, 100, 2)
示例15: test_pwm_start_invalid_duty_cycle_negative
def test_pwm_start_invalid_duty_cycle_negative(self):
with pytest.raises(ValueError):
PWM.start("XIO-P7", -1)