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


Python CHIP_IO.PWM类代码示例

本文整理汇总了Python中CHIP_IO.PWM的典型用法代码示例。如果您正苦于以下问题:Python PWM类的具体用法?Python PWM怎么用?Python PWM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PWM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_start_pwm

    def test_start_pwm(self):
        PWM.start("PWM0", 0)

        pwm_test = '/sys/class/pwm/pwmchip0/pwm0/'

        assert os.path.exists(pwm_test) == True
        duty = open(pwm_test + 'duty_cycle').readline().strip()
        period = open(pwm_test + 'period').readline().strip()
        assert int(duty) == 0
        assert int(period) == 500000
开发者ID:vagelim,项目名称:CHIP_IO,代码行数:10,代码来源:test_pwm_setup.py

示例2: test_start_pwm

    def test_start_pwm(self):
        PWM.start("PWM0", 0)

        pwm_test = '/sys/class/pwm/pwmchip0/pwm0'

        assert os.path.exists(pwm_test)
        duty = open(pwm_test + '/duty_cycle').read()
        period = open(pwm_test + '/period').read()
        assert int(duty) == 0
        assert int(period) == 500000
        PWM.cleanup()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:11,代码来源:test_pwm_setup.py

示例3: test_start_pwm_with_polarity_zero

    def test_start_pwm_with_polarity_zero(self):
        PWM.cleanup()
        PWM.start("PWM0", 0, 2000, 0)

        pwm_test = '/sys/class/pwm/pwmchip0/pwm0/'

        duty = open(pwm_test + 'duty_cycle').readline().strip()
        period = open(pwm_test + 'period').readline().strip()
        polarity = open(pwm_test + 'polarity').readline().strip()
        assert int(duty) == 0
        assert int(period) == 500000
        assert str(polarity) == "normal"
开发者ID:vagelim,项目名称:CHIP_IO,代码行数:12,代码来源:test_pwm_setup.py

示例4: test_start_pwm_with_polarity_zero

    def test_start_pwm_with_polarity_zero(self):
        PWM.start("PWM0", 0, 2000, 0)

        pwm_test = '/sys/class/pwm/pwmchip0/pwm0'

        assert os.path.exists(pwm_test)
        duty = open(pwm_test + '/duty_cycle').read()
        period = open(pwm_test + '/period').read()
        polarity = open(pwm_test + '/polarity').read()
        assert int(duty) == 0
        assert int(period) == 500000
        assert string(polarity) == "normal"
        PWM.cleanup()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:13,代码来源:test_pwm_setup.py

示例5: test_start_pwm_with_polarity_one

    def test_start_pwm_with_polarity_one(self):
        PWM.start("PWM0", 0, 2000, 1)

        pwm_test = '/sys/class/pwm/pwmchip0/pwm0'

        assert os.path.exists(pwm_test)
        duty = open(pwm_test + '/duty_cycle').readline().strip()
        period = open(pwm_test + '/period').readline().strip()
        polarity = open(pwm_test + '/polarity').readline().strip()
        assert int(duty) == 0
        assert int(period) == 500000
        assert str(polarity) == "inverted"
        PWM.cleanup()
开发者ID:HeatfanJohn,项目名称:CHIP_IO,代码行数:13,代码来源:test_pwm_setup.py

示例6: test_pwm_duty_modified

    def test_pwm_duty_modified(self):
        PWM.start("PWM0", 0)

        pwm_test = '/sys/class/pwm/pwmchip0/pwm0'

        assert os.path.exists(pwm_test)
        duty = open(pwm_test + '/duty_cycle').readline().strip()
        period = open(pwm_test + '/period').readline().strip()
        assert int(duty) == 0
        assert int(period) == 500000

        PWM.set_duty_cycle("PWM0", 100)
        duty = open(pwm_test + '/duty_cycle').readline().strip()
        period = open(pwm_test + '/period').readline().strip()
        assert int(duty) == 500000
        assert int(period) == 500000
        PWM.cleanup()
开发者ID:HeatfanJohn,项目名称:CHIP_IO,代码行数:17,代码来源:test_pwm_setup.py

示例7: test_pwm_start_invalid_duty_cycle_string

 def test_pwm_start_invalid_duty_cycle_string(self):
     with pytest.raises(TypeError):
         PWM.start("PWM0", "1")
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_pwm_setup.py

示例8: test_pwm_start_valid_duty_cycle_max

 def test_pwm_start_valid_duty_cycle_max(self):
     #testing an exception isn't thrown
     PWM.start("PWM0", 100)
     PWM.cleanup()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:4,代码来源:test_pwm_setup.py

示例9: test_pwm_start_invalid_duty_cycle_high

 def test_pwm_start_invalid_duty_cycle_high(self):
     with pytest.raises(ValueError):
         PWM.start("PWM0", 101)
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_pwm_setup.py

示例10: 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_pwm_setup.py

示例11: test_pwm_start_invalid_duty_cycle_negative

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

示例12: test_pwm_duty_cycle_non_setup_key

 def test_pwm_duty_cycle_non_setup_key(self):
     with pytest.raises(RuntimeError):
         PWM.set_duty_cycle("PWM0", 100)
         PWM.cleanup()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:4,代码来源:test_pwm_setup.py

示例13: teardown_module

def teardown_module(module):
    PWM.cleanup()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:2,代码来源:test_pwm_setup.py

示例14: test_pwm_start_invalid_positive_polarity

 def test_pwm_start_invalid_positive_polarity(self):
     with pytest.raises(ValueError):
         PWM.start("PWM0", 0, 100, 2)
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:3,代码来源:test_pwm_setup.py

示例15: test_pwm_freq_non_setup_key

 def test_pwm_freq_non_setup_key(self):
     with pytest.raises(ValueError):
         PWM.set_frequency("P9_15", 100)
         PWM.cleanup()
开发者ID:aninternetof,项目名称:CHIP_IO,代码行数:4,代码来源:test_pwm_setup.py


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