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


Python CHIP_IO.SOFTPWM类代码示例

本文整理汇总了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)
开发者ID:artizirk,项目名称:sumochip,代码行数:7,代码来源:sumorobot.py

示例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()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:8,代码来源:test_softpwm_setup.py

示例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)
开发者ID:artizirk,项目名称:sumochip,代码行数:8,代码来源:sumorobot.py

示例4: test_pwm_start_negative_polarity

 def test_pwm_start_negative_polarity(self):
     with pytest.raises(ValueError):
         PWM.start("XIO-P7", 0, 100, -1)
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_softpwm_setup.py

示例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")
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_softpwm_setup.py

示例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)
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_softpwm_setup.py

示例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()
开发者ID:cornbreadheadman,项目名称:CHIP_IO,代码行数:6,代码来源:test_softpwm_setup.py

示例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()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:5,代码来源:test_softpwm_setup.py

示例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()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:4,代码来源:test_softpwm_setup.py

示例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()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:4,代码来源:test_softpwm_setup.py

示例11: test_pwm_start_invalid_pwm_key

 def test_pwm_start_invalid_pwm_key(self):
     with pytest.raises(ValueError):
         PWM.start("P8_25", -1)
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_softpwm_setup.py

示例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()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:5,代码来源:test_softpwm_setup.py

示例13: setup_method

 def setup_method(self, test_method):
     PWM.cleanup()
开发者ID:vagelim,项目名称:CHIP_IO,代码行数:2,代码来源:test_softpwm_setup.py

示例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)
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_softpwm_setup.py

示例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)
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_softpwm_setup.py


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