本文整理汇总了Python中RPIO.PWM.set_loglevel方法的典型用法代码示例。如果您正苦于以下问题:Python PWM.set_loglevel方法的具体用法?Python PWM.set_loglevel怎么用?Python PWM.set_loglevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RPIO.PWM
的用法示例。
在下文中一共展示了PWM.set_loglevel方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [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)
示例2: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [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 set_loglevel [as 别名]
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()
示例4: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
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
示例5: configureRPIO
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
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)
示例6: __enter__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
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
示例7: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
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)
示例8: __init__
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [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)
示例9: decode_color
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
#!/usr/bin/env python
import logging
import RPIO, time, os
from RPIO import PWM
import requests
import sys
import threading
import time
logging.basicConfig(level=logging.WARN)
PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)
RPIO.setmode(RPIO.BCM)
servo = None
def decode_color(color):
if color.endswith('anime'):
return 0
elif color == 'blue':
return 1
else:
return -1
def get_config():
return { 'examplesvc' : {
'button' : 17,
'led' : 0,#4,
'status_url': "http://maria.saymedia.com/job/examplesvc/job/master/api/json?tree=color",
'action_url': "http://maria.saymedia.com/job/examplesvc/job/test-ci/build?delay=0sec"
}
}
示例10: sensors
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
# NOTE: SOME ERRORS MIGHT STILL COME FROM mysensors.get_sensor()
# ESPECIALLY: SOME ABBORT-CRITERIA ARE DIFFICULT....
#
# NOTE: No-Echo-In-Result will be returned, but not saved,
# Out-Of-Sight-Result will be returned & saved
# Wrong-Sensor-Number-Error will be returned, but not saved
from __main__ import lg # for output-control
import time
import threading
import RPi.GPIO as GPIO
from RPIO import PWM
servo = PWM.Servo()
PWM.set_loglevel(1) # try to stop debug output
class sensors(threading.Thread):
def __init__(self, mode=0, start=False, sensors_min=7): # ignore sensor-values below sensors_min
self.lock = threading.Lock()
# initialize background-thread (not yet started)
threading.Thread.__init__(self)
# set thread-mode (if background-thread is started)
# mode: 0 = update all sensors in cycle 0-1-2-1-0-1-2-1-0-..., servo not moved
# 1 = scanning all sensors in cycle 0-1-2-1-0-1-2-1-0-..., servo scans: from left to right to left to right...
# 2 = scanning all sensors in cycle 0-1-2-1-0-1-2-1-0-..., servo scans: from left to right jump, form left to right, ...
# 3 = like mode 2, but averaging over two measurements
self.mode = mode
示例11: changespeed
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
#!/usr/bin/env python
import RPIO
from RPIO import PWM as PWM
import time
RPIO.setmode(RPIO.BOARD)
GPIO = 12
CHANNEL = 1
RPIO.setup(GPIO,RPIO.OUT)
# Setup PWM and DMA channel 0
PWM.set_loglevel(PWM.LOG_LEVEL_DEBUG)
PWM.setup()
PWM.init_channel(CHANNEL,20000)
PWM.print_channel(CHANNEL)
RPIO.output(GPIO, False)
def changespeed(current_speed,set_speed,step_size,delay):
for counter in range (current_speed, set_speed, step_size):
pwmmotor=int(round(counter*199,-1))
print(pwmmotor)
PWM.add_channel_pulse(CHANNEL,GPIO,0,pwmmotor)
time.sleep(delay)
# Add some pulses to the subcycle
PWM.add_channel_pulse(CHANNEL, GPIO, 0, 0)
示例12: pwm_setup
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
def pwm_setup():
pwm.set_loglevel(pwm.LOG_LEVEL_ERRORS)
pwm.setup(5)
pwm.init_channel(0, 5000)
示例13: io_init
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import set_loglevel [as 别名]
def io_init():
PWM.setup()
PWM.set_loglevel(PWM.LOG_LEVEL_ERRORS)