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); }