fix: Remove espressif/i2c_bus dependency for M5GFX/M5Unified coexistence#1
Open
LOVECHEN wants to merge 3 commits intom5stack:mainfrom
Open
fix: Remove espressif/i2c_bus dependency for M5GFX/M5Unified coexistence#1LOVECHEN wants to merge 3 commits intom5stack:mainfrom
LOVECHEN wants to merge 3 commits intom5stack:mainfrom
Conversation
added 3 commits
January 31, 2026 01:19
## 问题背景 - M5PM1 原本依赖 espressif/i2c_bus 库(旧版 I2C 驱动) - M5GFX/M5Unified 使用 ESP-IDF native driver/i2c_master.h(新版驱动) - ESP-IDF 5.x 不允许同一个 I2C port 同时使用两种驱动 - 导致 M5StickS3 屏幕黑屏或 I2C 通信失败 ## 解决方案 ### idf_component.yml - 删除 espressif/i2c_bus 依赖 ### M5PM1_i2c_compat.h - 移除 #include "i2c_bus.h" - 移除所有 M5PM1_I2C_*() i2c_bus 版本的宏 - 保留 M5PM1_I2C_MASTER_*() i2c_master 版本的宏 - 移除 M5PM1_I2C_DRIVER_BUS 枚举值 ### M5PM1.h - 删除 begin(i2c_bus_handle_t bus, ...) 函数声明 - 删除 _i2c_bus 成员变量 (i2c_bus_handle_t) - 删除 _i2c_device 成员变量 (i2c_bus_device_handle_t) ### M5PM1.cpp - 删除 begin(i2c_bus_handle_t) 实现(约100行) - 删除构造函数中的 _i2c_bus = nullptr / _i2c_device = nullptr - 删除析构函数中的 M5PM1_I2C_DRIVER_BUS case - 删除 _writeReg() 中的 M5PM1_I2C_DRIVER_BUS case - 删除 _writeReg16() 中的 M5PM1_I2C_DRIVER_BUS case - 删除 _readReg() 中的 M5PM1_I2C_DRIVER_BUS case - 删除 _readReg16() 中的 M5PM1_I2C_DRIVER_BUS case - 删除 _writeBytes() 中的 M5PM1_I2C_DRIVER_BUS case - 删除 _readBytes() 中的 M5PM1_I2C_DRIVER_BUS case - 删除 setI2cConfig() 中的两处 M5PM1_I2C_DRIVER_BUS case - 删除 sendWakeSignal() 中的 M5PM1_I2C_DRIVER_BUS case ## API 变更 - 旧 API: pm1.begin(i2c_bus_handle_t) [已删除] - 新 API: pm1.begin(i2c_master_bus_handle_t) [保留] - Arduino API: pm1.begin(TwoWire*) [保留,不受影响] ## 兼容性 - ESP-IDF 5.x: 完全支持(使用 i2c_master 驱动) - Arduino: 完全支持(使用 TwoWire) - 与 M5Unified/M5GFX: 现在可以共存,无驱动冲突 ## 测试状态 待验证:M5StickS3 + M5PM1 + M5Unified 共存
Member
|
Thank you for your detailed description and the effort put into this PR. I understand your motivation — resolving the I2C driver conflict when using M5PM1 alongside M5GFX/M5Unified on ESP-IDF 5.x. We plan to improve M5PM1 to support both the legacy and the new ESP-IDF I2C APIs for better coexistence. For context, the current M5Unified I2C implementation (see I2C_Class.hpp#L10) still relies on the legacy driver/i2c.h, so properly handling both sides will be the right long-term fix. I'll close this PR for now and address the compatibility on the M5PM1 side in the near future. Thanks again for bringing this to our attention! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
M5PM1 depends on
espressif/i2c_buswhich uses the legacy I2C driver (i2c_bus.h).M5GFX and M5Unified use the native ESP-IDF I2C driver (
driver/i2c_master.h).ESP-IDF 5.x does not allow both drivers to coexist on the same I2C port, causing:
Solution
Remove the
espressif/i2c_busdependency completely. M5PM1 now only uses the nativedriver/i2c_master.hdriver.Commits
espressif/i2c_busfromidf_component.yml, rewriteM5PM1_i2c_compat.h, removebegin(i2c_bus_handle_t)APIespressif__i2c_busfromCMakeLists.txtREQUIRESChanges Summary
idf_component.ymlespressif/i2c_busdependencyCMakeLists.txtespressif__i2c_busfrom REQUIRESM5PM1_i2c_compat.h#include "i2c_bus.h"and all i2c_bus macrosM5PM1.hbegin(i2c_bus_handle_t)declaration and_i2c_bus/_i2c_devicemembersM5PM1.cppbegin(i2c_bus_handle_t)implementation and allM5PM1_I2C_DRIVER_BUScasesAPI Changes
pm1.begin(i2c_bus_handle_t bus, ...)pm1.begin(i2c_master_bus_handle_t bus, ...)(ESP-IDF native)pm1.begin(TwoWire* wire, ...)(Arduino)Tested
✅ M5StickS3 with M5PM1 + M5Unified + M5GFX working correctly.
✅ Display shows normally, no I2C conflicts.
✅ This enables M5PM1, M5Unified, and M5GFX to coexist without I2C driver conflicts on ESP-IDF 5.x.
@ricker-go This PR resolves the I2C driver conflict issue that prevents M5PM1, M5Unified, and M5GFX from working together. The legacy
i2c_busdriver has been completely removed in favor of the nativei2c_masterdriver.