本文整理汇总了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)
示例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);
示例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)
示例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()
示例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)
示例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)
示例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
示例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)
示例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
示例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);
示例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)
示例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)
示例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)
示例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
示例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)