Exemplo n.º 1
0
def init():
    #somehow enables piface
    pifacedigital = pifacedigitalio.PiFaceDigital()

    #######################################################################
    # IO expander setup SPI piFace2 (for conveyor relay control)
    #######################################################################

    wiringpi.mcp23s17Setup(PIFACE, 0, 0)
Exemplo n.º 2
0
    def enable_device():
        """enable the specified device """
        try:
            devices = cm.hardware.devices

            for key in devices.keys():
                device = key
                device_slaves = devices[key]

                if device.lower() == "mcp23008":
                    for slave in device_slaves:
                        params = slave
                        wiringpi.mcp23008Setup(int(params['pinBase']),
                                               int(params['i2cAddress'], 16))

                elif device.lower() == "mcp23s08":
                    for slave in device_slaves:
                        params = slave
                        wiringpi.mcp23s08Setup(int(params['pinBase']),
                                               int(params['spiPort'], 16),
                                               int(params['devId']))

                elif device.lower() == "mcp23016":
                    for slave in device_slaves:
                        params = slave
                        wiringpi.mcp23016Setup(int(params['pinBase']),
                                               int(params['i2cAddress'], 16))

                elif device.lower() == "mcp23017":
                    for slave in device_slaves:
                        params = slave
                        wiringpi.mcp23017Setup(int(params['pinBase']),
                                               int(params['i2cAddress'], 16))

                elif device.lower() == "mcp23s17":
                    for slave in device_slaves:
                        params = slave
                        wiringpi.mcp23s17Setup(int(params['pinBase']),
                                               int(params['spiPort'], 16),
                                               int(params['devId']))

                elif device.lower() == "sr595":
                    for slave in device_slaves:
                        params = slave
                        wiringpi.sr595Setup(int(params['pinBase']),
                                            int(params['numPins']),
                                            int(params['dataPin']),
                                            int(params['clockPin']),
                                            int(params['latchPin']))

                elif device.lower() == "pcf8574":
                    for slave in device_slaves:
                        params = slave
                        wiringpi.pcf8574Setup(int(params['pinBase']),
                                              int(params['i2cAddress'], 16))

                else:
                    logging.error(
                        "Device defined is not supported, please check "
                        "your devices settings: " + str(device))
        except Exception as error:
            logging.debug(
                "Error setting up devices, please check your devices "
                "settings.")
            logging.debug(error)