Skip to content

Commit c495e12

Browse files
authored
Merge pull request #4 from MaxBec/hotfix_pwm_freq
Fix #3
2 parents c99e497 + 15d704e commit c495e12

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

adafruit_emc2101.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def __str__(self):
152152
lut_keys.sort()
153153
for temp in lut_keys:
154154
fan_drive = self.lut_values[temp]
155-
value_strs.append("%d deg C => %.1f%% duty cycle" % (temp, fan_drive))
155+
value_strs.append("%d deg C => %.1f%% duty cycle" %
156+
(temp, fan_drive))
156157

157158
return "\n".join(value_strs)
158159

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

180182
# add the current temp/speed to our internal representation
181183
self.lut_values[k] = lut_value
@@ -190,16 +192,20 @@ def _set_lut(self, lut_dict):
190192
for idx in range(lut_size):
191193
current_temp = lut_keys[idx]
192194
current_speed = _speed_to_lsb(self.lut_values[current_temp])
193-
getattr(self, "_fan_lut_t%d" % (idx + 1)).__set__(self, current_temp)
194-
getattr(self, "_fan_lut_s%d" % (idx + 1)).__set__(self, current_speed)
195+
getattr(self, "_fan_lut_t%d" %
196+
(idx + 1)).__set__(self, current_temp)
197+
getattr(self, "_fan_lut_s%d" %
198+
(idx + 1)).__set__(self, current_speed)
195199

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

199203
# Set the remaining LUT entries to the default (Temp/Speed = max value)
200204
for idx in range(8)[lut_size:]:
201-
getattr(self, "_fan_lut_t%d" % (idx + 1)).__set__(self, MAX_LUT_TEMP)
202-
getattr(self, "_fan_lut_s%d" % (idx + 1)).__set__(self, MAX_LUT_SPEED)
205+
getattr(self, "_fan_lut_t%d" %
206+
(idx + 1)).__set__(self, MAX_LUT_TEMP)
207+
getattr(self, "_fan_lut_s%d" %
208+
(idx + 1)).__set__(self, MAX_LUT_SPEED)
203209
self.emc_fan.lut_enabled = current_mode
204210

205211

@@ -399,7 +405,7 @@ def pwm_frequency(self):
399405
def pwm_frequency(self, value):
400406
if value < 0 or value > 0x1F:
401407
raise AttributeError("pwm_frequency must be from 0-31")
402-
self._pwm_freq_div = value
408+
self._pwm_freq = value
403409

404410
@property
405411
def pwm_frequency_divisor(self):

0 commit comments

Comments
 (0)