-
Notifications
You must be signed in to change notification settings - Fork 7
Description
As reported on the forum: https://forums.adafruit.com/viewtopic.php?t=199790
Trying to use the LUT example results in:
Lut: 27 deg C => 25.0% duty cycle
34 deg C => 50.0% duty cycle
42 deg C => 75.0% duty cycle
Traceback (most recent call last):
File "<stdin>", line 45, in <module>
File "adafruit_emc2101/emc2101_ext.py", line 230, in fan_speed
File "adafruit_emc2101/__init__.py", line 267, in fan_speed
File "adafruit_register/i2c_struct.py", line 80, in __get__
AttributeError: 'super' object has no attribute 'i2c_device'Can anyone with the module test it on a Circuitpython board and confirm ?
I don't pretend to understand why it's that error, but when I did some tests I ended up noticing that in Circuitpython you can't override @property accessors from subclasses, which emc2101_ext and emc2101_sub do.
Here is where it does it for example:
Adafruit_CircuitPython_EMC2101/adafruit_emc2101/emc2101_ext.py
Lines 223 to 230 in aea77f5
| @property | |
| def fan_speed(self): | |
| """The current speed in Revolutions per Minute (RPM). | |
| :return: float speed in RPM. | |
| """ | |
| self._check_status() | |
| return super().fan_speed |
This works in C python, but not in Circuitpython.
class Thing:
def __init__(self, i2c):
self.i2c_device = i2c
@property
def i2c(self):
print(self)
return self.i2c_device
class Thing_sub(Thing):
def __init__(self, i2c):
super().__init__(i2c)
@property
def i2c(self):
return super().i2c
c = Thing_sub("I2C")
print(c.i2c)code.py output:
<super: <class 'Thing_sub'>, <Thing_sub object at 0x3fd8c9a0>>
Traceback (most recent call last):
File "code.py", line 17, in <module>
File "code.py", line 14, in i2c
File "code.py", line 7, in i2c
AttributeError: 'super' object has no attribute 'i2c_device'
It's like super().i2c does call the i2c getter but with self being some super object that isn't what it should be ?
I don't know what a solution would be, maybe change the accessor methods to call a _set_fan_speed() method that could be overloaded in the sub classes, and called with super() as needed, since that form of overloading is known to work.