Ejemplo n.º 1
0
        public bool Write(byte[] value)
        {
            if (_initialised)
            {
                var result = _i2cDevice.Write(value);
                return(result);
            }

            return(false);
        }
Ejemplo n.º 2
0
        protected async Task <double> GetMillivolts(ushort channel, ushort gain, ushort samplesPerSecond)
        {
            using (var l = await _locker.LockAsync())
            {
                var result = new byte[2];
                var data   = new byte[3];

                // Set disable comparator and set "single shot" mode
                var config = 0x0003 | 0x8000;
                config |= samplesPerSecond;
                config |= channel;
                config |= gain;

                data[0] = REG_CFG;
                data[1] = (byte)((config >> 8) & 0xFF);
                data[2] = (byte)(config & 0xFF);

                _i2Cdevice.Write(data);

                await Task.Delay(5);

                _i2Cdevice.WriteRead(new byte[] { (byte)REG_CONV, 0x00 }, result);

                return((ushort)(((result[0] << 8) | result[1]) >> 4) * gain.ForADS1015Scale() / 2048);
            }
        }
Ejemplo n.º 3
0
        public int Write(int value)
        {
            if (_initialised)
            {
                // Only write HIGH the values of the ports that have been initialised as
                // outputs updating the output shadow of the device
                _shadow = (value & ~(_dirMask));

                var result = _i2cDevice.Write(_shadow);
                return(result == true ? 1 : 0);
            }
            return(1);
        }