Ejemplo n.º 1
0
        public LightSensor(AnaloguePort port, int deviceAddress, II2CDeviceFactory i2CDeviceFactory, bool normalizeValue = true) : base(port, deviceAddress, i2CDeviceFactory)
        {
            _normalizeValue = normalizeValue;
            var(pin1, _)    = Port.ToPinPair();
            var bus = I2CDeviceFactory.GetOrCreateI2CDevice(deviceAddress);

            _adc = new AnalogueDigitalConverter(bus, pin1);
            AddToDisposables(_adc);
        }
Ejemplo n.º 2
0
        public async Task SetDateTime(DateTime dateTime)
        {
            if (family != "Windows.Desktop")
            {
                var slave = await I2CDeviceFactory.GetI2CDevice(_deviceType);

                using (_rtc = new SainSmart_DS_1307_RTC(slave))
                {
                    _rtc.SetDateTime(dateTime);
                }
            }
            else
            {
                Debug.WriteLine("This is not a ARM device.");
            }
        }
Ejemplo n.º 3
0
        public async Task <DateTime> GetDateTime()
        {
            DateTime returnDate = DateTime.MinValue;

            if (family != "Windows.Desktop")
            {
                var slave = await I2CDeviceFactory.GetI2CDevice(_deviceType);

                using (_rtc = new SainSmart_DS_1307_RTC(slave))
                {
                    returnDate = _rtc.GetDateTimeNow();
                }
            }
            else
            {
                Debug.WriteLine("This is not a ARM device.");
            }

            return(returnDate);
        }
        public async Task <float> ReadHumidity()
        {
            float returnValue = -1;

            if (family != "Windows.Desktop")
            {
                var slave = await I2CDeviceFactory.GetI2CDevice(_deviceType);

                if (slave != null)
                {
                    using (_bme280 = new BME280_Sensor(slave))
                    {
                        returnValue = await _bme280.ReadHumidity();
                    }
                }
            }
            else
            {
                Debug.WriteLine("This is not a ARM device.");
            }

            return(returnValue);
        }
 protected static void Init(I2CDeviceFactory singleton)
 {
     Singleton = singleton;
 }