本文整理汇总了Python中RPIO.PWM.init_channel方法的典型用法代码示例。如果您正苦于以下问题:Python PWM.init_channel方法的具体用法?Python PWM.init_channel怎么用?Python PWM.init_channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RPIO.PWM
的用法示例。
在下文中一共展示了PWM.init_channel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
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)
示例2: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def __init__(self, pin, location, rotation, name):
#---------------------------------------------------------------------------
# The GPIO BCM numbered pin providing PWM signal for this ESC
#---------------------------------------------------------------------------
self.bcm_pin = pin
#---------------------------------------------------------------------------
# The location on the quad, and the direction of the motor controlled by this ESC
#---------------------------------------------------------------------------
self.motor_location = location
self.motor_rotation = rotation
#---------------------------------------------------------------------------
# The PWM pulse width range required by this ESC in microseconds
#---------------------------------------------------------------------------
self.min_pulse_width = 1000
self.max_pulse_width = 2000
#---------------------------------------------------------------------------
# The PWM pulse range required by this ESC
#---------------------------------------------------------------------------
self.current_pulse_width = self.min_pulse_width
self.name = name
#---------------------------------------------------------------------------
# Initialize the RPIO DMA PWM
#---------------------------------------------------------------------------
if not PWM.is_setup():
PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
PWM.setup(1) # 1us increment
PWM.init_channel(RPIO_DMA_CHANNEL, 3000) # 3ms carrier period
PWM.add_channel_pulse(RPIO_DMA_CHANNEL, self.bcm_pin, 0, self.current_pulse_width)
示例3: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def __init__(self):
"""Initialise movement."""
PWM.setup()
#get rid of debug output
PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
#pins
#i2c pins can be enabled high at boot - see http://www.raspberrypi.org/phpBB3/viewtopic.php?f=44&t=35321
self._l_enable_pin = 4
self._l_forward_pin = 3
self._l_backward_pin = 2
self._r_enable_pin = 17
self._r_forward_pin = 27
self._r_backward_pin = 22
#constants
self.LEFT = 1
self.RIGHT = 2
#setup the pins
RPIO.setup(self._l_forward_pin, RPIO.OUT)
RPIO.setup(self._r_forward_pin, RPIO.OUT)
RPIO.setup(self._l_backward_pin, RPIO.OUT)
RPIO.setup(self._r_backward_pin, RPIO.OUT)
#pwm setup
self._dma_l = 0
self._dma_r = 1
PWM.init_channel(self._dma_l)
PWM.init_channel(self._dma_r)
#this is silly, but otherwise pwm will complain if we try and clear a channel that hasn't been already used
PWM.add_channel_pulse(self._dma_l,self._l_enable_pin,0,0)
PWM.add_channel_pulse(self._dma_r,self._r_enable_pin,0,0)
示例4: setup
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def setup():
PWM.setup()
PWM.init_channel(DMA_LEFT,10000)
PWM.init_channel(DMA_RIGHT,10000)
PWM.add_channel_pulse(DMA_LEFT, LEFT_FORWARD, 0, 0)
PWM.add_channel_pulse(DMA_LEFT, LEFT_BACKWARD, 0, 0)
PWM.add_channel_pulse(DMA_RIGHT, RIGHT_FORWARD, 0, 0)
PWM.add_channel_pulse(DMA_RIGHT, RIGHT_BACKWARD, 0, 0)
示例5: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def __init__(self, gpioPin):
# RPIO PWM initalization
if PWM.is_setup() == 0:
PWM.setup(pulse_incr_us=self.pulseIncrementUs)
self.gpioPin = gpioPin
self.dutyCycle = self.initialpulsewidth
self.pwmChannel = self.getFreePwmChannel()
PWM.init_channel(self.pwmChannel, subcycle_time_us=self.subCycleTime)
示例6: initMotor
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def initMotor(self):
RPIO.setup(self.MODE_Pin,RPIO.OUT,initial=RPIO.HIGH); #select PWM Mode;
PWM.setup(); #initialize channel 0 and 1 for motor A and B
PWM.init_channel(self.A_CHANNEL);
PWM.init_channel(self.B_CHANNEL);
RPIO.setup(self.APHASE_Pin,RPIO.OUT,initial=RPIO.LOW); #default A to fwd direction
PWM.add_channel_pulse(self.A_CHANNEL,self.AENBL_Pin,0,0);#default A to channel 0 and speed 0
RPIO.setup(self.BPHASE_Pin,RPIO.OUT,initial=RPIO.LOW); #default B to fwd direction
PWM.add_channel_pulse(self.B_CHANNEL,self.BENBL_Pin,0,0);#default B to channel 1 and speed 0
示例7: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def __init__(self, pins):
"""Pin configuration.
[pins] : List of the the pins to use for R,G and B (GPIO.BCM numbering). """
pins = [int(pin) for pin in pins.split(",")]
if not len(pins) == 3:
raise ValueError("Configuration must contain three pins (pins=" + str(pins) + ")")
self._pins = pins
# PWM setup
PWM.setup(pulse_incr_us=PWM_RES)
PWM.init_channel(PWM_DMA, subcycle_time_us=PWM_PRD)
PWM.init_channel(PWM_DMA1, subcycle_time_us=PWM_PRD1)
示例8: initialize
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def initialize(self):
# Setup PWM if backlight is defined
if self.__backlight:
PWM.setup()
PWM.init_channel(0)
self.enableBacklight()
# Setup rs, enable and rw pins
GPIO.setup(self.__rs, GPIO.OUT)
GPIO.setup(self.__enable, GPIO.OUT)
if self.__rw:
GPIO.setup(self.__rw, GPIO.OUT)
示例9: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def __init__(self, redPin, greenPin, bluePin):
if not PWM.is_setup():
PWM.setup(10,1)
self.pins = [redPin, greenPin, bluePin]
a=2
while PWM.is_channel_initialized(a):
a=a+1
self.channels = [a, a+1, a+2]
for channel_num in self.channels:
PWM.init_channel(channel_num, subcycle_time_us=10000)
示例10: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def __init__(self, gpio=18, period=20000, ch_count=6):
self.gpio = gpio
self.period = period
self.channel_count = ch_count
self.control_ppm = PWM.Servo()
PWM.setup()
# add channels and set init value as 150
for ch in range(1, self.channel_count):
PWM.init_channel(ch, self.period)
PWM.add_channel_pulse(ch, self.gpio, self.default_channel_width, self.default_channel_value)
self.default_channel_value.insert(ch, self.default_channel_value)
示例11: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def __init__(self, channel=PWM_CHANNEL, pin=PWM_PIN, subcycle=PWM_SUBCYCLE, unit=PWM_UNIT):
self._channel = channel
self._pin = pin
self._subcycle = subcycle
self._range = int(subcycle / unit)
if not PWM.is_setup():
PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
PWM.setup()
# work around bug in RPIO.PWM, https://www.raspberrypi.org/forums/viewtopic.php?p=509549
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
if not PWM.is_channel_initialized(self._channel):
PWM.init_channel(self._channel, self._subcycle)
示例12: set_brightness
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def set_brightness(self, percent):
# Make our percentage logarithmic from 0 to 100 for a more natural brightness curve
percent = (float(percent)/10)**2
# Divide the 20ms period into 4 pulses so we get 200Hz
# pulse width in 10us increments.
pulse_width = int((100-percent) * 5)
if (not PWM.is_setup()):
PWM.setup()
PWM.init_channel(0)
PWM.add_channel_pulse(0, self.lcd_backlight, start=0, width=pulse_width)
PWM.add_channel_pulse(0, self.lcd_backlight, start=499, width=pulse_width)
PWM.add_channel_pulse(0, self.lcd_backlight, start=999, width=pulse_width)
PWM.add_channel_pulse(0, self.lcd_backlight, start=1499, width=pulse_width)
示例13: pwm_example2
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [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()
示例14: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
def __init__(self):
PWM.cleanup()
PWM.setup(1)
PWM.init_channel(1, 5000)
PWM.init_channel(2, 5000)
PWM.init_channel(3, 5000)
self.r = 0
self.g = 0
self.b = 0
self.dimFactor = 1.
self.fadeTimer = None
self.fadeCallback = None
self.fadeStartTime = datetime.now()
self.fadeSeconds = None
示例15: GPIO
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import init_channel [as 别名]
#pulse_start = [200, 20, 50, 100] #_start=200*100 microsec=20 msec.
#pulse_width = [100, 500, 1000, 5000] #_width=100*100 microsec=10 msec.
pulse_start = [0, 0, 0, 0] #_start=0*10 microsec=0 msec.
pulse_width = [0, 0, 0, 0] #_width=0*10 microsec=0 msec.
#incr_impulso = [10, 10, 10, 10]
canale_dma = [0, 1, 2, 3] #ce ne sono 15 (0-14)
gpio_port = [18, 23, 24, 25] #porte GPIO (lato pin pari)
#frequency = [500, 50, 2, 1] #in Hz
#set della granularity (è il default durante l'inizializzazione tic di incremento in microsecondi)
PWM.setup(granularity, 0) #default: pulse_incr_us=10, delay_hw=0
for i in canale_dma:
PWM.init_channel(i, subcycle_time[i]) #canale DMA con tempo subcycle
# PWM.setup(granularity, 0) #default: pulse_incr_us=10, delay_hw=0
#aggiungo un impulso nel canale DMA all'interno di ogni subcycle per ogni GPIO
#POSSO ANCHE NON AGGIUNGERE NIENTE :-), VOLENDO.
PWM.add_channel_pulse(i, gpio_port[i], pulse_start[i], pulse_width[i])
#setup per output su GPIO
for i in gpio_port:
RPIO.setup(i, RPIO.OUT)
for i in canale_dma:
PWM.print_channel(i)
if PWM.is_channel_initialized(i):
print ("canale ", i, " inizializzato")
else:
print ("canale ", i, " NON inizializzato")
if PWM.is_setup():