本文整理汇总了Python中wiringpi.pwmSetMode方法的典型用法代码示例。如果您正苦于以下问题:Python wiringpi.pwmSetMode方法的具体用法?Python wiringpi.pwmSetMode怎么用?Python wiringpi.pwmSetMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wiringpi
的用法示例。
在下文中一共展示了wiringpi.pwmSetMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: raw_command
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import pwmSetMode [as 别名]
def raw_command(self, command):
if command == 0:
stop()
return
if not self.engauged:
wiringpi.pinMode(1, wiringpi.GPIO.PWM_OUTPUT)
wiringpi.pwmSetMode( wiringpi.GPIO.PWM_MODE_MS )
# fix this to make it higher resolution!!!
wiringpi.pwmSetRange( 1000 )
wiringpi.pwmSetClock( 400 )
self.engauged = True
clockcmd = 60 + 30*command
clockcmd = int(min(110, max(36, clockcmd)))
wiringpi.pwmWrite(1, clockcmd)
示例2: initOS
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import pwmSetMode [as 别名]
def initOS():
os.environ['SDL_FBDEV'] = '/dev/fb1'
os.environ['SDL_MOUSEDEV'] = '/dev/input/touchscreen'
os.environ['SDL_MOUSEDRV'] = 'TSLIB'
os.environ['SDL_VIDEODRIVER'] = 'fbcon'
try:
# if this system has the newer screen control then turn off the SMTPE control so PWM works
with open('/sys/class/backlight/soc:backlight/brightness', 'w') as f:
f.write('0')
except:
pass
wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(18, 2)
wiringpi.pwmSetMode(wiringpi.PWM_MODE_MS) # default balanced mode makes screen dark at about 853/1024
wiringpi.pwmWrite(18, 1024)
示例3: setup_pwm_pin_18
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import pwmSetMode [as 别名]
def setup_pwm_pin_18(initial_value: float = 0):
"""
Sets up pin 18 PWM.
This method is required because the order of the calls to the methods required to setup a pwm pin through
wiringpi matters and is mystical!
Be warned -- This method will only allow you to setup pin 18 in a hardcoded way! You can however read the
configuration variables used by looking at the pwm_pin attribute of this module.
Args:
initial_value (float): a value to set after setting up the pin for pwm
"""
global pwm_pin
if pwm_pin is not None:
warnings.warn('Cannot set up pwm pin more than once! Skipping setup...')
return
pwm_pin = PWMPinInfo(pin_number=18, pwm_range=500, pwm_clock_divisor=765)
wiringpi.pinMode(pwm_pin.pin_number, wiringpi.PWM_OUTPUT) # Set SERVO pin as PWM output
wiringpi.pwmWrite(pwm_pin.pin_number, 0) # Turn output off
# TODO: Ask Luke to explain these three pwm setup functions...
wiringpi.pwmSetMode(wiringpi.PWM_MODE_MS) # Set PWM mode as mark space (as opposed to balanced - the default)
wiringpi.pwmSetRange(pwm_pin.pwm_range) # Set PWM range (range of duty cycles)
wiringpi.pwmSetClock(pwm_pin.pwm_clock_divisor) # Set PWM clock divisor
# Note: PWM Frequency = 19.2MHz / (pwm_divisor * pwm_range)
wiringpi.pwmWrite(pwm_pin.pin_number, initial_value)