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


Python RPIO.PWM类代码示例

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


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

示例1: right_speed

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,代码行数:7,代码来源:motors.py

示例2: setMotor

 def setMotor(self,channel,speed):
     if(channel=='A'):
         print "set channel A PWM to "+str(speed);
         PWM.add_channel_pulse(self.A_CHANNEL,self.AENBL_Pin,0,speed);
     if(channel=='B'):
         print "set channel B PWM to "+str(speed);
         PWM.add_channel_pulse(self.B_CHANNEL,self.BENBL_Pin,0,speed);
开发者ID:haomen,项目名称:rbot,代码行数:7,代码来源:motor.py

示例3: __init__

 def __init__(self, xin1, xin2, channels):
     self.xin1 = xin1
     self.xin2 = xin2
     self.channel1 = channels[0]
     self.channel2 = channels[1]
     PWM.init_channel(self.channel1)
     PWM.init_channel(self.channel2)
开发者ID:heidtn,项目名称:butter_bot,代码行数:7,代码来源:motor_driver.py

示例4: __init__

    def __init__(self, min_speed=50.0, flipLeft=False, flipRight=False):
        PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
        # each motor will use seperate dma channel (not sure if completely necessary)
        self.left_servo  = PWM.Servo(dma_channel=0,
                                     subcycle_time_us=self.SUBCYCLE_TIME)
        self.right_servo = PWM.Servo(dma_channel=1,
                                     subcycle_time_us=self.SUBCYCLE_TIME)

        # RPIO.PWM module uses BCM GPIO numbering
        self._gpio_lf = 24 # left forward
        self._gpio_lr = 23 # left rear
        self._gpio_rf = 22 # right forward
        self._gpio_rr = 27 # right rear

        # Holder for last commanded speed per motor
        self.left_speed  = 0
        self.right_speed = 0

        self.slope = math.floor(self.SUBCYCLE_TIME * (1 - min_speed/100.0) / 100.0)
        self.offset = math.floor(self.SUBCYCLE_TIME * min_speed / 100.0)

        if flipLeft:
            self.flipLeftMotor()
        if flipRight:
            self.flipRightMotor()
开发者ID:charlieb,项目名称:RobotWars2014,代码行数:25,代码来源:motor.py

示例5: left_speed

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,代码行数:7,代码来源:motors.py

示例6: beep

    def beep(self, t=T_MED, duration=D_MED):

        for x in range(0, self._range, t * 2):
            PWM.add_channel_pulse(self._channel, self._pin, x, t)

        sleep(duration)

        PWM.clear_channel(self._channel)
开发者ID:alyf80,项目名称:goopy,代码行数:8,代码来源:buzzer.py

示例7: __init__

	def __init__(self, pin, minW = 0, maxW = 100):
		PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
		
		self.__pin = pin
		self.__minW = minW
		self.__maxW = maxW
		self.__servo = PWM.Servo()
		self.__W = 0
开发者ID:schmidma,项目名称:PiCopter,代码行数:8,代码来源:motor.py

示例8: update

	def update(self, spin_rate):
		self.current_pulse_width = int(self.min_pulse_width + spin_rate)

		if self.current_pulse_width < self.min_pulse_width:
			self.current_pulse_width = self.min_pulse_width
		if self.current_pulse_width > self.max_pulse_width:
			self.current_pulse_width = self.max_pulse_width

		PWM.add_channel_pulse(RPIO_DMA_CHANNEL, self.bcm_pin, 0, self.current_pulse_width)
开发者ID:monestereo,项目名称:Quadcopter,代码行数:9,代码来源:ESC.py

示例9: __enter__

 def __enter__(self):
     PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
     GPIO.setup(self._gpios['solenoid'], GPIO.OUT)
     GPIO.setup(self._gpios['echo_trigger'], GPIO.OUT)
     GPIO.setup(self._gpios['echo'], GPIO.IN)
     self._i2c_bus = SMBus()
     self._i2c_bus.open(Monster.I2C_BUS_NUM)
     self.close_door()
     return self
开发者ID:mgalgs,项目名称:halloween-2015,代码行数:9,代码来源:main.py

示例10: stopMotor

 def stopMotor(self,channel):
     if(channel=='A'):
         print "stop channel A"
         self.setDirection('A',0);
         PWM.add_channel_pulse(self.A_CHANNEL,self.AENBL_Pin,0,0);
     if(channel=='B'):
         print "stop channel B"
         self.setDirection('B',0);
         PWM.add_channel_pulse(self.B_CHANNEL,self.BENBL_Pin,0,0);
开发者ID:haomen,项目名称:rbot,代码行数:9,代码来源:motor.py

示例11: configureRPIO

def configureRPIO():
    PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
    RPIO.setwarnings(False)
    RPIO.setup(R, RPIO.OUT)
    RPIO.setup(A, RPIO.OUT)
    RPIO.setup(G, RPIO.OUT)
    RPIO.output(R, False)
    RPIO.output(A, False)
    RPIO.output(G, False)
开发者ID:enekochan,项目名称:piStopCpuLoad,代码行数:9,代码来源:piStopCpuLoadPwm.py

示例12: note

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,代码行数:9,代码来源:SunGuitar.py

示例13: __init__

    def __init__(self):
        from RPIO import PWM
        # Defaults for PWM.Servo, but we need to work with them
        self._subcycle_time_us = 20000
        self._pulse_incr_us = 10

        PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
        self._servo = PWM.Servo(
            subcycle_time_us = self._subcycle_time_us,
            pulse_incr_us = self._pulse_incr_us)
开发者ID:petli,项目名称:codplayer,代码行数:10,代码来源:lcd.py

示例14: updatecolor

def updatecolor (led_int, led_red, led_green, led_blue):
    time.sleep(1)
    PWM.clear_channel(0)
    print('Set color using MOOD %1d: Intensity: %1d | Red: %1d | Green: %1d | Blue: %1d' % (mood, led_int, led_red, led_green, led_blue))
    time.sleep(1)
    PWM.add_channel_pulse(0, LI_PIN, 0, led_int)
    PWM.add_channel_pulse(0, LR_PIN, 0, led_red)
    PWM.add_channel_pulse(0, LG_PIN, 0, led_green)
    PWM.add_channel_pulse(0, LB_PIN, 0, led_blue)
    return
开发者ID:Tomasusan,项目名称:Thomas.Brijs,代码行数:10,代码来源:moodswitch.py

示例15: to_bottom

def to_bottom():
        global pos_y
	global step
        read_pos()
        pos_y = int(pos_y) + int(step)
        pos = open(pos_file_y,"w")
        pos.write(str(pos_y))
        pos.close()
        PWM.add_channel_pulse(0, 4, 0, pos_y)
	sleep(1)
开发者ID:Goldorhack,项目名称:HackPiBot,代码行数:10,代码来源:move_function.py


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