Пример #1
0
        internal bool SetValue(byte[] data)
        {
            BatteryValue newValue = null;

            switch (Mode)
            {
            case BatteryMode.All:
            {
                newValue = UIReadMethods.BatteryValue(data, 0);
                break;
            }

            case BatteryMode.Level:
            {
                newValue = new BatteryValue(Mode)
                {
                    Level = UIReadMethods.BatteryValueLevel(data, 0)
                };
                break;
            }
            }

            bool hasChanged = (Value != newValue);

            if (hasChanged)
            {
                Value = newValue;
                if (MonitorEvents)
                {
                    ValueChanged?.Invoke(newValue);
                }
            }
            return(hasChanged);
        }
Пример #2
0
        /// <summary>
        /// Gets all battery information
        /// </summary>
        /// <returns></returns>
        public async Task <BatteryValue> GetValue()
        {
            BatteryValue value = await UIReadMethods.GetBatteryValue(Brick.Socket);

            Value = value;
            return(value);
        }