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


Python GPIO.setwarnings方法代码示例

本文整理汇总了Python中RPi.GPIO.setwarnings方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.setwarnings方法的具体用法?Python GPIO.setwarnings怎么用?Python GPIO.setwarnings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RPi.GPIO的用法示例。


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

示例1: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def __init__(self):
        GPIO.setmode(GPIO.BOARD)
        GPIO.setwarnings(False)

        GPIO.setup(self.MotorFront1, GPIO.OUT)
        GPIO.setup(self.MotorFront2, GPIO.OUT)
        GPIO.setup(self.MotorFront, GPIO.OUT)
        GPIO.output(self.MotorFront, 0)

        GPIO.setup(self.MotorBack1, GPIO.OUT)
        GPIO.setup(self.MotorBack2, GPIO.OUT)
        GPIO.setup(self.MotorBack, GPIO.OUT)
        GPIO.output(self.MotorBack, 0)
        self.BackPWM = GPIO.PWM(self.MotorBack,100)
        self.BackPWM.start(0)
        self.BackPWM.ChangeDutyCycle(0)
        
        self.direction = 0 
开发者ID:yazeedalrubyli,项目名称:SDRC,代码行数:20,代码来源:drive.py

示例2: InitHardware

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def InitHardware(self):

        # NOTE: This function assumes the underlying hardware is the LTE Cat 1 Pi Hat
        # http://wiki.seeedstudio.com/LTE_Cat_1_Pi_HAT/

        try:
            self.power_pin = 29
            self.reset_pin = 31
            GPIO.setmode(GPIO.BOARD)
            GPIO.setwarnings(False)
            GPIO.setup(self.power_pin, GPIO.OUT) # Setup module power pin
            GPIO.setup(self.reset_pin, GPIO.OUT) # Setup module reset pin
            GPIO.output(self.power_pin, False)
            GPIO.output(self.reset_pin, False)

            return self.PowerUp()
        except Exception as e1:
            self.LogErrorLine("Error in LTEPiHat:InitHardware: " + str(e1))
            return False
    #------------------LTEPiHat::PowerDown------------------------------------- 
开发者ID:jgyates,项目名称:genmon,代码行数:22,代码来源:mymodem.py

示例3: saks_gpio_init

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.LOW)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
开发者ID:spoonysonny,项目名称:SAKS-SDK,代码行数:21,代码来源:sakshat.py

示例4: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def setup():
    """Setup piezo buzzer."""
    global _is_setup, pwm

    if _is_setup:
        return

    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(BUZZER, GPIO.OUT)

    # Set up the PWM and then set the pin to input
    # to prevent the signal from being output.
    # Since starting/stopping PWM causes a segfault,
    # this is the only way to manage the buzzer.

    pwm = GPIO.PWM(BUZZER, 1)
    GPIO.setup(BUZZER, GPIO.IN)
    pwm.start(50)

    _is_setup = True 
开发者ID:pimoroni,项目名称:rainbow-hat,代码行数:23,代码来源:buzzer.py

示例5: show

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def show():
    """Output the buffer."""
    global _gpio_setup

    if not _gpio_setup:
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup([DAT, CLK, CS], GPIO.OUT)
        _gpio_setup = True

    GPIO.output(CS, 0)
    _sof()

    for pixel in pixels:
        r, g, b, brightness = pixel
        _write_byte(0b11100000 | brightness)
        _write_byte(b)
        _write_byte(g)
        _write_byte(r)

    _eof()
    GPIO.output(CS, 1) 
开发者ID:pimoroni,项目名称:rainbow-hat,代码行数:24,代码来源:apa102.py

示例6: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def __init__(self,
                 channel,
                 polarity=GPIO.FALLING,
                 pull_up_down=GPIO.PUD_UP,
                 debounce_time=0.08):
        if polarity not in [GPIO.FALLING, GPIO.RISING]:
            raise ValueError(
                'polarity must be one of: GPIO.FALLING or GPIO.RISING')

        self.channel = int(channel)
        self.polarity = polarity
        self.expected_value = polarity == GPIO.RISING
        self.debounce_time = debounce_time

        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(channel, GPIO.IN, pull_up_down=pull_up_down)

        self.callback = None 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:21,代码来源:_button.py

示例7: init_process

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def init_process():
	print " "
	print "MSG - [S100, T110 CO2 Sensor Driver on RASPI2, Please check log file : ", LOG_PATH
	print "MSG - now starting to read SERIAL PORT"
	print " "
	# HW setup, GPIO
	GPIO.setwarnings(False)
	GPIO.cleanup()
	GPIO.setmode(GPIO.BCM)
	GPIO.setup(18, GPIO.OUT)
	GPIO.setup(23, GPIO.OUT)
	GPIO.setup(24, GPIO.OUT)
	GPIO.setup(25, GPIO.OUT)
	logger.info(' *start* GPIO all set, trying to open serial port, SW starting ')
	rledAllOn()

######################################################################
# START Here. Main
######################################################################

# set logger file 
开发者ID:jeonghoonkang,项目名称:BerePi,代码行数:23,代码来源:co2_t110.py

示例8: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def setup():
    global _is_setup

    if _is_setup:
        return True

    atexit.register(_exit)

    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup([DAT, CLK], GPIO.OUT)
    GPIO.setup(BUTTONS, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    for button in BUTTONS:
        GPIO.add_event_detect(button, GPIO.FALLING, callback=_handle_button, bouncetime=200)

    _is_setup = True 
开发者ID:pimoroni,项目名称:phat-beat,代码行数:19,代码来源:__init__.py

示例9: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def __init__(self):
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)

        lock = Lock()

        self.publish_io_state_frequency = rospy.get_param("~publish_io_state_frequency")
        self.digitalIOs = [DigitalPin(lock, GPIO_1_A, GPIO_1_A_NAME), DigitalPin(lock, GPIO_1_B, GPIO_1_B_NAME),
                           DigitalPin(lock, GPIO_1_C, GPIO_1_C_NAME),
                           DigitalPin(lock, GPIO_2_A, GPIO_2_A_NAME), DigitalPin(lock, GPIO_2_B, GPIO_2_B_NAME),
                           DigitalPin(lock, GPIO_2_C, GPIO_2_C_NAME),
                           DigitalPin(lock, SW_1, SW_1_NAME, mode=GPIO.OUT),
                           DigitalPin(lock, SW_2, SW_2_NAME, mode=GPIO.OUT)]

        self.digital_io_publisher = rospy.Publisher('niryo_one/rpi/digital_io_state', DigitalIOState, queue_size=1)
        rospy.Timer(rospy.Duration(1.0 / self.publish_io_state_frequency), self.publish_io_state)

        self.get_io_server = rospy.Service('niryo_one/rpi/get_digital_io', GetDigitalIO, self.callback_get_io)
        self.set_io_mode_server = rospy.Service('niryo_one/rpi/set_digital_io_mode', SetDigitalIO,
                                                self.callback_set_io_mode)
        self.set_io_state_server = rospy.Service('niryo_one/rpi/set_digital_io_state', SetDigitalIO,
                                                 self.callback_set_io_state) 
开发者ID:NiryoRobotics,项目名称:niryo_one_ros,代码行数:24,代码来源:digital_io_panel.py

示例10: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def __init__(self):
        # Set warning false, and don't cleanup LED GPIO after exit
        # So the LED will be red only after the Rpi is shutdown
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(LED_GPIO_R, GPIO.OUT)
        GPIO.setup(LED_GPIO_G, GPIO.OUT)
        GPIO.setup(LED_GPIO_B, GPIO.OUT)

        rospy.sleep(0.1)
        self.state = LedState.OK
        self.set_led_from_state(dxl_leds=True)

        self.set_led_state_server = rospy.Service('/niryo_one/rpi/set_led_state',
                                                  SetInt, self.callback_set_led_state)

        # Subscribe to hotspot and hardware status. Those values will override standard states
        self.hotspot_state_subscriber = rospy.Subscriber('/niryo_one/wifi/hotspot',
                                                         Bool, self.callback_hotspot_state)

        self.hardware_status_subscriber = rospy.Subscriber('/niryo_one/hardware_status',
                                                           HardwareStatus, self.callback_hardware_status)

        rospy.loginfo('LED manager has been started.') 
开发者ID:NiryoRobotics,项目名称:niryo_one_ros,代码行数:27,代码来源:led_manager.py

示例11: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def __init__(self, red_led=23, green_led=27, blue_led=22 ):
		self.red_led = red_led
		self.green_led = green_led
		self.blue_led = blue_led

		# Set up status LEDS
                GPIO.setmode(GPIO.BCM)
		GPIO.setwarnings(False)
		if self.red_led > 0:
			GPIO.setup(self.red_led, GPIO.OUT)
		if self.blue_led > 0:
			GPIO.setup(self.blue_led, GPIO.OUT)
		if self.green_led > 0:
			GPIO.setup(self.green_led, GPIO.OUT)
                return

	# Set the status to normal, busy, error or clear 
开发者ID:bobrathbone,项目名称:piradio,代码行数:19,代码来源:status_led_class.py

示例12: run

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def run(self):
		global remote_led
		global udpport
		global udphost
		log.init('radio')
		progcall = str(sys.argv)
		log.message(progcall, log.DEBUG)
		log.message('Remote control running pid ' + str(os.getpid()), log.INFO)
		signal.signal(signal.SIGHUP,signalHandler)
		exec_cmd('sudo service lirc start')		

		remote_led = config.getRemoteLed()
		if remote_led > 0:
			GPIO.setwarnings(False)      # Disable warnings
			GPIO.setmode(GPIO.BCM)       # Use BCM GPIO numbers
			GPIO.setup(remote_led, GPIO.OUT)  # Output LED
			flash_led(remote_led)
		else:
			log.message("Remote control LED disabled", log.DEBUG)
		udpport = config.getRemoteUdpPort()
		udphost = config.getRemoteUdpHost()
		log.message("UDP connect host " + udphost + " port " + str(udpport), log.DEBUG)
		listener() 
开发者ID:bobrathbone,项目名称:piradio,代码行数:25,代码来源:remote_control.py

示例13: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def __init__(self, dout=5, pd_sck=6, gain=128, bitsToRead=24):
        self.PD_SCK = pd_sck
        self.DOUT = dout

        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.PD_SCK, GPIO.OUT)
        GPIO.setup(self.DOUT, GPIO.IN)

        # The value returned by the hx711 that corresponds to your
        # reference unit AFTER dividing by the SCALE.
        self.REFERENCE_UNIT = 1

        self.GAIN = 0
        self.OFFSET = 1
        self.lastVal = 0
        self.bitsToRead = bitsToRead
        self.twosComplementThreshold = 1 << (bitsToRead-1)
        self.twosComplementOffset = -(1 << (bitsToRead))
        self.setGain(gain)
        self.read() 
开发者ID:dcrystalj,项目名称:hx711py3,代码行数:23,代码来源:hx711.py

示例14: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def __init__(self, config):

        # Config
        self.relay_pin = config['relay']
        self.state_pin = config['state']
        self.id = config['id']
        self.mode = int(config.get('state_mode') == 'normally_closed')
        self.invert_relay = bool(config.get('invert_relay'))

        # Setup
        self._state = None
        self.onStateChange = EventHook()

        # Set relay pin to output, state pin to input, and add a change listener to the state pin
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.relay_pin, GPIO.OUT)
        GPIO.setup(self.state_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.add_event_detect(self.state_pin, GPIO.BOTH, callback=self.__stateChanged, bouncetime=300)


        # Set default relay state to false (off)
        GPIO.output(self.relay_pin, self.invert_relay)

    # Release rpi resources 
开发者ID:Jerrkawz,项目名称:GarageQTPi,代码行数:27,代码来源:garage.py

示例15: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import setwarnings [as 别名]
def __init__(self):
        self.__RESET = 26

        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)

        GPIO.setup(self.__RESET, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        # Do not proceed unless the reset signal has turned off
        # attempt to prevent restart storm in systemd

        print("waiting for reset to complete.")
        while GPIO.input(self.__RESET) != 1:
            time.sleep(0.100)
            pass

        GPIO.add_event_detect(
            self.__RESET, GPIO.FALLING, callback=onReset, bouncetime=100
        )
        print("GPIO initialized.") 
开发者ID:jedimatt42,项目名称:tipi,代码行数:21,代码来源:TipiWatchDogService.py


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