Skip to content

Commit e3249be

Browse files
zeeexsixareNeonGalaxy75
authored andcommitted
Implement csouers 67-70% charging to preserve batt
1 parent 5a9f7dd commit e3249be

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

selfdrive/thermald.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ def thermald_thread():
195195
msg.thermal.freeSpace = avail
196196
with open("/sys/class/power_supply/battery/capacity") as f:
197197
msg.thermal.batteryPercent = int(f.read())
198+
199+
#begining of limit charging. read the charging enabled flag in to charging_enabled
200+
with open("/sys/class/power_supply/battery/charging_enabled") as f:
201+
charging_enabled = int(f.read())
202+
if msg.thermal.batteryPercent > 70 and charging_enabled:
203+
os.system("echo 0 > /sys/class/power_supply/battery/charging_enabled")
204+
elif msg.thermal.batteryPercent < 67 and not charging_enabled:
205+
os.system("echo 1 > /sys/class/power_supply/battery/charging_enabled")
206+
#end limit charging
207+
198208
with open("/sys/class/power_supply/battery/status") as f:
199209
msg.thermal.batteryStatus = f.read().strip()
200210
with open("/sys/class/power_supply/battery/current_now") as f:
@@ -262,7 +272,7 @@ def thermald_thread():
262272
should_start = should_start and msg.thermal.freeSpace > 0.02
263273

264274
# require usb power in passive mode
265-
should_start = should_start and (not passive or msg.thermal.usbOnline)
275+
#should_start = should_start and (not passive or msg.thermal.usbOnline)
266276

267277
# confirm we have completed training and aren't uninstalling
268278
should_start = should_start and accepted_terms and (passive or completed_training) and (not do_uninstall)

0 commit comments

Comments
 (0)