Class Max1704x
Base class for MAX1704x fuel gauge family, which monitors battery state of charge for lithium-ion batteries
Assembly: Max17043.dll
View Source
public abstract class Max1704x : II2cPeripheral, IVoltageSensor, ISensor<Voltage>, IStateOfChargeSensor, ISensor<double>, ISensor
Derived:
Meadow.Foundation.Sensors.Battery.Max17043
Implements:
Meadow.Hardware.II2cPeripheral
, Meadow.Peripherals.Sensors.IVoltageSensor
, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Voltage>
, Meadow.Peripherals.Sensors.IStateOfChargeSensor
, Meadow.Peripherals.Sensors.ISensor<System.Double>
, Meadow.Peripherals.Sensors.ISensor
Properties
DefaultI2cAddress
The default I2C address for the peripheral
View Source
public byte DefaultI2cAddress { get; }
Version
Gets the version of the MAX1704x chip
View Source
public byte Version { get; }
Voltage
Last value read from the Voltage sensor.
View Source
public Voltage? Voltage { get; }
Methods
ReadVoltage()
Reads the current battery voltage
View Source
public ValueTask<Voltage> ReadVoltage()
Returns
System.Threading.Tasks.ValueTask<Meadow.Units.Voltage>
: The battery voltage in volts### ReadStateOfCharge()
Reads the current state of charge (battery percentage)
View Source
public ValueTask<double> ReadStateOfCharge()
Returns
System.Threading.Tasks.ValueTask<System.Double>
: Battery percentage from 0.0 to 100.0### SetAlertThreshold(int)
Sets the alert threshold for low battery
View Source
public void SetAlertThreshold(int percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | percent | Alert threshold percentage (1-32) |
Exceptions
System.ArgumentOutOfRangeException
Thrown when percent is outside the valid range of 1-32
IsAlertSet()
Checks if the alert flag is currently set
View Source
public bool IsAlertSet()
Returns
System.Boolean
: True if the alert flag is set, otherwise false### ClearAlert()
Clears the alert flag
View Source
public void ClearAlert()
SetSleepMode(bool)
Sets or clears the sleep mode of the fuel gauge
View Source
public void SetSleepMode(bool sleep)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | sleep | True to enter sleep mode, false to exit sleep mode |
Events
LowChargeAlert
Event that fires when battery charge falls below alert threshold
View Source
public event EventHandler<double>? LowChargeAlert
Event Type
System.EventHandler<System.Double>
Implements
Meadow.Hardware.II2cPeripheral
Meadow.Peripherals.Sensors.IVoltageSensor
Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Voltage>
Meadow.Peripherals.Sensors.IStateOfChargeSensor
Meadow.Peripherals.Sensors.ISensor<System.Double>
Meadow.Peripherals.Sensors.ISensor