Ejemplo n.º 1
0
    def __init__(self):
        # pinouts
        lcd_rs = 1
        lcd_en = 2
        lcd_d4 = 3
        lcd_d5 = 4
        lcd_d6 = 5
        lcd_d7 = 6
        backlight_pin = 7

        lcd_columns = 16
        lcd_rows = 2

        # We're going to use an I2C interface, so get the correct object to pass to the LCD class
        gpio = MCP.MCP23008(0x20, busnum=1)

        # Use the base class's init to set everything up
        LCD.Adafruit_CharLCD.__init__(self,
                                      lcd_rs,
                                      lcd_en,
                                      lcd_d4,
                                      lcd_d5,
                                      lcd_d6,
                                      lcd_d7,
                                      lcd_columns,
                                      lcd_rows,
                                      gpio=gpio,
                                      backlight=backlight_pin)
Ejemplo n.º 2
0
 def __init__(self,model):
     # Initialize MCP23017 device using its default 0x20 I2C address.
     self.gpio = MCP.MCP23008(0x20, busnum=1)
     self.lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
                           lcd_columns, lcd_rows, lcd_back,
                           gpio=self.gpio, invert_polarity=False)
     self.led = LED(16)
     self.model = model
     self.formatter = "{:" + str(8) + "}"
     self.redraw()
Ejemplo n.º 3
0
 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 the MCP23008 device.
     self._mcp = MCP.MCP23008(address=address, busnum=busnum)
     # Initialize LCD (with no PWM support).
     super(Adafruit_CharLCDBackpack, self).__init__(LCD_BACKPACK_RS, LCD_BACKPACK_EN,
         LCD_BACKPACK_D4, LCD_BACKPACK_D5, LCD_BACKPACK_D6, LCD_BACKPACK_D7,
         cols, lines, LCD_BACKPACK_LITE, enable_pwm=False, gpio=self._mcp)
Ejemplo n.º 4
0
 def __init__(self):
     self.className = "Lcd"
     self.gpio = MCP.MCP23008(self.address)
     self.lcd = LCD.Adafruit_CharLCD(1,
                                     2,
                                     3,
                                     4,
                                     5,
                                     6,
                                     self.lines,
                                     self.cols,
                                     gpio=self.gpio,
                                     backlight=7,
                                     invert_polarity=False)
Ejemplo n.º 5
0
import time

import Adafruit_GPIO as GPIO
import Adafruit_GPIO.MCP230xx as adafruit_mcp

# Use busnum = 0 for older Raspberry Pi's (256MB)
#mcp = adafruit_mcp.MCP23008()
# Use busnum = 1 for new Raspberry Pi's (512MB with mounting holes)
mcp = adafruit_mcp.MCP23008(address=0x20)

# Set pin 3 to input with the pullup resistor enabled
mcp.setup(0, GPIO.OUT)

# Python speed test on output 0 toggling at max speed
while (True):
    print "high"
    mcp.output(0, GPIO.HIGH)  # Pin 0 High
    time.sleep(1)
    print "low"
    mcp.output(0, GPIO.LOW)  # Pin 1 Low  time.sleep(0.1)
    time.sleep(1)
Ejemplo n.º 6
0
    "pump": {
        "gpio": 7,
        "label": u"Насос",
    }
}

SMS_NOTIFICATIONS = dict([
    (10,
     "10д. Долейте воду и удобрения: Micro-12.5мл, Grow-12.5мл, Bloom-12.5мл"),
    (20, "20д. Долейте воду и удобрения: Micro-25мл, Grow-25мл, Bloom-25мл"),
    (30, "30д. Долейте воду и удобрения: Micro-25мл, Grow-25мл, Bloom-25мл"),
    (45, "45д. Начните новый цикл. Детали: http://admin.vhnh.hort.io/today")
])

# Setup IO
mcp = MCP.MCP23008()

for out in range(8):
    mcp.setup(out, GPIO.OUT)

# Setup DB
db = LSM(os.getenv("DB_FILE", "/data/hortio.ldb"))


def pca9548a_setup(pca9548a_channel):
    """
    Set i2c multiplexer (pca9548a) channel
    """
    pca9548a = I2C.get_i2c_device(PCA9548A_ADDR)
    pca9548a.writeRaw8(pca9548a_channel)
    time.sleep(0.1)
Ejemplo n.º 7
0
Archivo: read.py Proyecto: dfijma/p1
# Define MCP pins connected to the LCD.
lcd_rs = 1
lcd_en = 2
lcd_d4 = 3
lcd_d5 = 4
lcd_d6 = 5
lcd_d7 = 6
lcd_back = 7

# Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows = 2

# get lcd via MCP i2c io extender
gpio = MCP.MCP23008(0x20, busnum=1)
lcd = LCD.Adafruit_CharLCD(lcd_rs,
                           lcd_en,
                           lcd_d4,
                           lcd_d5,
                           lcd_d6,
                           lcd_d7,
                           lcd_columns,
                           lcd_rows,
                           lcd_back,
                           gpio=gpio,
                           invert_polarity=False)

client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  # UDP
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
client.bind(('', 37020))
Ejemplo n.º 8
0
 def __init__(self):
     self.buttons = mcs.MCP23008(i2c_address)
     for i in range(8):
         self.buttons.setup(i, GPIO.IN)