mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-06 00:36:32 +08:00
Move thermald hardware calls into HW abstraction layer (#2630)
* abstracted away hardware calls * oopsie * remove bugs * remove bugs #2 * fix unit test * removed print Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
@@ -300,3 +300,32 @@ class Android(HardwareBase):
|
||||
network_strength = max(network_strength, ns)
|
||||
|
||||
return network_strength
|
||||
|
||||
def get_battery_capacity(self):
|
||||
return self.read_param_file("/sys/class/power_supply/battery/capacity", int, 100)
|
||||
|
||||
def get_battery_status(self):
|
||||
# This does not correspond with actual charging or not.
|
||||
# If a USB cable is plugged in, it responds with 'Charging', even when charging is disabled
|
||||
return self.read_param_file("/sys/class/power_supply/battery/status", lambda x: x.strip(), '')
|
||||
|
||||
def get_battery_current(self):
|
||||
return self.read_param_file("/sys/class/power_supply/battery/current_now", int)
|
||||
|
||||
def get_battery_voltage(self):
|
||||
return self.read_param_file("/sys/class/power_supply/battery/voltage_now", int)
|
||||
|
||||
def get_battery_charging(self):
|
||||
# This does correspond with actually charging
|
||||
return self.read_param_file("/sys/class/power_supply/battery/charge_type", lambda x: x.strip() != "N/A", True)
|
||||
|
||||
def set_battery_charging(self, on):
|
||||
with open('/sys/class/power_supply/battery/charging_enabled', 'w') as f:
|
||||
f.write(f"{1 if on else 0}\n")
|
||||
|
||||
def get_usb_present(self):
|
||||
return self.read_param_file("/sys/class/power_supply/usb/present", lambda x: bool(int(x)), False)
|
||||
|
||||
def get_current_power_draw(self):
|
||||
# We don't have a good direct way to measure this on android
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user