Skip to content

4upstream #42

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

Merged
merged 4 commits into from
Mar 8, 2022
Merged

4upstream #42

merged 4 commits into from
Mar 8, 2022

Conversation

bablokb
Copy link

@bablokb bablokb commented Mar 3, 2022

add getter/setter for proximity-gain (PGAIN) and gesture-gain (GGAIN).

@ladyada
Copy link
Member

ladyada commented Mar 3, 2022

hiya! thanks so much for submitting a PR! we can review & merge PRs once they have passed continuous integration (CI). that means that code is 'linted' - that means it is formatted and passes basic structure tests, so that we maintain the same text formatting for all new code
if your code isnt passing, check the CI output (click on the red X next to the PR to scroll through the log and find where the error is

here is a tutorial on pylint and black: https://learn.adafruit.com/improve-your-code-with-pylint

and overall how to contribute PRs to circuitpython: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

once you get that green checkmark that indicates CI has passed, please comment reply to this post so we know its time for another review (we may not get notified on CI pass and miss that its time to look!)

@bablokb
Copy link
Author

bablokb commented Mar 3, 2022

Hm, the log does not tell me why the check failed.

@ladyada
Copy link
Member

ladyada commented Mar 3, 2022

you need to run black, that part failed

black....................................................................Failed

@tekktrik tekktrik linked an issue Mar 3, 2022 that may be closed by this pull request
@bablokb
Copy link
Author

bablokb commented Mar 5, 2022

Hi, checks from CI are now successful

@ladyada
Copy link
Member

ladyada commented Mar 7, 2022

@caternuson wanna check it?

@caternuson
Copy link

Looks good and generally works:

Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> from adafruit_apds9960.apds9960 import APDS9960
>>> apds = APDS9960(board.I2C())
>>> apds.proximity_gain
0
>>> apds.proximity_gain = 3
>>> apds.proximity_gain
3
>>> apds.gesture_gain
2
>>> apds.gesture_gain = 0
>>> apds.gesture_gain
0
>>> 

@bablokb What do you think about adding a simple dictionary (or similar) to map the gain values, like 8x to the register values, like 3 and use that behind the scenes. That way users could think in terms of the actual gain values, for example:

# set gain to 8x 
apds.proximity_gain = 8

It looks like both prox gain and gesture gain have the same general mapping. So could use one for both.

And throw a ValueError exception for any invalid value.

# this should throw an exception
apds.proximity_gain = 100
# and this, since the is no 3x gain
apds.proximity_gain = 3

@bablokb
Copy link
Author

bablokb commented Mar 8, 2022

With a dictionary PGAIN and GGAIN would have a different logic than AGAIN (color_gain), unless you want to break existing code. What about adding constants PGAIN_1X and so on? We could add these constants also for color-gain without breaking things. But new code would be more readable.

Checking values and throwing ValueErrors is currently not consistent within the library. I will be happy to add that, but there is a footprint tradeoff. So this is more of a policy decision.

@caternuson
Copy link

Thanks. Good point about color_gain (AGAIN). I think being consistent is better at this point. My suggestion can be deferred to some later PR. You're also right that it'd be breaking. So would require some consideration.

@ladyada lgtm, including the _APDS9960_CONTROL change you flagged.

@ladyada ladyada merged commit 9bd4882 into adafruit:main Mar 8, 2022
@ladyada
Copy link
Member

ladyada commented Mar 8, 2022

thanks :)

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 18, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_APDS9960 to 3.1.0 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_APDS9960#42 from bablokb/4upstream
  > Fixed readthedocs build
  > Post-patch cleanup

Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS to 4.4.1 from 4.3.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_LSM6DS#52 from jerryneedell/jerryn_mlc

Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7789 to 1.5.6 from 1.5.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_ST7789#30 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L0X to 3.6.0 from 3.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL53L0X#35 from whogben/main
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 1.12.3 from 1.12.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#54 from masgari/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 8.2.2 from 8.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#159 from dhalbert/nus-doc-fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_LYWSD03MMC to 1.0.6 from 1.0.5:
  > Fixed readthedocs build

Updating https://github.com/adafruit/Adafruit_CircuitPython_MagTag to 2.1.8 from 2.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#82 from makermelissa/main
  > Merge pull request adafruit/Adafruit_CircuitPython_MagTag#81 from makermelissa/main
  > Fixed readthedocs build

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 5.3.0 from 5.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#106 from dgriswo/subscription_logging

Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 1.11.1 from 1.11.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#64 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_WSGI to 1.1.9 from 1.1.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_WSGI#13 from tekktrik/dev/clearer-bad-return
  > Fixed readthedocs build
  > Post-patch cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no method for setting pgain/ggain
3 participants