Python RPi.GPIO 模块,setwarnings() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用RPi.GPIO.setwarnings()

项目:rainbow-hat    作者:pimoroni    | 项目源码 | 文件源码
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)
项目:waterflowers    作者:chaodalong    | 项目源码 | 文件源码
def send_gpio_order(param):
    """
    GPIO????
    type in(GPIO.IN) out(GPIO.OUT)
    value 1 GPIO.HIGH 0 GPIO.LOW
    :param param:
    :return:
    """
    print param
    channel, type, value = param
    try:
        import RPi.GPIO as GPIO
    except RuntimeError:
        print("????")
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)

    if type == 'in':
        GPIO.setup(channel, GPIO.IN)
        GPIO.input(channel, value)
    else:
        GPIO.setup(channel, GPIO.OUT)
        GPIO.output(channel, value)
项目:BH1750    作者:ElJulio    | 项目源码 | 文件源码
def init(self,bitrate,SDAPIN,SCLPIN):
        if(SDAPIN != SCLPIN):
            self.SCL = SCLPIN
            self.SDA = SDAPIN

        else:
            print "SDA = GPIO"+str(self.SDA)+"  SCL = GPIO"+str(self.SCL)

        #configer SCL as output
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup(self.SCL, GPIO.OUT)
        GPIO.setup(self.SDA, GPIO.OUT)
        GPIO.output(self.SDA, GPIO.HIGH)
        GPIO.output(self.SCL, GPIO.HIGH)


        if bitrate == 100:
            self.int_clk = 0.0000025
        elif bitrate == 400:
            self.int_clk = 0.000000625
        elif bitrate == 1000:
            self.int_clk = 1
        elif bitrate == 3200:
            self.int_clk = 1
项目:burro    作者:yconst    | 项目源码 | 文件源码
def __init__(self, channel, invert=False):
        from navio import adafruit_pwm_servo_driver as pwm
        from navio import util
        import RPi.GPIO as GPIO
        util.check_apm()

        #Navio+ requires the GPIO line 27 to be set to low 
        #before the PCA9685 is accesed 
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(27, GPIO.OUT)
        GPIO.output(27,GPIO.LOW)

        #GPIO.cleanup()
        self.frequency = 60
        self.channel = channel
        self.invert = invert
        self.pwm = pwm.PWM()
        self.pwm.setPWMFreq(self.frequency)
项目:red-phone    作者:mixmasteru    | 项目源码 | 文件源码
def __init__(self, ready):
        Thread.__init__(self)
        self.ready = ready
        self.picked_up = False
        self.on = True
        self._ringer1 = 11
        self._ringer2 = 13
        self._button = 7

        GPIO.setmode(GPIO.BOARD)
        GPIO.setwarnings(False)
        GPIO.setup(self._ringer1, GPIO.OUT)
        GPIO.output(self._ringer1, GPIO.LOW)
        GPIO.setup(self._ringer2, GPIO.OUT)
        GPIO.output(self._ringer2, GPIO.LOW)
        GPIO.setup(self._button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

        self._last_state = 0
        self._last_ts = time.time()
        self._last_check = time.time()
        self._ring = 1
        self.max_ring_cnt = 2
项目:raspberry-gpio-emulator    作者:nosix    | 项目源码 | 文件源码
def main():
    import RPi.GPIO as GPIO
    import time

    try:
        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(18, GPIO.OUT)
        GPIO.setup(27, GPIO.IN)

        while True:
            time.sleep(1)
    finally:
        GPIO.cleanup()
项目:raspberry-gpio-emulator    作者:nosix    | 项目源码 | 文件源码
def main():
    import RPi.GPIO as GPIO
    import time

    try:
        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(18, GPIO.OUT)
        GPIO.setup(27, GPIO.IN)

        while True:
            time.sleep(1)
    finally:
        GPIO.cleanup()
项目:pimaa    作者:outboxafrica    | 项目源码 | 文件源码
def __init__(self, data):
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        self.SPIMOSI = 23
        self.SPIMISO = 24
        self.SPICLK = 18
        self.SPICS = 25
        if "mosiPin" in data:
            self.SPIMOSI = data["mosiPin"]
        if "misoPin" in data:
            self.SPIMISO = data["misoPin"]
        if "clkPin" in data:
            self.SPICLK = data["clkPin"]
        if "csPin" in data:
            self.SPICS = data["csPin"] 
        GPIO.setup(self.SPIMOSI, GPIO.OUT)
        GPIO.setup(self.SPIMISO, GPIO.IN)
        GPIO.setup(self.SPICLK, GPIO.OUT)
        GPIO.setup(self.SPICS, GPIO.OUT)
        if MCP3008.sharedClass == None:
            MCP3008.sharedClass = self

    #read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)
项目:kalliope    作者:kalliope-project    | 项目源码 | 文件源码
def __init__(self, rpi_settings=None, callback=None):
        """
        Class used to:
        - manage RPI GPIO
        - thread to catch mute button signal
        The object receive a rpi settings object which contains pin number to use on the Rpi
        When a signal is caught form the mute button, the callback method from the main controller is called
        :param rpi_settings: Settings object with GPIO pin number to use
        :type rpi_settings: RpiSettings
        :param callback: Callback function from the main controller to call when the mute button is pressed
        """
        super(RpiUtils, self).__init__()
        GPIO.setmode(GPIO.BCM)  # Use GPIO name
        GPIO.setwarnings(False)
        self.rpi_settings = rpi_settings
        self.callback = callback
        self.init_gpio(self.rpi_settings)
项目:rpi.rtc    作者:sourceperl    | 项目源码 | 文件源码
def __init__(self, clk_pin=11, data_pin=13, ce_pin=15):
        # init GPIO
        # no warnings
        GPIO.setwarnings(False)
        # use safer pin number (avoid GPIO renumber on each Pi release)
        GPIO.setmode(GPIO.BOARD)
        # set GPIO pins
        self._clk_pin = clk_pin
        self._data_pin = data_pin
        self._ce_pin = ce_pin
        # CLK and CE (sometime call RST) pin are always output
        GPIO.setup(self._clk_pin, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(self._ce_pin, GPIO.OUT, initial=GPIO.LOW)
        # turn off WP (write protect)
        self._start_tx()
        self._w_byte(0x8e)
        self._w_byte(0x00)
        self._end_tx()
        # charge mode is disabled
        self._start_tx()
        self._w_byte(0x90)
        self._w_byte(0x00)
        self._end_tx()
项目:Venenfinder    作者:Myrijam    | 项目源码 | 文件源码
def __init__(self,pinA,pinB,callback):
      self.pinA = pinA
      self.pinB = pinB
      #self.button = button
      self.callback = callback
      GPIO.setmode(GPIO.BCM)
      # The following lines enable the internal pull-up resistors
      # on version 2 (latest) boards
      GPIO.setwarnings(False)
      GPIO.setup(self.pinA, GPIO.IN, pull_up_down=GPIO.PUD_UP)
      GPIO.setup(self.pinB, GPIO.IN, pull_up_down=GPIO.PUD_UP)
      #GPIO.setup(self.button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
      # For version 1 (old) boards comment out the above four lines
      # and un-comment the following 3 lines
      #GPIO.setup(self.pinA, GPIO.IN)
      #GPIO.setup(self.pinB, GPIO.IN)
      #GPIO.setup(self.button, GPIO.IN)
      # Add event detection to the GPIO inputs
      GPIO.add_event_detect(self.pinA, GPIO.FALLING, callback=self.switch_event)
      GPIO.add_event_detect(self.pinB, GPIO.FALLING, callback=self.switch_event)
      #GPIO.add_event_detect(self.button, GPIO.BOTH, callback=self.button_event, bouncetime=200)
      return


# Call back routine called by switch events
项目:RFExplorer-for-Python    作者:RFExplorer    | 项目源码 | 文件源码
def ResetIOT_HW(cls, bMode):
        """Set Raspberry pi GPIO pins and reset RF Explorer device

        Parameters: 
            bMode -- True if the baudrate is set to 500000bps, False to 2400bps
        """
        try:
            import RPi.GPIO as GPIO

            #print("RPi info: " + str(GPIO.RPI_INFO)) #information about your RPi:
            #print("RPi.GPio version: " + GPIO.VERSION) #version of RPi.GPIO:
            GPIO.setwarnings(False)
            GPIO.setmode(GPIO.BOARD)    #refer to the pin numbers on the P1 header of the Raspberry Pi board
            GPIO.setup(12, GPIO.OUT)    #set /reset (pin 12) to output 
            GPIO.output(12, False)      #set /reset (pin 12) to LOW
            GPIO.setup(21, GPIO.OUT)    #set GPIO2 (pin 21) to output
            GPIO.output(21, bMode)      #set GPIO2 (pin 21) to HIGH (for 500Kbps)
            time.sleep(0.1)             #wait 100ms
            GPIO.output(12, True)       #set /reset to HIGH
            time.sleep(2.5)             #wait 2.5sec
            GPIO.setup(21, GPIO.IN)     #set GPIO2 to input
            GPIO.cleanup()              #clean up GPIO channels 

        except RuntimeError:
            print("Error importing RPi.GPIO!  This is probably because you need superuser privileges.  You can achieve this by using 'sudo' to run your script")
项目:OctoPrint-LEDStripControl    作者:google    | 项目源码 | 文件源码
def _setup_pin(self, pin):
        self._logger.debug(u"_setup_pin(%s)" % (pin,))
        if pin:
            p = None

            if self._pigpiod is None:
                self._pigpiod = pigpio.pi()

            if self._settings.get_boolean(['pigpiod']):
                if not self._pigpiod.connected:
                    self._logger.error(u"Unable to communicate with PiGPIOd")
                else:
                    p = PiGPIOpin(self._pigpiod, pin, self._logger)
            else:
                GPIO.setwarnings(False)
                GPIO.setmode(GPIO.BOARD)
                GPIO.setup(pin, GPIO.OUT)
                GPIO.output(pin, GPIO.HIGH)
                p = GPIO.PWM(pin, 100)
            p.start(100)
            return p
项目:SunFounder_PiCar    作者:sunfounder    | 项目源码 | 文件源码
def __init__(self, direction_channel, pwm=None, offset=True):
        '''Init a motor on giving dir. channel and PWM channel.'''
        if self._DEBUG:
            print self._DEBUG_INFO, "Debug on"
        self.direction_channel = direction_channel
        self._pwm = pwm
        self._offset = offset
        self.forward_offset = self._offset

        self.backward_offset = not self.forward_offset
        self._speed = 0

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

        if self._DEBUG:
            print self._DEBUG_INFO, 'setup motor direction channel at', direction_channel
            print self._DEBUG_INFO, 'setup motor pwm channel as', self._pwm.__name__
        GPIO.setup(self.direction_channel, GPIO.OUT)
项目:RuneAudioLCDMod    作者:lukazgur    | 项目源码 | 文件源码
def __init__(self, button_pins, bounce_time):
        # Set bounce time
        self.bounce_time = bounce_time

        # Set buttons
        self.buttons = button_pins

        # Initialize display client
        self.display = False

        # We don't need warnings from GPIO
        GPIO.setwarnings(False)

        # Set button GPIO pins as inputs and enable interrupts
        for button in button_pins:
            if (button_pins[button] != False):
                GPIO.setup(button_pins[button], GPIO.IN, pull_up_down = GPIO.PUD_UP)
                GPIO.add_event_detect(button_pins[button], GPIO.FALLING, callback=self.button_pressed, bouncetime=self.bounce_time)

        # Initalize MPD
        self.mpd = False

    # Register MPD client to send it commands
项目:raspberry    作者:ykevin    | 项目源码 | 文件源码
def __init__(self, left_pin1, left_pin2, right_pin1, right_pin2, leftpwm_pin, rightpwm_pin):
        io.setmode(io.BCM)
        # Constant values
        self.PWM_MAX = 100
        # Here we configure the GPIO settings for the left and right motors spinning direction. 
        # It defines the four GPIO pins used as input on the L298 H-Bridge to set the motor mode (forward, reverse and stopp).
        self.leftmotor_in1_pin = left_pin1
        self.leftmotor_in2_pin = left_pin2
        self.rightmotor_in1_pin = right_pin1
        self.rightmotor_in2_pin = right_pin2
        self.leftmotorpwm_pin = leftpwm_pin
        self.rightmotorpwm_pin = rightpwm_pin
        self.SetupGPIO()
        self.leftmotorpwm = io.PWM(self.leftmotorpwm_pin,100)
        self.rightmotorpwm = io.PWM(self.rightmotorpwm_pin,100)
        self.InitPWM()
        # Disable warning from GPIO
        io.setwarnings(False)
项目:raspberry    作者:ykevin    | 项目源码 | 文件源码
def __init__(self, left_pin1, left_pin2, right_pin1, right_pin2, leftpwm_pin, rightpwm_pin):
        io.setmode(io.BCM)
        # Constant values
        self.PWM_MAX = 100
        # Here we configure the GPIO settings for the left and right motors spinning direction. 
        # It defines the four GPIO pins used as input on the L298 H-Bridge to set the motor mode (forward, reverse and stopp).
        self.leftmotor_in1_pin = left_pin1
        self.leftmotor_in2_pin = left_pin2
        self.rightmotor_in1_pin = right_pin1
        self.rightmotor_in2_pin = right_pin2
        self.leftmotorpwm_pin = leftpwm_pin
        self.rightmotorpwm_pin = rightpwm_pin
        self.SetupGPIO()
        self.leftmotorpwm = io.PWM(self.leftmotorpwm_pin,100)
        self.rightmotorpwm = io.PWM(self.rightmotorpwm_pin,100)
        self.InitPWM()
        # Disable warning from GPIO
        io.setwarnings(False)
项目:SDRC    作者:yazeedalrubyli    | 项目源码 | 文件源码
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
项目:Webradio_v2    作者:Acer54    | 项目源码 | 文件源码
def __initGPIOs(self):
        #setup GPIO using Board numbering (pins, not GPIOs)
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BOARD)

        #setup defined pins and event_detectors or outputs and initial states (initial is always 0, low)
        for pin in pins_in_use:
            if pins_in_use[pin][0] == GPIO.IN:
                if pin == 5:
                    GPIO.setup(pin, pins_in_use[pin][0], pull_up_down=GPIO.PUD_UP)
                else:
                    GPIO.setup(pin, pins_in_use[pin][0])
                GPIO.add_event_detect(pin, pins_in_use[pin][1], callback=self.shoutItOut, bouncetime=100)
                self.gpio_states.update({pin: 1})
            elif pins_in_use[pin][0] == GPIO.OUT:
                GPIO.setup(pin, pins_in_use[pin][0], initial=0)
项目:Webradio_v2    作者:Acer54    | 项目源码 | 文件源码
def __init__(self,pinA,pinB,button,callback, parent):
        self.pinA = pinA
        self.pinB = pinB
        self.button = button
        self.callback = callback
        self.parent = parent
        if self.pinA is not None and self.pinB is not None:
            GPIO.setmode(GPIO.BOARD)

            GPIO.setwarnings(False)
            GPIO.setup(self.pinA, GPIO.IN)
            GPIO.setup(self.pinB, GPIO.IN)
            GPIO.add_event_detect(self.pinA, GPIO.FALLING,
            callback=self.switch_event)
            GPIO.add_event_detect(self.pinB, GPIO.FALLING,
            callback=self.switch_event)

        if self.button is not None:
            GPIO.setup(self.button, GPIO.IN)
            GPIO.add_event_detect(self.button, GPIO.BOTH,
            callback=self.button_event, bouncetime=200)

        return
        # Call back routine called by switch events
项目:Aquamonitor    作者:aquamonitor    | 项目源码 | 文件源码
def Setup():
    global logger
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.INFO)
    handler = logging.FileHandler('/var/log/rodi.log')
    handler.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s - %(message)s',"%Y-%m-%d %H:%M:%S")
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(WATER_VALVE, GPIO.OUT)
    GPIO.setup(FLOATSW_HIGH_WL, GPIO.IN, pull_up_down=GPIO.PUD_UP)      #, initial = GPIO.HIGH)
    if not sys.stdout.isatty():
        sys.stderr = open('/var/log/rodi_stderr.log', 'a')
        sys.stdout = open('/var/log/rodi_stdout.log', 'a')
项目:telewall    作者:synox    | 项目源码 | 文件源码
def start():
    """  start running the ui. GPIO must only be loaded when it is stared, as the library is not available on the
         build computer.
    """
    from RPi import GPIO
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)  # use pin numbers as written on the board

    main_led.start()
    button_led.start()
    display.start()
    button.start()

    CallState.add_listener(on_call_state_change)

    main_led.queue(Startup())
    button_led.queue(StartupButton())
    display.show(10, 'Telewall')
项目:phony    作者:littlecraft    | 项目源码 | 文件源码
def __init__(self, layout):
    ClassLogger.__init__(self)

    # IO event callbacks occur in another thread, dbus/gdk need
    # to be made aware of this.
    gobject.threads_init()

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

    self._layout = layout
    for name, config in layout.iteritems():
      for point in ['pin', 'default']:
        Outputs._raise_if_not_in(point, config)

      self._conigure_output(name, config)
项目:AlarmPI    作者:bkbilly    | 项目源码 | 文件源码
def __init__(self, sensorName):
        # GPIO Setup
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)

        # Global Required Variables
        self.sensorName = sensorName
        self.online = True
        self.alert = None
        self._event_alert = []
        self._event_alert_stop = []
        self._event_error = []
        self._event_error_stop = []

        # Other Variables
        self.gpioState = None
        self.pin = None
项目:hx711py3    作者:dcrystalj    | 项目源码 | 文件源码
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()
项目:tipi    作者:jedimatt42    | 项目源码 | 文件源码
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."
项目:RaspberryPiControllerQtPython    作者:take-iwiw    | 项目源码 | 文件源码
def loop(gpio0, gpio1, resource):
    print (str(gpio0) + " " + str(gpio1))
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(gpio0, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(gpio1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    previousCode = 0
    while True:
        # code(FW) = 0 1 3 2 0 1 3 2 0 1 3 2
        rotationTable = [0,1,-1,0,-1,0,0,1,1,0,0,-1,0,-1,1,0]
        val0 = GPIO.input(gpio0)
        val1 = GPIO.input(gpio1)
        currentCode = val0 << 1 | val1
        # todo: chattering
        if currentCode != previousCode:
            code = previousCode << 2 | currentCode
            rotation = rotationTable[code & 0x0f]
            resource.diffRotate += rotation * TICK_DEGREE
            resource.totalRotate += rotation * TICK_DEGREE
        previousCode = currentCode
        time.sleep(0.002)
项目:coffee-billing    作者:weissekat    | 项目源码 | 文件源码
def __init__(self, dev='/dev/spidev0.0', speed=1000000, pin_rst=25, pin_ce=8):
        self.pin_rst = pin_rst
        self.pin_ce = pin_ce

        SPI.openSPI(device=dev, speed=speed)
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup(pin_rst, GPIO.OUT)
        GPIO.output(pin_rst, 1)
        if pin_ce != 0:
            GPIO.setup(pin_ce, GPIO.OUT)
            GPIO.output(pin_ce, 1)
        self.reset()
        self.dev_write(0x2A, 0x8D)
        self.dev_write(0x2B, 0x3E)
        self.dev_write(0x2D, 30)
        self.dev_write(0x2C, 0)
        self.dev_write(0x15, 0x40)
        self.dev_write(0x11, 0x3D)
        self.set_antenna(True)
项目:jarmilka    作者:msgre    | 项目源码 | 文件源码
def setup_gpio():
    """
    Setup GPIO pins on which LEDs and button switch are connected.
    """
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)

    # led output
    GPIO.setup(LED_1_PIN, GPIO.OUT)
    GPIO.setup(LED_2_PIN, GPIO.OUT)
    GPIO.setup(LED_BUTTON_PIN, GPIO.OUT)

    # button input
    GPIO.setup(BUTTON_PIN, GPIO.IN, GPIO.PUD_UP)

    # switch leds off
    reset_led()
项目:dhtxx-rpi-python3    作者:jdupl    | 项目源码 | 文件源码
def __init__(self, pin, gpio_lib=None):
        """
        pin: BCM pin number
        gpio_lib: optional library injection (for tests, Pine64 or platforms)
        """
        self.pin = pin

        if not gpio_lib:
            # Loads only on a Raspberry Pi
            import RPi.GPIO as GPIO
        else:
            GPIO = gpio_lib
        self.gpio_lib = GPIO

        # GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
项目:mote-phat    作者:pimoroni    | 项目源码 | 文件源码
def show():
    """Output the buffer to Mote pHAT"""
    global _gpio_setup

    if not _gpio_setup:
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup([DAT_PIN,CLK_PIN],GPIO.OUT)
        GPIO.setup(CHANNEL_PINS,GPIO.OUT)
        atexit.register(_exit)
        _gpio_setup = True

    for index, channel in enumerate(pixels):
        _select_channel(index)
        gamma = _gamma_table if channels[1] else range(256)
        _sof()
        for pixel in channel:
            r, g, b, brightness = pixel
            r, g, b = [gamma[int(x * brightness * _white_point[i]) & 0xff] for i, x in enumerate([r, g, b])]
            _write_byte(LED_SOF | LED_MAX_BR)
            _write_byte(b)
            _write_byte(g)
            _write_byte(r)

        _eof()
项目:rpi-can-logger    作者:JonnoFTW    | 项目源码 | 文件源码
def setup_GPIO():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(7, GPIO.OUT)
    GPIO.setup(37, GPIO.OUT)
    GPIO.setup(35, GPIO.IN)
项目:StratoBalloon    作者:delattreb    | 项目源码 | 文件源码
def __init__(self, name = ''):
        self.importlib = GPIO
        self.logger = com_logger.Logger(name)
        # self.setwarnings(False)
        self.IN = GPIO.IN if GPIO is not None else None
        self.OUT = GPIO.OUT if GPIO is not None else None
        self.LOW = GPIO.LOW if GPIO is not None else None
        self.HIGH = GPIO.HIGH if GPIO is not None else None
        self.PUD_UP = GPIO.PUD_UP if GPIO is not None else None
        self.PUD_DOWN = GPIO.PUD_DOWN if GPIO is not None else None
        self.RISING = GPIO.RISING if GPIO is not None else None
项目:StratoBalloon    作者:delattreb    | 项目源码 | 文件源码
def setwarnings(self, state):
        if self.importlib is not None:
            GPIO.setwarnings(state)
项目:voctomix-outcasts    作者:CarlFK    | 项目源码 | 文件源码
def reset_led(self):
        GPIO.setmode(GPIO.BOARD)
        GPIO.setwarnings(False)
        for gpio in self.gpios:
            gpio = int(gpio)
            GPIO.setup(gpio, GPIO.OUT)
            GPIO.output(gpio, GPIO.HIGH)
项目:Rpi-envMonitor    作者:conanwhf    | 项目源码 | 文件源码
def _GPIO_Power_Regist(pins):
    GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)
    GPIO.setup( pins , GPIO.OUT)
    return
项目:Rpi-envMonitor    作者:conanwhf    | 项目源码 | 文件源码
def __init__(self, datapin=24, powerpin=25):
        GPIO.setmode(GPIO.BOARD)
        self.pin = datapin
        GPIO.setwarnings(False)
        count=0
项目:AlexaPi    作者:alexa-pi    | 项目源码 | 文件源码
def setup(self):
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        super(RaspberrypiPlatform, self).setup()
项目:OpenAg-MVP    作者:webbhm    | 项目源码 | 文件源码
def setLightOn():
    "Check the time and determine if the lights need to be changed"
    lightPin = 29
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    print ("Turn lights On")
    GPIO.setup(lightPin, GPIO.OUT)
    GPIO.output(lightPin, GPIO.HIGH)
    logData("LightChange", "Success", "light", "On", '')
项目:OpenAg-MVP    作者:webbhm    | 项目源码 | 文件源码
def setLightOff():
    "Check the time and determine if the lights need to be changed"
    lightPin = 29
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    print ("Turn lights Off")
    GPIO.setup(lightPin, GPIO.OUT)
    GPIO.output(lightPin, GPIO.LOW)
    logData("Light_Switch", "Success", "light", "Off", '')
项目:gwot-physical    作者:JanVan01    | 项目源码 | 文件源码
def __prepare(self):
        if self.prepared is True:
            return self.prepared

        self.trigger_pin = self.get_setting("trigger_pin")
        self.data_pin = self.get_setting("data_pin")
        if self.trigger_pin is None or self.data_pin is None:
            print('Please configure pins of distance sensor.')
            return False

        self.prepared = True
        self.trigger_pin = int(self.trigger_pin)
        self.data_pin = int(self.data_pin)

        # Warnings disabled
        GPIO.setwarnings(False)

        GPIO.setmode(GPIO.BCM)

        # Define used GPIOs
        GPIO.setup(self.trigger_pin, GPIO.OUT)
        GPIO.setup(self.data_pin, GPIO.IN)
        GPIO.output(self.trigger_pin, GPIO.LOW)

        # Avoid crashs
        time.sleep(0.5)
        return self.prepared
项目:nhl_goal_light    作者:arim215    | 项目源码 | 文件源码
def setup():
    """ Function to setup raspberry pi GPIO mode and warnings. PIN 7 OUT and PIN 11 IN """

    # Setup GPIO on raspberry pi
    GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)
    GPIO.setup(7, GPIO.OUT, initial=GPIO.LOW) # Tell the program you want to use pin number 7 as output. Relay is ACTIVE LOW, so OFF is HIGH
    GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)  # Set GPIO 11 as a PULL DOWN switch
    GPIO.add_event_detect(11, GPIO.RISING, activate_goal_light, 5000)
项目:BoilerPlate    作者:wyaron    | 项目源码 | 文件源码
def init_relay():       
    # switch to BCM
    GPIO.setmode(GPIO.BCM)

    # disable warning of used ports
    GPIO.setwarnings(False)

    # set the port as output port
    GPIO.setup(CTL_OUT, GPIO.OUT)
项目:WaterHeaterController    作者:mcapinha    | 项目源码 | 文件源码
def initialize():
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(PINS.SPIMOSI, GPIO.OUT)
    GPIO.setup(PINS.SPIMISO, GPIO.IN)
    GPIO.setup(PINS.SPICLK, GPIO.OUT)
    GPIO.setup(PINS.SPICS, GPIO.OUT)


# Function to read data from Analog Pin 0 from MCP3008 (don't need to edit)
# This function will be called in our loop to get the current sensor value
项目:picade-hat    作者:pimoroni    | 项目源码 | 文件源码
def write_unlock():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(GPIO_WRITE_PROTECT,  GPIO.OUT)
    GPIO.output(GPIO_WRITE_PROTECT, GPIO.LOW)
项目:52-Weeks-of-Pi    作者:grantwinney    | 项目源码 | 文件源码
def initialize_gpio():
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(PIN, GPIO.OUT)
项目:raspberrypi_tempmon    作者:gavinlyonsrepo    | 项目源码 | 文件源码
def led_toggle_func(mode, led):
    """led_toggle_func , function to toggle a GPIO LED, passed mode on/off
    and GPIO pin of LED"""
    led = int(led)
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(led, GPIO.OUT)

    if mode == "off":
        GPIO.output(led, False)
    else:
        GPIO.output(led, True)
项目:frosti    作者:bmcc0605    | 项目源码 | 文件源码
def gpio_init():
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)

        # set up the SPI interface pins
        GPIO.setup(SPIMOSI, GPIO.OUT)
        GPIO.setup(SPIMISO, GPIO.IN)
        GPIO.setup(SPICLK, GPIO.OUT)
        GPIO.setup(SPICS, GPIO.OUT)

# read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)
项目:timeturner    作者:scamallach    | 项目源码 | 文件源码
def uptonogood(SER=4, RCLK=17, SRCLK=27):
    GPIO.setwarnings(True)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(SER, GPIO.OUT)
    GPIO.setup(RCLK, GPIO.OUT)
    GPIO.setup(SRCLK, GPIO.OUT)
项目:Gartenwasser    作者:bgewehr    | 项目源码 | 文件源码
def init_gpio():
    """
    Initialise the GPIO library
    """
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)

    for PIN in PINS:
        index = [y[0] for y in PINS].index(PIN[0])
        pin = PINS[index][0]
        GPIO.setup(pin, GPIO.IN)