You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def reflected_light_intensity(self):
"""
Reflected light intensity as a percentage. Light on sensor is red.
"""
if self.auto_mode:
self.mode = self.MODE_COL_REFLECT
return self.value(0)
Is there a scenario where auto_mode would be False? Doesn't seem like anything would work if it were unless the user also did self.mode = self.MODE_COL_REFLECT so you have the same behavior in the end. I'm scratching my head a bit on why we have this.
Every sensor has auto_mode field. When it is on, the appropriate mode will be selected before reading a value (e.g. when we read RGB from color sensor, it's mode will be set to 'RAW'). When it is off, user have to make sure sensor is in correct mode. This makes sense when user needs as much performance as possible.
The mode has to be set correctly anyway though...I'm missing how it increases performance by having the user set the mode vs us setting it for them? We could just cache what the current mode is and only update that attribute when it needs to be in a different mode....then we could chop the auto_mode variable.
User can set the mode once and read the value many times. Caching current mode could work as long as we assume no one will change the mode from under our feet (e.g. another thread or process).
Activity
dlech commentedon Sep 20, 2017
dwalton76 commentedon Sep 23, 2017
Is there a scenario where auto_mode would be False? Doesn't seem like anything would work if it were unless the user also did
self.mode = self.MODE_COL_REFLECTso you have the same behavior in the end. I'm scratching my head a bit on why we have this.dwalton76 commentedon Sep 23, 2017
TouchSensor class also has the mysterious self.auto_mode
ddemidov commentedon Sep 23, 2017
Every sensor has
auto_modefield. When it is on, the appropriate mode will be selected before reading a value (e.g. when we read RGB from color sensor, it's mode will be set to 'RAW'). When it is off, user have to make sure sensor is in correct mode. This makes sense when user needs as much performance as possible.dwalton76 commentedon Sep 23, 2017
The mode has to be set correctly anyway though...I'm missing how it increases performance by having the user set the mode vs us setting it for them? We could just cache what the current mode is and only update that attribute when it needs to be in a different mode....then we could chop the auto_mode variable.
ddemidov commentedon Sep 23, 2017
User can set the mode once and read the value many times. Caching current mode could work as long as we assume no one will change the mode from under our feet (e.g. another thread or process).