Ejemplo n.º 1
0
        //Method to write 0x03 to the humidity control register
        private async Task WriteControlRegisterHumidityAsync()
        {
            byte[] writeBuffer = new byte[] { (byte)eRegisters.BME280_REGISTER_CONTROLHUMID, 0x03 };
            bme280.Write(writeBuffer);
            await Task.Delay(1);

            return;
        }
Ejemplo n.º 2
0
 protected override void Write(Stm32Command command, ushort data, bool dataAvailable)
 {
     if (dataAvailable)
     {
         _gpioExpander.WriteAddressWord(Unsafe.As <Stm32Command, byte>(ref command), data);
     }
     else
     {
         _gpioExpander.Write(Unsafe.As <Stm32Command, byte>(ref command));
     }
 }
        public override void Execute(II2CDevice i2CDevice)
        {
            i2CDevice.Write(GenerateClearSignalCachePackage());

            int offset = 0;
            while (offset < _signal.Length)
            {
                var buffer = _signal.Skip(offset).Take(30).ToArray();
                offset += buffer.Length;

                i2CDevice.Write(GenerateFillSignalCachePackage(buffer));
            }

            i2CDevice.Write(GenerateSendCachedSignalPackage());
        }
Ejemplo n.º 4
0
        public override void Execute(II2CDevice i2CDevice)
        {
            i2CDevice.Write(GenerateClearSignalCachePackage());

            int offset = 0;

            while (offset < _signal.Length)
            {
                var buffer = _signal.Skip(offset).Take(30).ToArray();
                offset += buffer.Length;

                i2CDevice.Write(GenerateFillSignalCachePackage(buffer));
            }

            i2CDevice.Write(GenerateSendCachedSignalPackage());
        }
Ejemplo n.º 5
0
        internal void WriteBytes(byte address, byte[] values)
        {
            byte[] buffer = new byte[1 + values.Length];
            buffer[0] = address;
            Array.Copy(values, 0, buffer, 1, values.Length);

            _device.Write(buffer);
        }
Ejemplo n.º 6
0
        public override void Execute(II2CDevice i2CDevice)
        {
            i2CDevice.Write(GenerateRegisterSensorPackage());

            byte[] buffer = new byte[9];
            i2CDevice.Read(buffer);

            ParseResponse(buffer);
        }
        public override void Execute(II2CDevice i2CDevice)
        {
            i2CDevice.Write(GenerateRegisterSensorPackage());

            byte[] buffer = new byte[9];
            i2CDevice.Read(buffer);

            ParseResponse(buffer);
        }
Ejemplo n.º 8
0
        // public static UInt32 Read32Bits(II2CDevice device, byte reg, ByteOrder byteOrder, string exceptionMessage)
        // {
        //     try
        //     {
        //         byte[] data = ReadBytes(device, reg, 4, exceptionMessage);

        //         switch (byteOrder)
        //         {
        //             case ByteOrder.BigEndian:
        //                 return (UInt32)((data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]);

        //             case ByteOrder.LittleEndian:
        //                 return (UInt32)((data[3] << 24) | (data[2] << 16) | (data[1] << 8) | data[0]);

        //             default:
        //                 throw new SensorException($"Unsupported byte order {byteOrder}");
        //         }
        //     }
        //     catch (Exception exception)
        //     {
        //         throw new SensorException(exceptionMessage, exception);
        //     }
        // }

        public static byte[] ReadBytes(II2CDevice device, byte reg, int count, string exceptionMessage)
        {
            try
            {
                byte[] addr = { reg };

                byte[] data = new byte[count];

                device.Write(reg);
                for (int i = 0; i < count; ++i)
                {
                    data[i] = device.ReadAddressByte(reg);
                }
                return(data);
                //return device.ReadAddressBlock(reg, count);
            }
            catch (Exception exception)
            {
                throw new SensorException(exceptionMessage, exception);
            }
        }
 public override void Execute(II2CDevice i2CDevice)
 {
     i2CDevice.Write(ToPackage());
 }
Ejemplo n.º 10
0
 public void Execute(II2CDevice i2CDevice)
 {
     i2CDevice.Write(ToPackage());
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Setzt die 8 Pins des Port Expanders auf High oder Low
 /// </summary>
 /// <param name="data">1 Byte mit den 8 Zuständen</param>
 public void Write(byte data)
 {
     this.data = data;
     dev.Write((byte)(data | mask));
 }