def setUp(self):
     #initialize the serial port
     _usbissdev = usbiss.USBISS(Port)
     # Initialize the GPIO, only pins 3 and 4 are available if combined with serial mode
     self.serport = serial.SERIAL(_usbissdev, Baudrate)
     self.io2 = gpio.GPIO(_usbissdev, gpio.SERIAL)
     self.io2.setup_pins({3: gpio.OUT, 4: gpio.IN}, {3: gpio.LOW})
     self.assertIsInstance(self.io2, gpio.GPIO)
 def setUp(self):
     self._usbissdev = usbiss.USBISS(Port)
     self.i2cchannel = i2c.I2C(self._usbissdev, 'H', 100)
     self.assertIsInstance(self.i2cchannel, i2c.I2C)
     # print(self.i2cchannel._usbiss.__repr__)
     self.pcf8574 = i2c.I2CDevice(self.i2cchannel, Address)
     self.assertIsInstance(self.pcf8574, i2c.I2CDevice)
     self.IODIR = 0x0F
Пример #3
0
 def setUp(self):
     self._usbissdev = usbiss.USBISS(Port)
     #initialize the serial port
     self.serport = serial.SERIAL(self._usbissdev, Baudrate)
     # Initialize the GPIO, only pins 3 and 4 are available if combined with serial mode
     self.io2 = gpio.GPIO(self._usbissdev, gpio.SERIAL)
     # Configure Pin3 as Out, Pin4 as IN, set Pin3 as Low
     self.io2.setup_pins({3: gpio.OUT, 4: gpio.IN}, {3: gpio.LOW})
     self.assertIsInstance(self.io2, gpio.GPIO)
Пример #4
0
def test_main():
    """Test function for verifying basic functionality."""
    print("Running test_main")
    usbissdev = usbiss.USBISS(Port)
    i2c = I2C.I2C(usbissdev, 'H', 100)
    lcd = LCD.I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16)
    lcd.putstr("USBISS Lcd_API\n Inheritance")
    time.sleep(3000 / 1000.0)
    lcd.clear()
    count = 0
    while True:
        lcd.move_to(0, 0)
        # pyb lcd.putstr("%7d" % (millis() // 1000))
        lcd.putstr("%7d" % (count))
        # millis() not available in Python
        time.sleep(1000 / 1000.0)
        count += 1
        if count % 10 == 3:
            print("Turning backlight off")
            lcd.backlight_off()
        if count % 10 == 4:
            print("Turning backlight on")
            lcd.backlight_on()
        if count % 10 == 5:
            print("Turning display off")
            lcd.display_off()
        if count % 10 == 6:
            print("Turning display on")
            lcd.display_on()
        if count % 10 == 7:
            print("Turning display & backlight off")
            lcd.backlight_off()
            lcd.display_off()
        if count % 10 == 8:
            print("Turning display & backlight on")
            lcd.backlight_on()
            lcd.display_on()
Пример #5
0
 def setUp(self):
     self._usbissdev = usbiss.USBISS(Port)
     self.serport = serial.SERIAL(self._usbissdev, Baudrate)
Пример #6
0
 def setUp(self):
     self._usbiss = usbiss.USBISS(Port)
     self.assertIsInstance(self._usbiss, usbiss.USBISS)
Пример #7
0
 def setUp(self):
     self._usbissdev = usbiss.USBISS(Port)
     self.io4 = gpio.GPIO(self._usbissdev)
     self.io4.setup_pins({1:gpio.OUT, 2:gpio.OUT, 3:gpio.IN, 4: gpio.IN}, {1:gpio.LOW, 2:gpio.LOW})
     self.assertIsInstance(self.io4, gpio.GPIO)
Пример #8
0
# Example GPIO based on Adafruit library for FT232H
# For the GPIO the connection to the USBISS is made outside the GPIO class thereby
# enabling using the GPIO class for use in I2C en Serial mode.
# GdH 23-3-2019

# Hardware : connect a LED to pins 1 and 2, connect Pin 3 to Pin 1
import time
from usbiss import gpio
from usbiss import usbiss

usbissdev = usbiss.USBISS('COM3')
io4 = gpio.GPIO(usbissdev)

io4.setup_pins({
    1: gpio.OUT,
    2: gpio.OUT,
    3: gpio.IN,
    4: gpio.IN
}, {
    1: gpio.HIGH,
    2: gpio.HIGH
})
print('Press Ctrl-C to quit.')
while True:
    # Set pin C0 to a high level so the LED turns on.
    io4.output(1, gpio.HIGH)
    # Sleep for 1 second.
    time.sleep(1)
    # Set pin C0 to a low level so the LED turns off.
    io4.output(1, gpio.LOW)
    # Sleep for 1 second.
 def setUp(self):
     self._usbissdev = usbiss.USBISS(Port)
     self.i2cchannel = i2c.I2C(self._usbissdev, 'H', 100)
     print(self.i2cchannel._usbiss.__repr__)
     self.eprom = i2c.I2CDevice(self.i2cchannel, EpromAddress)
Пример #10
0
# Based on https://github.com/mercolino/MCP9808
# Adapted for use with th USBISS Device by Geert de Haan 

# import MCP9808.mcp9808 as MCP9808
from usbiss import usbiss
from Devices import mcp9808 as MCP9808
from usbiss import i2c as I2C 
from usbiss import gpio

import time

port = 'COM3'
usbissdev = usbiss.USBISS(port)

io2 = gpio.GPIO(usbissdev, gpio.I2C)
io2.setup(1, gpio.OUT)
io2.output(1, gpio.HIGH)
io2.setup(2, gpio.IN)

i2c_chan = I2C.I2C(usbissdev, 'H', 100)

sensor = MCP9808.MCP9808(i2c_chan, 48)


# Optionally you can override the address and/or bus number:
#sensor = MCP9808.MCP9808(address=0x20, busnum=2)

# Initialize communication with the sensor.
sensor.begin()

# Print the Config Register