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


Python GPIO.setwarnings方法代码示例

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


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

示例1: test_alreadyinuse

# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setwarnings [as 别名]
    def test_alreadyinuse(self):
        """Test 'already in use' warning"""
        GPIO.setwarnings(False)
        with open('/sys/class/gpio/export','wb') as f:
            f.write(str(LED_PIN_BCM).encode())
        with open('/sys/class/gpio/gpio%s/direction'%LED_PIN_BCM,'wb') as f:
            f.write(b'out')
        with open('/sys/class/gpio/gpio%s/value'%LED_PIN_BCM,'wb') as f:
            f.write(b'1')
        with warnings.catch_warnings(record=True) as w:
            GPIO.setup(LED_PIN, GPIO.OUT)    # generate 'already in use' warning
            self.assertEqual(len(w),0)       # should be no warnings
        with open('/sys/class/gpio/unexport','wb') as f:
            f.write(str(LED_PIN_BCM).encode())
        GPIO.cleanup()

        GPIO.setwarnings(True)
        with open('/sys/class/gpio/export','wb') as f:
            f.write(str(LED_PIN_BCM).encode())
        with open('/sys/class/gpio/gpio%s/direction'%LED_PIN_BCM,'wb') as f:
            f.write(b'out')
        with open('/sys/class/gpio/gpio%s/value'%LED_PIN_BCM,'wb') as f:
            f.write(b'1')
        with warnings.catch_warnings(record=True) as w:
            GPIO.setup(LED_PIN, GPIO.OUT)    # generate 'already in use' warning
            self.assertEqual(w[0].category, RuntimeWarning)
        with open('/sys/class/gpio/unexport','wb') as f:
            f.write(str(LED_PIN_BCM).encode())
        GPIO.cleanup()
开发者ID:Alessia-Cao,项目名称:LMK.GPIO,代码行数:31,代码来源:test.py

示例2: init

# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setwarnings [as 别名]
	def init(self):
		GPIO.setmode(GPIO.BCM)
		GPIO.setwarnings(False)
		GPIO.setup(self.pin1,GPIO.OUT)
		GPIO.setup(self.pin2,GPIO.OUT)
		GPIO.setup(self.pin3,GPIO.OUT)
		GPIO.setup(self.pin4,GPIO.OUT)
		self.zeroPosition()
		return	
开发者ID:Alessia-Cao,项目名称:LeScratch,代码行数:11,代码来源:step_motor.py

示例3: test_cleanupwarning

# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setwarnings [as 别名]
    def test_cleanupwarning(self):
        """Test initial GPIO.cleanup() produces warning"""
        GPIO.setwarnings(False)
        GPIO.setup(SWITCH_PIN, GPIO.IN)
        with warnings.catch_warnings(record=True) as w:
            GPIO.cleanup()
            self.assertEqual(len(w),0) # no warnings
            GPIO.cleanup()
            self.assertEqual(len(w),0) # no warnings

        GPIO.setwarnings(True)
        GPIO.setup(SWITCH_PIN, GPIO.IN)
        with warnings.catch_warnings(record=True) as w:
            GPIO.cleanup()
            self.assertEqual(len(w),0) # no warnings
            GPIO.cleanup()
            self.assertEqual(w[0].category, RuntimeWarning) # a warning
开发者ID:Alessia-Cao,项目名称:LMK.GPIO,代码行数:19,代码来源:test.py

示例4: Tk

# 需要导入模块: from LMK import GPIO [as 别名]
# 或者: from LMK.GPIO import setwarnings [as 别名]
import datetime
from Tkinter import Tk
from array import array
import LMK.GPIO as GPIO
import step_motor as StepMotor
import RTC_DS1307
import IOboard

ver_BOARD = GPIO.LMK_REVISION
if ver_BOARD == 2:
	import DHTreader2 as DHTreader
if ver_BOARD == 3:
	import DHTreader3 as DHTreader

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(True)

stepM1 = StepMotor.Motor(11,7,16,26)
stepM2 = StepMotor.Motor(4,25,24,23)

root = Tk()
root.withdraw()

Bus = smbus.SMBus(2)
PORT = 42001
HOST = "localhost"

Debug = False
Connected = False
Setup = False
I2Csetup = False
开发者ID:Alessia-Cao,项目名称:LeScratch,代码行数:33,代码来源:LeScratch.py


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