mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-08-06 00:35:44 +08:00
Add charging control
This commit is contained in:
Binary file not shown.
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user