public double GetMillivolts(Channel channel, Gain gain = Gain.Volt5, SamplesPerSecond sps = SamplesPerSecond.SPS1600) {
            lock (deviceLock) {

                byte[] result = new byte[2];

                // Set disable comparator and set "single shot" mode	
                config = 0x0003 | 0x8000; // | 0x100;
                config |= (ushort)SamplePerSecondMap[(int)sps];
                config |= (ushort)channel;
                config |= (ushort)programmableGainMap[(int)gain];

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


                I2CDevice.Write(data);
                // delay in milliseconds
                //int delay = (1000.0 / SamplesPerSecondRate[(int)sps] + .1;
            //    int delay = 1;
                Task.Delay(TimeSpan.FromMilliseconds(.5)).Wait();

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

                //var r = (((result[0] << 8) | result[1]) >> 4);

                //Debug.WriteLine(r.ToString());

                return (ushort)(((result[0] << 8) | result[1]) >> 4) * programmableGain_Scaler[(int)gain] / 2048;
            }
        }
        public double GetMillivolts(Channel channel, Gain gain = Gain.Volt5, SamplesPerSecond sps = SamplesPerSecond.SPS1600)
        {
            lock (deviceLock) {
                byte[] result = new byte[2];

                // Set disable comparator and set "single shot" mode
                config  = 0x0003 | 0x8000; // | 0x100;
                config |= (ushort)SamplePerSecondMap[(int)sps];
                config |= (ushort)channel;
                config |= (ushort)programmableGainMap[(int)gain];

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


                I2CDevice.Write(data);
                // delay in milliseconds
                //int delay = (1000.0 / SamplesPerSecondRate[(int)sps] + .1;
                //    int delay = 1;
                Task.Delay(TimeSpan.FromMilliseconds(.5)).Wait();

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

                //var r = (((result[0] << 8) | result[1]) >> 4);

                //Debug.WriteLine(r.ToString());

                return((ushort)(((result[0] << 8) | result[1]) >> 4) * programmableGain_Scaler[(int)gain] / 2048);
            }
        }
        private int GetMillivolts(int channel)
        {
            SamplesPerSecond sps = SamplesPerSecond.SPS1600;


            byte[] data   = new byte[3];
            byte[] result = new byte[2];


            // Set disable comparator and set "single shot" mode
            config  = 0x0003 | 0x8000; // | 0x100;
            config |= (ushort)SamplePerSecondMap[(int)sps];
            config |= (ushort)programmableGainMap[(int)gain];


            switch (channel)
            {
            case (0):
                config |= ADS1015_REG_CONFIG_MUX_SINGLE_0;
                break;

            case (1):
                config |= ADS1015_REG_CONFIG_MUX_SINGLE_1;
                break;

            case (2):
                config |= ADS1015_REG_CONFIG_MUX_SINGLE_2;
                break;

            case (3):
                config |= ADS1015_REG_CONFIG_MUX_SINGLE_3;
                break;
            }


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


            I2CDevice.Write(data);
            // delay in milliseconds
            //int delay = (1000.0 / SamplesPerSecondRate[(int)sps] + .1;
            //    int delay = 1;
            //Task.Delay(TimeSpan.FromMilliseconds(.5)).Wait();
            Task.Delay(TimeSpan.FromMilliseconds(.5)).Wait();

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

            return((((result[0] << 8) | result[1]) >> 4) * programmableGain_Scaler[(int)gain] / 2048);
        }
Exemplo n.º 4
0
 public override string ToString()
 {
     return(Headroom.ToString() + ", " + Codec.ToString() + ": " + Samples.ToString() + " samples, " + SamplesPerSecond.ToString() + " samples/sec");
 }
Exemplo n.º 5
0
 public override string ToString()
 {
     return(Id.ToString() + ": " + Samples.ToString() + " samples, " + SamplesPerSecond.ToString() + " samples/sec, size: " + RoundSize.ToString());
 }
Exemplo n.º 6
0
 public override string ToString()
 {
     return(Unk1.ToString() + ", " + Unk6.ToString() + ": " + Samples.ToString() + " samples, " + SamplesPerSecond.ToString() + " samples/sec");
 }