Skip to content

Fix #3 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions adafruit_emc2101.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def __str__(self):
lut_keys.sort()
for temp in lut_keys:
fan_drive = self.lut_values[temp]
value_strs.append("%d deg C => %.1f%% duty cycle" % (temp, fan_drive))
value_strs.append("%d deg C => %.1f%% duty cycle" %
(temp, fan_drive))

return "\n".join(value_strs)

Expand All @@ -175,7 +176,8 @@ def _set_lut(self, lut_dict):
# Verify that the value is a correct amount
lut_value = lut_dict[k]
if lut_value > 100.0 or lut_value < 0:
raise AttributeError("LUT values must be a fan speed from 0-100%")
raise AttributeError(
"LUT values must be a fan speed from 0-100%")

# add the current temp/speed to our internal representation
self.lut_values[k] = lut_value
Expand All @@ -190,16 +192,20 @@ def _set_lut(self, lut_dict):
for idx in range(lut_size):
current_temp = lut_keys[idx]
current_speed = _speed_to_lsb(self.lut_values[current_temp])
getattr(self, "_fan_lut_t%d" % (idx + 1)).__set__(self, current_temp)
getattr(self, "_fan_lut_s%d" % (idx + 1)).__set__(self, current_speed)
getattr(self, "_fan_lut_t%d" %
(idx + 1)).__set__(self, current_temp)
getattr(self, "_fan_lut_s%d" %
(idx + 1)).__set__(self, current_speed)

# self.emc_fan._lut_temp_setters[idx].__set__(self.emc_fan, current_temp)
# self.emc_fan._lut_speed_setters[idx].__set__(self.emc_fan, current_speed)

# Set the remaining LUT entries to the default (Temp/Speed = max value)
for idx in range(8)[lut_size:]:
getattr(self, "_fan_lut_t%d" % (idx + 1)).__set__(self, MAX_LUT_TEMP)
getattr(self, "_fan_lut_s%d" % (idx + 1)).__set__(self, MAX_LUT_SPEED)
getattr(self, "_fan_lut_t%d" %
(idx + 1)).__set__(self, MAX_LUT_TEMP)
getattr(self, "_fan_lut_s%d" %
(idx + 1)).__set__(self, MAX_LUT_SPEED)
self.emc_fan.lut_enabled = current_mode


Expand Down Expand Up @@ -399,7 +405,7 @@ def pwm_frequency(self):
def pwm_frequency(self, value):
if value < 0 or value > 0x1F:
raise AttributeError("pwm_frequency must be from 0-31")
self._pwm_freq_div = value
self._pwm_freq = value

@property
def pwm_frequency_divisor(self):
Expand Down