-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Usermod Four Line Display: unnecessary use of software I2C on ESP32 #2708
Comments
Currently there is no standard way to assign the same I2C pins to multiple usermods. I have already thought about that and adjusted pin manager class but then focused elsewhere so the global I2C remained unimplemented. This is due to the fact that all usermods would need to be revised and changed, unfortunately I cannot test all of them. |
Ill follow this issue, because I can't route my OLED display to GPIO21-22! |
The idea behind global allocation of I2C (or SPI in the future) would be something like:
Then, in usermod, check like this:
Of course both of those would need appropriate change in Settings/Config which is more consuming task. Possibly also requiring changes elsewhere (set.cpp definitely and logic to change already allocated HW pins). |
I tested the solution proposed by @softhack007: my display runs really faster now. |
You can always just override HW_PIN_SDA (and SCL) so it will think those are HW pins. |
... but you need to do that in the source code |
ATM yes. |
Yes agreed. #ifndef HW_PIN_SCL
#define HW_PIN_SCL 22
#endif
#ifndef HW_PIN_SDA
#define HW_PIN_SDA 21
#endif and repeat for SPI pins |
I have checked the Wire library and it looks like it uses HW accelerated I2C no matter which GPIOs are defined (except if they cannot be remapped by muxer). |
Hopefully solved in #2737 |
What happened?
This is more a performance optimization that a real bug.
On ESP32, any GPIO can be assigned to the I2C hardware driver - ESP32 has two I2C hardware units that could be used in parallel. In the setup functions of four_line_display and four_line_display_ALT, only GPIO 21+22 are accepted as "hardware". If you configure other GPIO pins, a software-only driver is requested from U8g2.
As a result of using software-only I2C, the display will respond slower and there might be delays in animations. In debug build, you can see that a lot of time is spent in the usermod:
UM time[ms]: 0/196
UM time[ms]: 0/45
To Reproduce Bug
Compile with the following additional build_flags:
-D USERMOD_FOUR_LINE_DISPLAY
-D FLD_PIN_SCL=4
-D FLD_PIN_SDA=0
, --> notice the speed of display updates.Then compile again with
-D FLD_PIN_SCL=22
-D FLD_PIN_SDA=21
, and compare performances.Expected Behavior
Hardware I2C drivers should always be used on ESP32, no matter what GPIO.
Install Method
Self-Compiled
What version of WLED?
WLED main development branch
Which microcontroller/board are you seeing the problem on?
ESP32
Relevant log/trace output
Anything else?
As a quick hack that enforces HW i2C drivers:
below
https://github.com/Aircoookie/WLED/blob/a8908238d5e8c0aafb2f603168a193b86338e169/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h#L211-L212
add this
.
PS: overlooked one ... also this line needs to be patched:
https://github.com/Aircoookie/WLED/blob/a8908238d5e8c0aafb2f603168a193b86338e169/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h#L214
Code of Conduct
The text was updated successfully, but these errors were encountered: