adafruit / Adafruit_CircuitPython_CCS811

circuit python driver for CCS811 air quality sensor
MIT License
34 stars 24 forks source link

eCO2 and TVOC return values #11

Closed hukuzatuna closed 6 years ago

hukuzatuna commented 6 years ago

The eCO2 and TVOC methods should return int instead of NoneType (so the values can be used in formatted print statements.)

tannewt commented 6 years ago

It does return an int. Are you talking about the behavior when data isn't ready?

hukuzatuna commented 6 years ago

I'm sorry, I wasn't clear. Yes, when data are not ready it returns None, which causes print() to throw an error (can't convert NoneType to Int). Now, I can solve that with a Try/Except but the behavior between the CCS811, which returns None before initialization completes, and the SGP30, which returns an int (zero) are inconsistent. (Actually, I didn't check to see if the SGP30 was returning int before initialization - I should go read the source).

Feel free to close if this should be solved by the end user instead of the module. Suggested fix is to change "self.eCO2 = None" (and the corresponding line for TVOC) to "self.eCO2 = 0" in the class definition.

tannewt commented 6 years ago

Would it be ok if we just blocked until the data was ready?

hukuzatuna commented 6 years ago

Totally. That's the right solution anyway. :-) Thanks for taking time to consider it!

tannewt commented 6 years ago

Heh, mind changing the behavior for me? :-D

hukuzatuna commented 6 years ago

Happy to!

tannewt commented 6 years ago

Awesome! Thanks!

hukuzatuna commented 6 years ago

Closing because most recent master does not exhibit the failure I was trying to fix.