Exemple #1
0
        public void Write(byte[] state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            if (state.Length != StateSize)
            {
                throw new ArgumentException("Length is invalid.", nameof(state));
            }

            _i2CBus.Execute(_address, bus => bus.Write(state));
        }
Exemple #2
0
        public HSPE16InputOnly(DeviceId id, I2CSlaveAddress address, II2CBusService i2cBus)
            : base(id, new MAX7311Driver(address, i2cBus))
        {
            byte[] setupAsInputs = { 0x06, 0xFF, 0xFF };
            i2cBus.Execute(address, b => b.Write(setupAsInputs));

            FetchState();
        }
        public HSPE16InputOnly(DeviceId id, I2CSlaveAddress address, II2CBusService i2cBus)
            : base(id, new MAX7311Driver(address, i2cBus))
        {
            byte[] setupAsInputs = { 0x06, 0xFF, 0xFF };
            i2cBus.Execute(address, b => b.Write(setupAsInputs));

            FetchState();
        }
Exemple #4
0
        public HSPE16InputOnly(string id, I2CSlaveAddress address, II2CBusService i2cBusService, IDeviceMessageBrokerService deviceMessageBrokerService, ILogger log)
            : base(id, new MAX7311Driver(address, i2cBusService), deviceMessageBrokerService, log)
        {
            byte[] setupAsInputs = { 0x06, 0xFF, 0xFF };
            i2cBusService.Execute(address, b => b.Write(setupAsInputs));

            FetchState();
        }
        public void ExecuteCommand(I2CHardwareBridgeCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            _i2CBus.Execute(_address, command.Execute, false);
        }
Exemple #6
0
        public void Write(byte[] state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            if (state.Length != StateSize)
            {
                throw new ArgumentException("Length is invalid.", nameof(state));
            }

            byte[] setConfigurationToOutput = { ConfigurationRegisterA, 0, 0 };
            byte[] setState = { OutputPortRegisterA, state[0], state[1] };

            _i2CBus.Execute(_address, bus =>
            {
                bus.Write(setConfigurationToOutput);
                bus.Write(setState);
            });
        }