本文整理汇总了Python中RPIO.PWM.is_setup方法的典型用法代码示例。如果您正苦于以下问题:Python PWM.is_setup方法的具体用法?Python PWM.is_setup怎么用?Python PWM.is_setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RPIO.PWM
的用法示例。
在下文中一共展示了PWM.is_setup方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [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)
示例2: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [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)
示例3: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [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)
示例4: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [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)
示例5: set_brightness
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [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)
示例6: print
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [as 别名]
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():
print ("setup canale ", i, "chiamato")
else:
print ("setup canale ", i, " NON chiamato")
try:
while True:
# LED per vedere se tutto funziona
for t in led_time:
for i in gpio_port:
RPIO.output(i, RPIO.HIGH)
sleep(t)
RPIO.output(i, RPIO.LOW)
sleep(t)
for d in canale_dma:
subcycle_T = PWM.get_channel_subcycle_time_us(d)
示例7: RPIOHelper
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [as 别名]
"""
Until someone builds a good RPIO library for Node, I will be using
"""
import zerorpc
from RPIO import PWM
if not PWM.is_setup():
PWM.setup(pulse_incr_us=1)
PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
PWM.init_channel(1,3000)
class RPIOHelper(object):
def addChannelPulse(self, gpio, rate):
PWM.add_channel_pulse(1, gpio, 0, int(rate))
s = zerorpc.Server(RPIOHelper())
s.bind("tcp://0.0.0.0:4242")
s.run()
示例8: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [as 别名]
def __init__(self):
if not PWM.is_setup():
PWM.setup() #put this in def __init__():
示例9: trying
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import is_setup [as 别名]
def trying(event):
if event.type == pygame.JOYBUTTONDOWN:
if event.button == PS3_BUTTON_SELECT:
#do something
print
elif event.button == PS3_BUTTON_START:
#do something
print
elif event.button == PS3_BUTTON_TRI:
#shut down the motors and and shut down the system (power off.)
stop()
p.stop()
os.system('sudo poweroff')
elif event.button == PS3_BUTTON_X:
#run clockwise function
counter_clockwise()
print 'back'
elif event.button == PS3_BUTTON_SQUARE:
#stop motor 1
print 'stop'
stop()
elif event.button == PS3_BUTTON_UP:
#reboot the system
os.system('sudo reboot')
if event.type == pygame.JOYAXISMOTION:
if event.axis == PS3_AXIS_LEFT_VERTICAL:
#This is used to control the forwards and backwards movement.
#if event.value>=.24:
# print 'stop'
# stop()
if event.value>=threshold:
clockwise()
speed=int(event.value*100)
p.ChangeDutyCycle(speed)
if event.value>=-.24:
if event.value<0:
stop()
elif event.value<=-threshold:
counter_clockwise()
speed=-1*(int(event.value*100))
p.ChangeDutyCycle(speed)
elif event.axis == PS3_AXIS_RIGHT_HORIZONTAL:
#This is used to control the left and right movement.
if event.value>=threshold:
clockwise1()
speed=int(event.value*500)
if PWM.is_setup() == 1:
#set up the pwm to be set out.
PWM.add_channel_pulse(0,22,0,speed)
else:
PWM.setup()
PWM.init_channel(0)
PWM.add_channel_pulse(0,22,0,speed)
if event.value>=-.24:
if event.value<0:
stop1()
elif event.value<=-threshold:
counter_clockwise1()
speed=-1*(int(event.value*500))
if PWM.is_setup() == 1:
#set up pwm
PWM.add_channel_pulse(0,22,0,speed)
else:
PWM.setup()
PWM.init_channel(0)
PWM.add_channel_pulse(0,22,0,speed)