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


Python PWM.clear_channel_gpio方法代码示例

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


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

示例1: right_speed

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def right_speed(speed):
    if speed <0:
        PWM.clear_channel_gpio(DMA_RIGHT, RIGHT_FORWARD)
        set_motor_speed(DMA_RIGHT, RIGHT_BACKWARD, -speed)
    else:
        PWM.clear_channel_gpio(DMA_RIGHT, RIGHT_BACKWARD)
        set_motor_speed(DMA_RIGHT, RIGHT_FORWARD, speed)
开发者ID:haum,项目名称:TK-RX13,代码行数:9,代码来源:motors.py

示例2: P0

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def P0():	# Process 0 controlles Pan servo
	speed = .1		# Here we set some defaults:
	RollCP = initroll - 1		# by making the current position and desired position unequal,-
	RollDP = initroll		# 	we can be sure we know where the servo really is. (or will be soon)

	while True:
		time.sleep(speed)
		if RollCPQ.empty():			# Constantly update RollCPQ in case the main process needs-
			RollCPQ.put(RollCP)		# 	to read it
		if not RollDPQ.empty():		# Constantly read read RollDPQ in case the main process-
			RollDP = RollDPQ.get()	#	has updated it
		if not RollSQ.empty():			# Constantly read read RollSQ in case the main process-
			RollS = RollSQ.get()	# 	has updated it, the higher the speed value, the shorter-
			speed = .1 / RollS		# 	the wait between loops will be, so the servo moves faster
		if RollCP < RollDP:					# if RollCPQ less than RollDPQ
			RollCP += 1						# incriment RollCPQ up by one
			RollCPQ.put(RollCP)					# move the servo that little bit
			PWM.clear_channel_gpio(0, Roll)
			PWM.add_channel_pulse(0, Roll, 0, RollCP)
			if not RollCPQ.empty():				# throw away the old RollCPQ value,-
				trash = RollCPQ.get()				# 	it's no longer relevent
		if RollCP > RollDP:					# if RollCPQ greater than ServoPanDP
			RollCP -= 1						# incriment RollCPQ down by one
			RollCPQ.put(RollCP)					# move the servo that little bit
			PWM.clear_channel_gpio(0,Roll)
			PWM.add_channel_pulse(0, Roll, 0, RollCP)
			if not RollCPQ.empty():				# throw away the old ROllPanCPQ value,-
				trash = RollCPQ.get()				# 	it's no longer relevent
		if RollCP == RollDP:	        # if all is good,-
			RollS = 1		        # slow the speed; no need to eat CPU just waiting
开发者ID:Sushant-Bedage,项目名称:Object-Tracking-Camera,代码行数:32,代码来源:code.py

示例3: P1

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def P1():	# Process 1 controlles Tilt servo using same logic as above
	speed = .1
	PitchCP = initpitch - 1
	PitchDP = initpitch

	while True:
		time.sleep(speed)
		if PitchCPQ.empty():
			PitchCPQ.put(Pitch)
		if not PitchDPQ.empty():
			PitchDP = PitchDPQ.get()
		if not PitchSQ.empty():
			PitchS = PitchSQ.get()
			speed = .1 / PitchS
		if PitchCP < PitchDP:
			PitchCP += 1
			PitchCPQ.put(PitchCP)
			PWM.clear_channel_gpio(0, Pitch)
			PWM.add_channel_pulse(0, Pitch, 0,PitchCP)
			if not PitchCPQ.empty():
				trash = PitchCPQ.get()
		if PitchCP > PitchDP:
			PitchCP -= 1
			PitchCPQ.put(PitchCP)
			PWM.clear_channel_gpio(0, Pitch)
			PWM.add_channel_pulse(0, Pitch, 0, PitchCP)
			if not PitchCPQ.empty():
				trash = PitchCPQ.get()
		if PitchCP == PitchDP:
			PitchS = 1
开发者ID:Sushant-Bedage,项目名称:Object-Tracking-Camera,代码行数:32,代码来源:code.py

示例4: P0

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def P0():  # Process 0 controlles Pan servo
  speed = .1    # Here we set some defaults:
  _ServoPanCP = initPan - 1    # by making the current position and desired position unequal,-
  _ServoPanDP = initPan    #   we can be sure we know where the servo really is. (or will be soon)

  while True:
    time.sleep(speed)
    if ServoPanCP.empty():      # Constantly update ServoPanCP in case the main process needs-
      ServoPanCP.put(_ServoPanCP)    #   to read it
    if not ServoPanDP.empty():    # Constantly read read ServoPanDP in case the main process-
      _ServoPanDP = ServoPanDP.get()  #  has updated it
    if not ServoPanS.empty():      # Constantly read read ServoPanS in case the main process-
      _ServoPanS = ServoPanS.get()  #   has updated it, the higher the speed value, the shorter-
      speed = .1 / _ServoPanS    #   the wait between loops will be, so the servo moves faster
    if _ServoPanCP < _ServoPanDP:          # if ServoPanCP less than ServoPanDP
      _ServoPanCP += 1            # incriment ServoPanCP up by one
      ServoPanCP.put(_ServoPanCP)          # move the servo that little bit
      PWM.clear_channel_gpio(0, pPan)
      PWM.add_channel_pulse(0, pPan, 0, _ServoPanCP)
      if not ServoPanCP.empty():        # throw away the old ServoPanCP value,-
        trash = ServoPanCP.get()        #   it's no longer relevent
    if _ServoPanCP > _ServoPanDP:          # if ServoPanCP greater than ServoPanDP
      _ServoPanCP -= 1            # incriment ServoPanCP down by one
      ServoPanCP.put(_ServoPanCP)          # move the servo that little bit
      PWM.clear_channel_gpio(0, pPan)
      PWM.add_channel_pulse(0, pPan, 0, _ServoPanCP)
      if not ServoPanCP.empty():        # throw away the old ServoPanCP value,-
        trash = ServoPanCP.get()        #   it's no longer relevent
    if _ServoPanCP == _ServoPanDP:          # if all is good,-
      _ServoPanS = 1            # slow the speed; no need to eat CPU just waiting
开发者ID:lukasLump,项目名称:project_motorPoster_creepyEyes,代码行数:32,代码来源:facetrack.py

示例5: left_speed

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def left_speed(speed):
    if speed <0:
        PWM.clear_channel_gpio(DMA_LEFT, LEFT_FORWARD)
        set_motor_speed(DMA_LEFT, LEFT_BACKWARD, -speed)
    else:
        PWM.clear_channel_gpio(DMA_LEFT, LEFT_BACKWARD)
        set_motor_speed(DMA_LEFT, LEFT_FORWARD, speed)
开发者ID:haum,项目名称:TK-RX13,代码行数:9,代码来源:motors.py

示例6: P1

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def P1():	# Process 1 controlles Tilt servo using same logic as above
	speed = .1
	_ServoTiltCP = initTilt - 1
	_ServoTiltDP = initTilt

	while True:
		time.sleep(speed)
		if ServoTiltCP.empty():
			ServoTiltCP.put(_ServoTiltCP)
		if not ServoTiltDP.empty():
			_ServoTiltDP = ServoTiltDP.get()
		if not ServoTiltS.empty():
			_ServoTiltS = ServoTiltS.get()
			speed = .1 / _ServoTiltS
		if _ServoTiltCP < _ServoTiltDP:
			_ServoTiltCP += 1
			ServoTiltCP.put(_ServoTiltCP)
			PWM.clear_channel_gpio(0, pTilt)
			PWM.add_channel_pulse(0, pTilt, 0, _ServoTiltCP)
			if not ServoTiltCP.empty():
				trash = ServoTiltCP.get()
		if _ServoTiltCP > _ServoTiltDP:
			_ServoTiltCP -= 1
			ServoTiltCP.put(_ServoTiltCP)
			PWM.clear_channel_gpio(0, pTilt)
			PWM.add_channel_pulse(0, pTilt, 0, _ServoTiltCP)
			if not ServoTiltCP.empty():
				trash = ServoTiltCP.get()
		if _ServoTiltCP == _ServoTiltDP:
			_ServoTiltS = 1
开发者ID:DXM123,项目名称:facetrack,代码行数:32,代码来源:facetrack2.py

示例7: eyes

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def eyes(wink=3):
	for i in (1,wink):
		PWM.add_channel_pulse(0, 21, 0, 10)
		time.sleep(1)
		PWM.add_channel_pulse(0, 21, 0, 100)
		time.sleep(1)
		PWM.clear_channel_gpio(0, 21)
		GPIO.cleanup()
开发者ID:Harbardr,项目名称:FisherPricePhoneChatter,代码行数:10,代码来源:servo.py

示例8: send_signal

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def send_signal(signal):
  for x in range(1,1000,5): 
    pwm.add_channel_pulse(0, IO_PIN, x ,3)
  time.sleep(SIGNAL_LENGTHS[signal])
  pwm.clear_channel_gpio(0, IO_PIN)
  if DEBUG:
    sys.stdout.write(signal)
    sys.stdout.flush()
开发者ID:unfedorg,项目名称:rpi_jjy_server,代码行数:10,代码来源:jjy.py

示例9: note

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def note(value, pin):
    #PWM.setup()
    #PWM.clear_channel_gpio(0, pin)
    print "siren", value
    #TODO - Add mapping between midi value and PWM speed

    PWM.add_channel_pulse(0, pin, 0, value)
    sleep(0.5)
    PWM.clear_channel_gpio(0, pin)
开发者ID:b0rkestra,项目名称:b0rkestra,代码行数:11,代码来源:SunGuitar.py

示例10: set_velocity

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
		def set_velocity(self,pwmotor,motor_id):
			[pins,dma_ch] = self.motor_list[motor_id]
			c = [0,0]
			c[0] = PWM.get_channel_subcycle_time_us(dma_ch[0])/(100.0*PWM.get_pulse_incr_us()) #coefficient to convert duty to period
			c[1] = PWM.get_channel_subcycle_time_us(dma_ch[1])/(100.0*PWM.get_pulse_incr_us()) #coefficient to convert duty to period
			try:
				PWM.clear_channel_gpio(dma_ch[0], pins[0])
				PWM.clear_channel_gpio(dma_ch[1], pins[1])
			except:
				pass
			if pwmotor>0:
				PWM.add_channel_pulse(dma_ch[1],pins[1],0,0)
				PWM.add_channel_pulse(dma_ch[0],pins[0],0,int(abs(pwmotor)*c[0]))
			else:
				PWM.add_channel_pulse(dma_ch[0],pins[0],0,0)
				PWM.add_channel_pulse(dma_ch[1],pins[1],0,int(abs(pwmotor)*c[1]))
开发者ID:jcert,项目名称:t_controller,代码行数:18,代码来源:motor.py

示例11: pwm_example2

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def pwm_example2():
    from RPIO import PWM

    # Setup PWM and DMA channel 0
    PWM.setup()
    PWM.init_channel(0)
    
    # Add some pulses to the subcycle
    PWM.add_channel_pulse(0, 17, 0, 50)
    PWM.add_channel_pulse(0, 17, 100, 50)
    
    # Stop PWM for specific GPIO on channel 0
    PWM.clear_channel_gpio(0, 17)
    
    # Shutdown all PWM and DMA activity
    PWM.cleanup()
开发者ID:CloseCall,项目名称:quadcopter,代码行数:18,代码来源:quadcopter.py

示例12: RightMotor

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def RightMotor(dir):
    if dir == DIR_FW:
        PWM.add_channel_pulse(0, M2_B, 0, PWM_WIDTH)
        PWM.clear_channel_gpio(0, M2_A)
        
        webiopi.debug("Right FW")
    elif dir == DIR_BW:
        PWM.add_channel_pulse(0, M2_A, 0, PWM_WIDTH)
        PWM.clear_channel_gpio(0, M2_B)

        webiopi.debug("Right BW")
    else:
        PWM.clear_channel_gpio(0, M2_A)
        PWM.clear_channel_gpio(0, M2_B)
开发者ID:rasplay,项目名称:clickpirc,代码行数:16,代码来源:rc_script_pwm.py

示例13: input

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
import RPIO 
from RPIO import PWM
import time

# Top and bottom LEDs
# - Flash alternating.
#

PWM.setup(1000) # Pulse increment in micro Seconds = 1 milli Second
PWM.init_channel(0, subcycle_time_us=1000000) # Cycle time in microSeconds == 1 second

# All values from here are in mSeconds.
#
PWM.add_channel_pulse(0, 23, start=500, width=499)
PWM.add_channel_pulse(0, 24, start=0, width=499)

time.sleep(5)

# Needed to clear down the GPIO back to input (cleanup() does not do that).
#
PWM.clear_channel_gpio(0,23)
PWM.clear_channel_gpio(0,24)

# Shutdown all PWM and DMA activity
PWM.cleanup()

开发者ID:MakerSpaceLeiden,项目名称:AccesSystem,代码行数:27,代码来源:pwm.py

示例14: sleep

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
# tests RPIO lib instead of gpiozero

from RPIO import PWM
from time import sleep

# Setup PWM and DMA channel 0
PWM.setup()
PWM.init_channel(0)

# Add some pulses to the subcycle
PWM.add_channel_pulse(0, 4, 0, 50)
PWM.add_channel_pulse(0, 4, 100, 50)

sleep(10)

# Stop PWM for specific GPIO on channel 0
PWM.clear_channel_gpio(0, 4)

# Shutdown all PWM and DMA activity
PWM.cleanup()
开发者ID:piif,项目名称:scoreboard,代码行数:22,代码来源:rpio.py

示例15: stop_all

# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import clear_channel_gpio [as 别名]
def stop_all():
    print "stop"
    PWM.clear_channel_gpio(dma_l, l_enable_pin)
    PWM.clear_channel_gpio(dma_r, r_enable_pin)
开发者ID:mattvenn,项目名称:raspi-buggy,代码行数:6,代码来源:buggy.py


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