-
Notifications
You must be signed in to change notification settings - Fork 5
Add UV Index, use adafruit_register #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
Conversation
Is using register necessary? It's a simple sensor and bringing in register will make it potentially not usable on small boards. |
Probably not necessary, I really just noticed that some of the functionality here could be covered by using it. I think that was just my understanding of the design guide, but definitely understand the argument for avoiding it. This shouldn't be too difficult to refactor out if we go that route. |
Added @adafruit/circuitpythonlibrarians as reviewers so others can comments. |
Oh never mind, the design guide only specifies |
My two cents is to leave it out for now. I only consider using the register lib for a device if there are a lot of registers broken up into various smaller bits that control a guzillion internal settings. The SI1145 only has a few, like But the counter argument is the abstracting out of all the bit shifting / masking foo that the register lib provides for the sake of code safety. |
I'm out during the next meeting, but maybe this worth bringing up on the Monday meeting? I can add it and just listen to the meeting after the fact. |
adafruit_si1145.py
Outdated
SI1145_PARAM_WR = const(0x17) | ||
SI1145_COMMAND = const(0x18) | ||
SI1145_RESPONSE = const(0x20) | ||
SI1145_ALS_VIS_DATA0 = const(0x22) | ||
SI1145_UV_INDEX_DATA0 = const(0x2C) | ||
SI1145_PARAM_RD = const(0x2E) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We chatted about this in the meeting today. Basically, you should use register if its model matches the device's registers.
You can save space in this library by reducing these variables to, for example, _UV_INDEX_DATA0 = const(0x2c)
. For const
to drop a variable name it must start with _
, otherwise the whole variable name is kept around in case code outside this module references it. (_
prefix in Python implies that something should be private.) You can also drop the SI1145
bit because it duplicates the context of the file/module name that already includes si1145
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tekktrik Agree with above. OK to use register and please add the _
. I just forgot about that being a requirement. Also the degree to which the const names need to be unique, i.e. having SI1145
in all of them.
I don't have the hardware but did by best to resolve #1 by adding the UV index functionaliy. Some other changes happened along the way:
_i2c
is nowi2c_device
, because that's whatadafruit_register
expectsadafruit_register
while I was in there, as well as a few other things, but some things made more sense not to based on the way RAM+offset writes happen as well