Skip to content

Commit

Permalink
chore: revert back to int in fan_speed
Browse files Browse the repository at this point in the history
* TODO: fix convertion from PWM <-> RPM

Signed-off-by: Gonçalo Negrier Duarte <gonegrier.duarte@gmail.com>
  • Loading branch information
MrDuartePT committed Oct 13, 2024
1 parent 8b90b2b commit 0c998f4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions python/legion_linux/legion_linux/legion.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def get_dmesg(only_tail=False, filter_log=True):

@dataclass(order=True)
class FanCurveEntry:
fan1_speed: float # fan speed in rpm
fan2_speed: float # fan speed in rpm
fan1_speed: int # fan speed in rpm
fan2_speed: int # fan speed in rpm
cpu_lower_temp: int
cpu_upper_temp: int
gpu_lower_temp: int
Expand Down Expand Up @@ -793,7 +793,7 @@ def _write_file(file_path, value):
def _write_file_or(file_path, value):
if os.path.exists(file_path):
FanCurveIO._write_file(file_path, value)

def get_fan_1_max_rpm(self):
file_path = self.hwmon_path + self.fan1_max
return int(self._read_file(file_path))
Expand All @@ -813,10 +813,10 @@ def set_fan_2_speed_pwm(self, point_id, value):
self._write_file(file_path, value)

def set_fan_1_speed_rpm(self, point_id, value):
return self.set_fan_1_speed_pwm(point_id, round(value/self.get_fan_1_max_rpm()*255.0))
return self.set_fan_1_speed_pwm(point_id, round(value/self.get_fan_1_max_rpm()*255))

def set_fan_2_speed_rpm(self, point_id, value):
return self.set_fan_2_speed_pwm(point_id, round(value/self.get_fan_2_max_rpm()*255.0))
return self.set_fan_2_speed_pwm(point_id, round(value/self.get_fan_2_max_rpm()*255))

def set_lower_cpu_temperature(self, point_id, value):
point_id = self._validate_point_id(point_id)
Expand Down Expand Up @@ -869,10 +869,10 @@ def get_fan_2_speed_pwm(self, point_id):
return self._read_file(file_path)

def get_fan_1_speed_rpm(self, point_id):
return round(self.get_fan_1_speed_pwm(point_id)/255.0*self.get_fan_1_max_rpm(), ndigits=2)
return round(self.get_fan_1_speed_pwm(point_id)/255*self.get_fan_1_max_rpm())

def get_fan_2_speed_rpm(self, point_id):
return round(self.get_fan_2_speed_pwm(point_id)/255.0*self.get_fan_2_max_rpm(), ndigits=2)
return round(self.get_fan_2_speed_pwm(point_id)/255*self.get_fan_2_max_rpm())

def get_lower_cpu_temperature(self, point_id):
point_id = self._validate_point_id(point_id)
Expand Down

0 comments on commit 0c998f4

Please sign in to comment.