bobveringa / HSCDTD008A-Library

A library for the HSCDTD008A Sensor and CJMCU-008 Module
MIT License
3 stars 3 forks source link

Support of several i2c devices #14

Open tilman1 opened 11 months ago

tilman1 commented 11 months ago

Dear Bob I am intending to add another magnetic sensor to the i2c-bus (hmc5883l) and use both magentic sensors, i.e. the hmc5883l as well as the HSCDTD008A to count impulses from 2 gas meters. How can I implement that with the library? I mean the library never calls t_close, hence I can not access the i2c device for a second sensor with a 2nd library. And it is also not efficient to constantly open and close the i2c device.. I was thinking of adding the support for the hmc5883l as separate class. For the access to the i2c-bus I need to link to src/driver/platform_rpi.cpp or src/driver/hscdtd008a_driver.c (depending on the platfrom). The data type for handles (hscdtd_device_t *p_dev) are however specific to the HSCDTD008A driver. Should you have any ideas how to do this conceptually, please kindly let me know. Thanks Tilman

bobveringa commented 11 months ago

It has been a while since I have done any work on this driver as I have not had a need for it.

I think you could add another "class" in the driver section. It wouldn't have to share any data type handles, it can instead access the platform modules. The platform modules would have to be updated to allow re-use (if the i2c-bus was already initialized, use that instead of re-initializing).

But it has been a while since I worked with this sensor, so there might be better solutions.