Skip to content

Conversation

@rtyley
Copy link
Contributor

@rtyley rtyley commented Jun 27, 2022

The AW9523 supports 256-step linear constant-current dimming when LED driving. As noted in the datasheet introduction, the maximum current can be configured:

https://cdn-shop.adafruit.com/product-files/4886/AW9523+English+Datasheet.pdf

The default maximum current (IMAX) is 37mA, and IMAX can be changed in GCR register.

In Table 10 ("GCR, Global control register (11H)"), the datasheet explains that 4 possible current ranges can be selected - maintaining the 256-step granularity over a shorter current range:

D[1:0] is used to configure the max drive current of LED. AW9523B set max current IMAX to 37mA(typical) default, and through register ISEL[1:0] can set to IMAX×1/4,IMAX×2/4, IMAX×3/4,IMAX, so the 256 step dimming range changes.

This change updates the adafruit_aw9523.AW9523 class to have a constant_current_range selector field that can be used to set the register value. The 4 options are provided as constants (AW9523_4_4_RANGE, AW9523_3_4_RANGE, etc).

An example of using this code would be:

aw = adafruit_aw9523.AW9523(i2c) aw.constant_current_range = adafruit_aw9523.AW9523_3_4_RANGE

cc @FoamyGuy

@rtyley rtyley force-pushed the add-constant-current-range-selector branch 2 times, most recently from f331f24 to 5f6fb17 Compare June 27, 2022 16:31
The AW9523 supports 256-step linear constant-current dimming when LED driving. As noted in the datasheet introduction, the maximum current can be configured: https://cdn-shop.adafruit.com/product-files/4886/AW9523+English+Datasheet.pdf > The default maximum current (IMAX) is 37mA, and IMAX can be changed in GCR > register. In Table 10 ("GCR, Global control register (11H)"), the datasheet explains that 4 possible current ranges can be selected - maintaining the 256-step granularity over a shorter current range: > D[1:0] is used to configure the max drive current of LED. AW9523B set max > current IMAX to 37mA(typical) default, and through register ISEL[1:0] can > set to IMAX×1/4,IMAX×2/4, IMAX×3/4,IMAX, so the 256 step dimming range changes. This change updates the `adafruit_aw9523.AW9523` class to have a `constant_current_range` selector field that can be used to set the register value. The 4 options are provided as constants (`AW9523_4_4_RANGE`, `AW9523_3_4_RANGE`, etc). An example of using this code would be: ``` aw = adafruit_aw9523.AW9523(i2c) aw.constant_current_range = adafruit_aw9523.AW9523_3_4_RANGE ```
@rtyley rtyley force-pushed the add-constant-current-range-selector branch from 5f6fb17 to 792c2b0 Compare June 27, 2022 16:43
Copy link
Member

@ladyada ladyada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, didnt test but also looks like it wont break anything :)

@ladyada ladyada merged commit fa0aad9 into adafruit:main Jun 28, 2022
@rtyley
Copy link
Contributor Author

rtyley commented Jun 29, 2022

Thanks @ladyada! Here's a short demo (4x speed-up) of the new constant_current_range setting in action (code):

Adafruit_CircuitPython_AW9523.PR-6.ConstantCurrentRange.mp4
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 30, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_AW9523 to 1.1.0 from 1.0.6: > Merge pull request adafruit/Adafruit_CircuitPython_AW9523#6 from rtyley/add-constant-current-range-selector Updating https://github.com/adafruit/Adafruit_CircuitPython_DPS310 to 2.1.5 from 2.1.4: > Merge pull request adafruit/Adafruit_CircuitPython_DPS310#24 from tekktrik/dev/fix-units Updating https://github.com/adafruit/Adafruit_CircuitPython_GC_IOT_Core to 3.2.3 from 3.2.2: > Merge pull request adafruit/Adafruit_CircuitPython_GC_IOT_Core#26 from JulianOrteil/type-annotations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants