本文整理汇总了Python中Adafruit_GPIO.OUT属性的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_GPIO.OUT属性的具体用法?Python Adafruit_GPIO.OUT怎么用?Python Adafruit_GPIO.OUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类Adafruit_GPIO
的用法示例。
在下文中一共展示了Adafruit_GPIO.OUT属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def __init__(self, dc, rst, sclk=None, din=None, cs=None, gpio=None, spi=None):
self._sclk = sclk
self._din = din
self._dc = dc
self._cs = cs
self._rst = rst
self._gpio = gpio
self._spi = spi
# Default to detecting platform GPIO.
if self._gpio is None:
self._gpio = GPIO.get_platform_gpio()
if self._rst is not None:
self._gpio.setup(self._rst, GPIO.OUT)
# Default to bit bang SPI.
if self._spi is None:
self._spi = SPI.BitBang(self._gpio, self._sclk, self._din, None, self._cs)
# Set pin outputs.
self._gpio.setup(self._dc, GPIO.OUT)
# Initialize buffer to Adafruit logo.
self._buffer = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC7, 0xC7, 0x87, 0x8F, 0x9F, 0x9F, 0xFF, 0xFF, 0xFF, 0xC1, 0xC0, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF1, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x0F, 0x87, 0xE7, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0x3F, 0xF9, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x7E, 0x3F, 0x3F, 0x0F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xE0, 0xF1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
示例2: __init__
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def __init__(self, address=0x20, busnum=I2C.get_default_bus(), cols=16, lines=2):
"""Initialize the character LCD plate. Can optionally specify a separate
I2C address or bus number, but the defaults should suffice for most needs.
Can also optionally specify the number of columns and lines on the LCD
(default is 16x2).
"""
# Configure MCP23017 device.
self._mcp = MCP.MCP23017(address=address, busnum=busnum)
# Set LCD R/W pin to low for writing only.
self._mcp.setup(LCD_PLATE_RW, GPIO.OUT)
self._mcp.output(LCD_PLATE_RW, GPIO.LOW)
# Set buttons as inputs with pull-ups enabled.
for button in (SELECT, RIGHT, DOWN, UP, LEFT):
self._mcp.setup(button, GPIO.IN)
self._mcp.pullup(button, True)
# Initialize LCD (with no PWM support).
super(Adafruit_CharLCDPlate, self).__init__(LCD_PLATE_RS, LCD_PLATE_EN,
LCD_PLATE_D4, LCD_PLATE_D5, LCD_PLATE_D6, LCD_PLATE_D7, cols, lines,
LCD_PLATE_RED, LCD_PLATE_GREEN, LCD_PLATE_BLUE, enable_pwm=False,
gpio=self._mcp)
示例3: GPIO_handler
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def GPIO_handler(self,pin):
self.FTDI_setup()
pin_combo={0:self.comboBox_d0,1:self.comboBox_d1,2:self.comboBox_d2,3:self.comboBox_d3,4:self.comboBox_d4,5:self.comboBox_d5,6:self.comboBox_d6,7:self.comboBox_d7}
pin_check={0:self.checkBox_d0,1:self.checkBox_d1,2:self.checkBox_d2,3:self.checkBox_d3,4:self.checkBox_d4,5:self.checkBox_d5,6:self.checkBox_d6,7:self.checkBox_d7}
mode=pin_check[pin].isChecked()
if(str(pin_combo[pin].currentText())=="Input"):
self.ft232h.setup(pin,GPIO.IN)
print("[*] Pin "+str(pin)+" set as Input")
elif(str(pin_combo[pin].currentText())=="Output"):
print("[*] Pin "+str(pin)+" set as Output")
self.ft232h.setup(pin,GPIO.OUT)
if(mode):
print("[*] Pin "+str(pin)+" : HIGH ")
self.statusbar.showMessage(" GPIO | Pin "+str(pin)+" : HIGH ",500)
self.ft232h.output(pin, GPIO.HIGH)
else:
self.ft232h.output(pin, GPIO.LOW)
self.statusbar.showMessage(" GPIO | Pin "+str(pin)+" : LOW ",500)
print("[*] Pin "+str(pin)+" : LOW ")
示例4: __init__
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def __init__(self, dc, spi, rst=None, gpio=None, width=ILI9341_TFTWIDTH,
height=ILI9341_TFTHEIGHT):
"""Create an instance of the display using SPI communication. Must
provide the GPIO pin number for the D/C pin and the SPI driver. Can
optionally provide the GPIO pin number for the reset pin as the rst
parameter.
"""
self._dc = dc
self._rst = rst
self._spi = spi
self._gpio = gpio
self.width = width
self.height = height
if self._gpio is None:
self._gpio = GPIO.get_platform_gpio()
# Set DC as output.
self._gpio.setup(dc, GPIO.OUT)
# Setup reset as output (if provided).
if rst is not None:
self._gpio.setup(rst, GPIO.OUT)
# Set SPI to mode 0, MSB first.
spi.set_mode(0)
spi.set_bit_order(SPI.MSBFIRST)
spi.set_clock_hz(64000000)
# Create an image buffer.
self.buffer = Image.new('RGB', (width, height))
示例5: setup_pins
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def setup_pins(self, pins):
if False in [y for x,y in [(self._validate_pin(pin),mode in (IN,OUT)) for pin,mode in pins.items()]]:
raise ValueError('Invalid MODE, IN or OUT')
for pin,mode in pins.items():
self.iodir = self._bit2(self.iodir, pin, mode)
self._write_pins()
示例6: setup
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def setup(self, pin, value):
"""Set the input or output mode for a specified pin. Mode should be
either GPIO.OUT or GPIO.IN.
"""
self._validate_pin(pin)
# Set bit to 1 for input or 0 for output.
if value == GPIO.IN:
self.iodir[int(pin/8)] |= 1 << (int(pin%8))
elif value == GPIO.OUT:
self.iodir[int(pin/8)] &= ~(1 << (int(pin%8)))
else:
raise ValueError('Unexpected value. Must be GPIO.IN or GPIO.OUT.')
self.write_iodir()
示例7: __init__
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def __init__(self, gpio, sclk, mosi=None, miso=None, ss=None):
"""Initialize bit bang (or software) based SPI. Must provide a BaseGPIO
class, the SPI clock, and optionally MOSI, MISO, and SS (slave select)
pin numbers. If MOSI is set to None then writes will be disabled and fail
with an error, likewise for MISO reads will be disabled. If SS is set to
None then SS will not be asserted high/low by the library when
transfering data.
"""
self._gpio = gpio
self._sclk = sclk
self._mosi = mosi
self._miso = miso
self._ss = ss
# Set pins as outputs/inputs.
gpio.setup(sclk, GPIO.OUT)
if mosi is not None:
gpio.setup(mosi, GPIO.OUT)
if miso is not None:
gpio.setup(miso, GPIO.IN)
if ss is not None:
gpio.setup(ss, GPIO.OUT)
# Assert SS high to start with device communication off.
gpio.set_high(ss)
# Assume mode 0.
self.set_mode(0)
# Assume most significant bit first order.
self.set_bit_order(MSBFIRST)
示例8: test_setup
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def test_setup(self):
rpi_gpio = Mock()
adapter = GPIO.RPiGPIOAdapter(rpi_gpio)
adapter.setup(1, GPIO.OUT)
rpi_gpio.setup.assert_called_with(1, rpi_gpio.OUT, pull_up_down=rpi_gpio.PUD_OFF)
adapter.setup(1, GPIO.IN)
rpi_gpio.setup.assert_called_with(1, rpi_gpio.IN, pull_up_down=rpi_gpio.PUD_OFF)
adapter.setup(1, GPIO.IN, GPIO.PUD_DOWN)
rpi_gpio.setup.assert_called_with(1, rpi_gpio.IN, pull_up_down=rpi_gpio.PUD_DOWN)
adapter.setup(1, GPIO.IN, GPIO.PUD_UP)
rpi_gpio.setup.assert_called_with(1, rpi_gpio.IN, pull_up_down=rpi_gpio.PUD_UP)
示例9: __init__
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def __init__(self, cs, sclk=None, mosi=None, miso=None, gpio=None,
spi=None):
"""Create an instance of the PN532 class using either software SPI (if
the sclk, mosi, and miso pins are specified) or hardware SPI if a
spi parameter is passed. The cs pin must be a digital GPIO pin.
Optionally specify a GPIO controller to override the default that uses
the board's GPIO pins.
"""
# Default to platform GPIO if not provided.
self._gpio = gpio
if self._gpio is None:
self._gpio = GPIO.get_platform_gpio()
# Initialize CS line.
self._cs = cs
self._gpio.setup(self._cs, GPIO.OUT)
self._gpio.set_high(self._cs)
# Setup SPI provider.
if spi is not None:
logger.debug('Using hardware SPI.')
# Handle using hardware SPI.
self._spi = spi
self._spi.set_clock_hz(1000000)
else:
logger.debug('Using software SPI')
# Handle using software SPI. Note that the CS/SS pin is not used
# as it will be manually controlled by this library for better
# timing.
self._spi = SPI.BitBang(self._gpio, sclk, mosi, miso)
# Set SPI mode and LSB first bit order.
self._spi.set_mode(0)
self._spi.set_bit_order(SPI.LSBFIRST)
示例10: GPIO_setup
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def GPIO_setup(self):
if(self.gpio_init==0):
print("[*] Setting up GPIO pins")
#setting everything as out
#because leaving then un-
#initialized confuses the
#Input Monitor
self.ft232h.setup(0, GPIO.OUT)
self.ft232h.setup(1, GPIO.OUT)
self.ft232h.setup(2, GPIO.OUT)
self.ft232h.setup(3, GPIO.OUT)
self.ft232h.setup(4, GPIO.OUT)
self.ft232h.setup(5, GPIO.OUT)
self.ft232h.setup(6, GPIO.OUT)
self.ft232h.setup(7, GPIO.OUT)
示例11: __init__
# 需要导入模块: import Adafruit_GPIO [as 别名]
# 或者: from Adafruit_GPIO import OUT [as 别名]
def __init__(self, width, height, rst, dc=None, sclk=None, din=None, cs=None,
gpio=None, spi=None, i2c_bus=None, i2c_address=SSD1306_I2C_ADDRESS,
i2c=None):
self._log = logging.getLogger('Adafruit_SSD1306.SSD1306Base')
self._spi = None
self._i2c = None
self.width = width
self.height = height
self._pages = height//8
self._buffer = [0]*(width*self._pages)
# Default to platform GPIO if not provided.
self._gpio = gpio
if self._gpio is None:
self._gpio = GPIO.get_platform_gpio()
# Setup reset pin.
self._rst = rst
if not self._rst is None:
self._gpio.setup(self._rst, GPIO.OUT)
# Handle hardware SPI
if spi is not None:
self._log.debug('Using hardware SPI')
self._spi = spi
self._spi.set_clock_hz(8000000)
# Handle software SPI
elif sclk is not None and din is not None and cs is not None:
self._log.debug('Using software SPI')
self._spi = SPI.BitBang(self._gpio, sclk, din, None, cs)
# Handle hardware I2C
elif i2c is not None:
self._log.debug('Using hardware I2C with custom I2C provider.')
self._i2c = i2c.get_i2c_device(i2c_address)
else:
self._log.debug('Using hardware I2C with platform I2C provider.')
import Adafruit_GPIO.I2C as I2C
if i2c_bus is None:
self._i2c = I2C.get_i2c_device(i2c_address)
else:
self._i2c = I2C.get_i2c_device(i2c_address, busnum=i2c_bus)
# Initialize DC pin if using SPI.
if self._spi is not None:
if dc is None:
raise ValueError('DC pin must be provided when using SPI.')
self._dc = dc
self._gpio.setup(self._dc, GPIO.OUT)