Skip to content
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

Sm2335 5-channel LED driver #15839

Merged
merged 10 commits into from
Jun 22, 2022
Merged

Conversation

Cossid
Copy link
Contributor

@Cossid Cossid commented Jun 22, 2022

Description:

Adds an I2C-based light driver for the SM2335(EGH) controller. This chip is used by e.g. SwitchBot Color Bulbs.

It was created based on chip datasheet from the original manufacturer. It supports (as far as I can tell) all features of the original driver.

Notes to reviewer: This I2C has a large current range, and rather than hard-code values, I took an approach similar to SM2135's "model" method, but instead made it more of a linear "power factor" setting rather than specific model mapping, and left all color correction to the SetOption37 feature. As a result, this will take up a total of 17 AGPIO mappings. This approach will use the lowest and safest value by default while given users the ability to change current levels without code changes. If there is a different/better way to do this, please advise. Please verify I set the AGPIO mappings correctly to not break any others, as I am not 100% familiar with this process. Additionally, there is a comment that notes the size added by the driver for each config, and I could not see how to calculate that (program size in platformio does not break out individual files). Please correct changelog commit if this does not go out in the next release or it was inappropriate to add.

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works with Tasmota core ESP32 V.2.0.3
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@arendst
Copy link
Owner

arendst commented Jun 22, 2022

Thx for your input.

I guess the driver works for you. As my goal is to not only provide working drivers but also make them codewise as small as possible I suggest you go over the code and remove the many redundant code. Look at for next loops and use arrays. At first look you might save at least 500 bytes.

Also do not enable this driver as default. The ESP8266 image sizes are already reaching the high watermark so I would like to keep control over this.

@Cossid
Copy link
Contributor Author

Cossid commented Jun 22, 2022

Changes have been pushed which:

  • Reduce code by replacing redundant calls with for loops
  • Disable by default on ESP8266 and enable by default on ESP32

@arendst please re-review.

@arendst
Copy link
Owner

arendst commented Jun 22, 2022

Perfect Thx.

@arendst arendst merged commit 8a2d001 into arendst:development Jun 22, 2022
@Cossid Cossid deleted the sm2335-led-driver branch June 22, 2022 15:16
arendst added a commit that referenced this pull request Jun 22, 2022
Add support for 5-channel light dimmer driver SM2335 used in SwitchBot Color Bulbs (#15839)
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.

2 participants