Skip to content

Commit

Permalink
Bugfixes0.9 (#59)
Browse files Browse the repository at this point in the history
Fix #47 JBD single temp sensor
Fix deviation calc
  • Loading branch information
Louisvdw authored Oct 4, 2021
1 parent 9170457 commit e6f0b73
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def get_midvoltage(self):
extra = 0 if (2*halfcount == self.cell_count) else self.cells[self.cell_count-1].voltage/2
# get the midpoint of the battery
midpoint = (half1voltage + half2voltage)/2 + extra
return midpoint, abs(1 - half1voltage/half2voltage)
return midpoint, abs(1 - half1voltage/half2voltage)*100

def get_balancing(self):
for c in range(min(len(self.cells), self.cell_count)):
Expand Down
10 changes: 6 additions & 4 deletions etc/dbus-serialbattery/lltjbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,23 @@ def read_gen_data(self):
return False

voltage, current, capacity_remain, capacity, self.cycles, self.production, balance, \
balance2, protection, version, self.soc, fet, self.cell_count, self.temp_sensors, temp1, temp2 \
= unpack_from('>HhHHHHhHHBBBBBHH', gen_data)
balance2, protection, version, self.soc, fet, self.cell_count, self.temp_sensors \
= unpack_from('>HhHHHHhHHBBBBB', gen_data)
self.voltage = voltage / 100
self.current = current / 100
self.capacity_remain = capacity_remain / 100
self.capacity = capacity / 100
self.to_temp(1, kelvin_to_celsius(temp1 / 10))
self.to_temp(2, kelvin_to_celsius(temp2 / 10))
self.to_cell_bits(balance, balance2)
self.version = float(str(version >> 4 & 0x0F) + "." + str(version & 0x0F))
self.to_fet_bits(fet)
self.to_protection_bits(protection)
self.max_battery_voltage = MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = MIN_CELL_VOLTAGE * self.cell_count

for t in range(self.temp_sensors):
temp1 = unpack_from('>H', gen_data, 23 + (2*t))[0]
self.to_temp(t + 1, kelvin_to_celsius(temp1 / 10))

return True

def read_cell_data(self):
Expand Down
2 changes: 1 addition & 1 deletion etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Constants - Need to dynamically get them in future
DRIVER_VERSION = 0.9
DRIVER_SUBVERSION = 'beta2'
DRIVER_SUBVERSION = ''
zero_char = chr(48)
degree_sign = u'\N{DEGREE SIGN}'
# Cell min/max voltages - used with the cell count to get the min/max battery voltage
Expand Down

0 comments on commit e6f0b73

Please sign in to comment.