python类VERSION的实例源码

RFExplorer.py 文件源码 项目:RFExplorer-for-Python 作者: RFExplorer 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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")
__init__.py 文件源码 项目:OctoPrint-LEDStripControl 作者: google 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def on_after_startup(self):
        self._logger.debug(u"LEDStripControl Startup")
        if GPIO:
            self._logger.debug(u"RPi.GPIO version %s" % (GPIO.VERSION,))
__init__.py 文件源码 项目:OctoPrint-Switch 作者: MoonshineSG 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def initialize(self):
        #self._logger.setLevel(logging.DEBUG)

        self._logger.info("Running RPi.GPIO version '{0}'...".format(GPIO.VERSION))
        if GPIO.VERSION < "0.6":
            raise Exception("RPi.GPIO must be greater than 0.6")

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

        self.PIN_LED = self._settings.get_int(["led_pin"])
        self.PIN_POWER = self._settings.get_int(["power_pin"])
        self.PIN_RESET = self._settings.get_int(["reset_pin"])

        self.POWER_OFF_COMMAND = self._settings.get(["command_power_off"]).split(",")
        self.RETRACTION_LENGHT = self._settings.get_int(["retraction_length"])
        self.SHORT_RETRACTION_LENGHT = self._settings.get_int(["short_retraction_length"])
        self.RETRACTION_SPEED = self._settings.get_int(["retraction_speed"])

        self.IDLE_TIMEOUT = self._settings.get_int(["idle_timeout"])        

        if self.PIN_POWER != -1:
            GPIO.setup(self.PIN_POWER, GPIO.OUT)    #default OFF (normally open)
        else:
            self._logger.info("Power pin not setup.")

        if self.PIN_LED != -1:
            GPIO.setup(self.PIN_LED, GPIO.OUT)      #default OFF  (normally open)
        else:
            self._logger.info("LED pin not setup.")

        GPIO.setup(self.PIN_RPICAM, GPIO.OUT)   #default ON (internal)

        self.MUTE_FILE = os.path.join(self.get_plugin_data_folder(), "mute")
        self.POWEROFF_FILE = os.path.join(self.get_plugin_data_folder(), "poweroff")
        self.UNLOAD_FILE = os.path.join(self.get_plugin_data_folder(), "unload")

        #the power is turned on by lights (and it should be turned off if nobody else needs it)
        self.LIGHT = False 

        self._logger.info("SwitchPlugin initialized...")
__init__.py 文件源码 项目:Octoprint-Filament-Reloaded 作者: kontakt 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def initialize(self):
        self._logger.info("Running RPi.GPIO version '{0}'".format(GPIO.VERSION))
        if GPIO.VERSION < "0.6":       # Need at least 0.6 for edge detection
            raise Exception("RPi.GPIO must be greater than 0.6")
        GPIO.setwarnings(False)        # Disable GPIO warnings
sample_board.py 文件源码 项目:raspberry-gpio-emulator 作者: nosix 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def main():
    import RPi.GPIO as GPIO
    import time

    try:
        print(GPIO.VERSION)
        print(GPIO.RPI_INFO)

        GPIO.setmode(GPIO.BOARD)

        GPIO.setwarnings(False)

        GPIO.setup(12, GPIO.OUT)
        GPIO.setup(11, GPIO.OUT, initial=GPIO.HIGH)
        GPIO.setup(13, GPIO.IN)
        GPIO.setup(15, GPIO.OUT)
        GPIO.setup([16, 18], GPIO.OUT)
        GPIO.setup((8, 10), GPIO.OUT)
        GPIO.setup([21, 19], GPIO.IN)

        GPIO.setup(3, GPIO.IN)
        GPIO.cleanup(3)

        GPIO.setup([5, 7], GPIO.OUT)
        GPIO.cleanup([5, 7])

        GPIO.setup([5, 7], GPIO.IN)
        GPIO.cleanup((5, 7))

        while True:
            GPIO.output(12, GPIO.HIGH)
            GPIO.output(11, 0)
            GPIO.output(15, True)
            GPIO.output([16, 18], not GPIO.input(16))
            GPIO.output((8, 10), [GPIO.HIGH, GPIO.LOW])
            time.sleep(1)

            GPIO.output(12, GPIO.LOW)
            GPIO.output(11, 1)
            GPIO.output(15, False)
            GPIO.output((16, 18), not GPIO.input(16))
            GPIO.output([8, 10], (GPIO.LOW, GPIO.HIGH))
            time.sleep(1)
    finally:
        GPIO.cleanup()
sample_bcm.py 文件源码 项目:raspberry-gpio-emulator 作者: nosix 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def main():
    import RPi.GPIO as GPIO
    import time

    try:
        print(GPIO.VERSION)
        print(GPIO.RPI_INFO)

        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(18, GPIO.OUT)
        GPIO.setup(17, GPIO.OUT, initial=GPIO.HIGH)
        GPIO.setup(27, GPIO.IN)
        GPIO.setup(22, GPIO.OUT)
        GPIO.setup([23, 24], GPIO.OUT)
        GPIO.setup((14, 15), GPIO.OUT)
        GPIO.setup([9, 10], GPIO.IN)

        GPIO.setup(2, GPIO.IN)
        GPIO.cleanup(2)

        GPIO.setup([3, 4], GPIO.OUT)
        GPIO.cleanup([3, 4])

        GPIO.setup([3, 4], GPIO.IN)
        GPIO.cleanup((3, 4))

        while True:
            GPIO.output(18, GPIO.HIGH)
            GPIO.output(17, 0)
            GPIO.output(22, True)
            GPIO.output([23, 24], not GPIO.input(23))
            GPIO.output((14, 15), [GPIO.HIGH, GPIO.LOW])
            time.sleep(1)

            GPIO.output(18, GPIO.LOW)
            GPIO.output(17, 1)
            GPIO.output(22, False)
            GPIO.output((23, 24), not GPIO.input(23))
            GPIO.output([14, 15], (GPIO.LOW, GPIO.HIGH))
            time.sleep(1)
    finally:
        GPIO.cleanup()
__init__.py 文件源码 项目:OctoPrint-PSUControl 作者: kantlivelong 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _configure_gpio(self):
        if not self._hasGPIO:
            self._logger.error("RPi.GPIO is required.")
            return

        self._logger.info("Running RPi.GPIO version %s" % GPIO.VERSION)
        if GPIO.VERSION < "0.6":
            self._logger.error("RPi.GPIO version 0.6.0 or greater required.")

        GPIO.setwarnings(False)

        for pin in self._configuredGPIOPins:
            self._logger.debug("Cleaning up pin %s" % pin)
            try:
                GPIO.cleanup(self._gpio_get_pin(pin))
            except (RuntimeError, ValueError) as e:
                self._logger.error(e)
        self._configuredGPIOPins = []

        if GPIO.getmode() is None:
            if self.GPIOMode == 'BOARD':
                GPIO.setmode(GPIO.BOARD)
            elif self.GPIOMode == 'BCM':
                GPIO.setmode(GPIO.BCM)
            else:
                return

        if self.sensingMethod == 'GPIO':
            self._logger.info("Using GPIO sensing to determine PSU on/off state.")
            self._logger.info("Configuring GPIO for pin %s" % self.senseGPIOPin)

            if self.senseGPIOPinPUD == 'PULL_UP':
                pudsenseGPIOPin = GPIO.PUD_UP
            elif self.senseGPIOPinPUD == 'PULL_DOWN':
                pudsenseGPIOPin = GPIO.PUD_DOWN
            else:
                pudsenseGPIOPin = GPIO.PUD_OFF

            try:
                GPIO.setup(self._gpio_get_pin(self.senseGPIOPin), GPIO.IN, pull_up_down=pudsenseGPIOPin)
                self._configuredGPIOPins.append(self.senseGPIOPin)
            except (RuntimeError, ValueError) as e:
                self._logger.error(e)

        if self.switchingMethod == 'GPIO':
            self._logger.info("Using GPIO for On/Off")
            self._logger.info("Configuring GPIO for pin %s" % self.onoffGPIOPin)
            try:
                if not self.invertonoffGPIOPin:
                    initial_pin_output=GPIO.LOW
                else:
                    initial_pin_output=GPIO.HIGH
                GPIO.setup(self._gpio_get_pin(self.onoffGPIOPin), GPIO.OUT, initial=initial_pin_output)
                self._configuredGPIOPins.append(self.onoffGPIOPin)
            except (RuntimeError, ValueError) as e:
                self._logger.error(e)


问题


面经


文章

微信
公众号

扫码关注公众号