本文整理匯總了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()