本文整理汇总了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
示例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()
示例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"
示例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()
示例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()
示例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()
示例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")
示例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()
示例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)
示例10: test_pwm_start_invalid_pwm_key
def test_pwm_start_invalid_pwm_key(self):
with pytest.raises(ValueError):
PWM.start("P8_25", -1)
示例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)
示例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()
示例13: teardown_module
def teardown_module(module):
PWM.cleanup()
示例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)
示例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()