當前位置: 首頁>>代碼示例>>Python>>正文


Python wiringpi.pwmWrite方法代碼示例

本文整理匯總了Python中wiringpi.pwmWrite方法的典型用法代碼示例。如果您正苦於以下問題:Python wiringpi.pwmWrite方法的具體用法?Python wiringpi.pwmWrite怎麽用?Python wiringpi.pwmWrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wiringpi的用法示例。


在下文中一共展示了wiringpi.pwmWrite方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: raw_command

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [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) 
開發者ID:pypilot,項目名稱:pypilot,代碼行數:19,代碼來源:servo.py

示例2: initOS

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [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) 
開發者ID:kevinkahn,項目名稱:softconsole,代碼行數:20,代碼來源:hw.py

示例3: write_rpi_servo

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [as 別名]
def write_rpi_servo(self, pos):
    if pos < 0:
      self.logger.warning("cannot write negative servo value")
      return 0
    if pos > 255:
      self.logger.warning("servo value too large")
      return 0
    #TODO: fix wiringpi
    #wiringpi.pwmWrite(1,pos)    
    return 1 
開發者ID:HisarCS,項目名稱:cuneyt,代碼行數:12,代碼來源:motor_controller.py

示例4: pwm

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [as 別名]
def pwm(pin, val):
    _pinmode(pin, 2)  # enable PWM mode on pin
    wiringpi.pwmWrite(pin, val) 
開發者ID:liffiton,項目名稱:ATLeS,代碼行數:5,代碼來源:wiring.py

示例5: GoDim

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [as 別名]
def GoDim(level):
	wiringpi.pwmWrite(18, (level*1024)/100) 
開發者ID:kevinkahn,項目名稱:softconsole,代碼行數:4,代碼來源:hw.py

示例6: GoBright

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [as 別名]
def GoBright(level):
	wiringpi.pwmWrite(18, (level*1024)/100) 
開發者ID:kevinkahn,項目名稱:softconsole,代碼行數:4,代碼來源:hw.py

示例7: gen

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [as 別名]
def gen(): 
    last_time = 0 
    while True:
        global sliderValue
        wiringpi.pwmWrite(18,sliderValue)
        print (1/(time.time()-last_time))
        last_time = time.time()
        frame = cap.read()  
        frame = cv2.imencode('.jpg',frame,[int(IMWRITE_JPEG_QUALITY),50])[1].tostring() 
        yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')


#default route 
開發者ID:HighlandersFRC,項目名稱:2016-Tegra-OpenCV,代碼行數:15,代碼來源:SpyCam.py

示例8:

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [as 別名]
def function PwmControl(self,turnForward):
    if turnForward:
        for i in range(255):
            wiringpi.pwmWrite(MotorEnable,i)
            sleep(.001)
    else:
        for i in range(255,0,-1):
            wiringpi.pwmWrite(MotorEnable,i)
            sleep(.001) 
開發者ID:mnr,項目名稱:RPi_GPIO,代碼行數:11,代碼來源:Motor_driver_L293D_with_PWM.py

示例9: setup_pwm_pin_18

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [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) 
開發者ID:JackBuck,項目名稱:Robo-Plot,代碼行數:31,代碼來源:wiringpi_wrapper.py

示例10: write_pwm_to_pin_18

# 需要導入模塊: import wiringpi [as 別名]
# 或者: from wiringpi import pwmWrite [as 別名]
def write_pwm_to_pin_18(value: int):
    """Does what it says on the tin."""
    wiringpi.pwmWrite(18, value) 
開發者ID:JackBuck,項目名稱:Robo-Plot,代碼行數:5,代碼來源:wiringpi_wrapper.py


注:本文中的wiringpi.pwmWrite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。