コード例 #1
0
 def __init__(self, i2c, columns, lines, backlight_inverted=False, usingPCF=False, address=None):
     """Initialize character LCD connected to backpack using I2C connection
     on the specified I2C bus with the specified number of columns and
     lines on the display. Optionally specify if backlight is inverted.
     """
     if usingPCF:
         from adafruit_character_lcd.pcf8574 import pcf8574
         if address:
             self.interface = pcf8574(i2c, const(address))
         else:
             raise NameError('No address argument')
         dummyPinArr = [i for i in range(6)]
         super().__init__(
             dummyPinArr[0], 
             dummyPinArr[1],
             dummyPinArr[2],
             dummyPinArr[3],
             dummyPinArr[4],
             dummyPinArr[5],
             columns, lines, interface=self.interface)
     else:
         import adafruit_mcp230xx
         self._mcp = adafruit_mcp230xx.MCP23008(i2c)
         reset = self._mcp.get_pin(1)
         enable = self._mcp.get_pin(2)
         db4 = self._mcp.get_pin(3)
         db5 = self._mcp.get_pin(4)
         db6 = self._mcp.get_pin(5)
         db7 = self._mcp.get_pin(6)
         backlight_pin = self._mcp.get_pin(7)
         super().__init__(reset, enable, db4, db5, db6, db7, columns, lines,
                         backlight_pin=backlight_pin, backlight_inverted=backlight_inverted)
コード例 #2
0
 def __init__(self, i2c, columns, lines, backlight_inverted=False):
     """Initialize character LCD connected to backpack using I2C connection
     on the specified I2C bus with the specified number of columns and
     lines on the display. Optionally specify if backlight is inverted.
     """
     import adafruit_mcp230xx
     self._mcp = adafruit_mcp230xx.MCP23008(i2c)
     reset = self._mcp.get_pin(1)
     enable = self._mcp.get_pin(2)
     db4 = self._mcp.get_pin(3)
     db5 = self._mcp.get_pin(4)
     db6 = self._mcp.get_pin(5)
     db7 = self._mcp.get_pin(6)
     backlight_pin = self._mcp.get_pin(7)
     super().__init__(reset, enable, db4, db5, db6, db7, columns, lines,
                      backlight_pin=backlight_pin, backlight_inverted=backlight_inverted)
コード例 #3
0
# they were native CircuitPython digital inputs/outputs.
# Author: Tony DiCola
import time

import board
import busio
import digitalio

import adafruit_mcp230xx

# Initialize the I2C bus:
i2c = busio.I2C(board.SCL, board.SDA)

# Create an instance of either the MCP23008 or MCP23017 class depending on
# which chip you're using:
mcp = adafruit_mcp230xx.MCP23008(i2c)  # MCP23008
#mcp = adafruit_mcp230xx.MCP23017(i2c)  # MCP23017

# Optionally change the address of the device if you set any of the A0, A1, A2
# pins.  Specify the new address with a keyword parameter:
#mcp = adafruit_mcp230xx.MCP23017(i2c, address=0x21)  # MCP23017 w/ A0 set

# Now call the get_pin function to get an instance of a pin on the chip.
# This instance will act just like a digitalio.DigitalInOut class instance
# and has all the same properties and methods (except you can't set pull-down
# resistors, only pull-up!).  For the MCP23008 you specify a pin number from 0
# to 7 for the GP0...GP7 pins.  For the MCP23017 you specify a pin number from
# 0 to 15 for the GPIOA0...GPIOA7, GPIOB0...GPIOB7 pins (i.e. pin 12 is GPIOB4).
pin0 = mcp.get_pin(0)
pin1 = mcp.get_pin(1)