Add charging control

This commit is contained in:
dragonpilot
2019-09-20 15:49:58 +10:00
parent 11555e198e
commit ced9202c46
3 changed files with 18 additions and 0 deletions
+3
View File
@@ -122,6 +122,9 @@ keys = {
"DragonGreyPandaMode": [TxType.PERSISTENT],
"DragonDrivingUI": [TxType.PERSISTENT],
"DragonDisplaySteeringLimitAlert": [TxType.PERSISTENT],
"DragonChargingCtrl": [TxType.PERSISTENT],
"DragonCharging": [TxType.PERSISTENT],
"DragonDisCharging": [TxType.PERSISTENT],
}
@@ -42,6 +42,9 @@ default_conf = {
'DragonGreyPandaMode': '0',
'DragonDrivingUI': '1',
'DragonDisplaySteeringLimitAlert': '1',
'DragonChargingCtrl': '0',
'DragonCharging': 70,
'DragonDisCharging': 60,
}
deprecated_conf = {
+12
View File
@@ -152,8 +152,13 @@ def thermald_thread():
# Make sure charging is enabled
charging_disabled = False
os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled')
# dragonpilot
ts_last_ip = 0.
ip_addr = '255.255.255.255'
dragon_charging_ctrl = True if params.get('DragonChargingCtrl') == "1" else False
dragon_charging_max = params.get('DragonCharging')
dragon_discharging_min = params.get('DragonDisCharging')
while 1:
health = messaging.recv_sock(health_sock, wait=True)
@@ -297,6 +302,13 @@ def thermald_thread():
location=(location.to_dict() if location else None),
thermal=msg.to_dict())
# we only update charging status once per min
if dragon_charging_ctrl:
if msg.thermal.batteryPercent >= dragon_charging_max:
os.system('echo "0" > /sys/class/power_supply/battery/charging_enabled')
if msg.thermal.batteryPercent <= dragon_discharging_min:
os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled')
count += 1