Skip to content

fix percentage calculation - now expects 4.2V battery #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions adafruit_lc709203f.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

LC709023F_I2CADDR_DEFAULT = const(0x0B)
LC709203F_CMD_ICVERSION = const(0x11)
LC709203F_CMD_BATTPROF = const(0x12)
LC709203F_CMD_POWERMODE = const(0x15)
LC709203F_CMD_APA = const(0x0B)
LC709203F_CMD_INITRSOC = const(0x07)
Expand Down Expand Up @@ -100,6 +101,7 @@ def __init__(self, i2c_bus, address=LC709023F_I2CADDR_DEFAULT):
self._buf = bytearray(10)
self.power_mode = PowerMode.OPERATE # pylint: disable=no-member
self.pack_size = PackSize.MAH500 # pylint: disable=no-member
self.battery_profile = 1
self.init_RSOC()

def init_RSOC(self): # pylint: disable=invalid-name
Expand Down Expand Up @@ -132,6 +134,17 @@ def power_mode(self, mode):
raise AttributeError("power_mode must be a PowerMode")
self._write_word(LC709203F_CMD_POWERMODE, mode)

@property
def battery_profile(self):
"""Returns current battery profile (0 or 1)"""
return self._read_word(LC709203F_CMD_BATTPROF)

@battery_profile.setter
def battery_profile(self, mode):
if not mode in (0, 1):
raise AttributeError("battery_profile must be 0 or 1")
self._write_word(LC709203F_CMD_BATTPROF, mode)

@property
def pack_size(self):
"""Returns current battery pack size"""
Expand Down