Hello All!
I hope my question is not too ambiguous, I already had an idea on how to do this BUT it would use another library author’s code as a template, and I did not think that was fair to the author. Although I would be happy to credit him.
This is for an embedded system, and perhaps I should ask this in a MicroPython or CircuitPython forum, but I need to start somewhere.
I have an older piece of I2C sensor hardware. I cannot find a library for it anywhere but I want to use it. Out of the gate, I thought of taking a library for a similar piece of hardware, pull up the datasheet for the devices used on my hardware, and make changes to suit the requirements.
It does not seem right though, so I am asking if anyone can direct me to a DOs and DON’Ts faq for creating libraries for I2C components. I thought I would ask this first before I go after reverse engineering, say, a library in python that allows access to a MPU4060 accelerometer. It looks like there are base components of the library that handle communication, as in memory or register reads and writes by address.
Is there a template for such a thing? Creating a I2C device library for Python, MicroPython, or CircuitPython?
My piece of hardware is a GY-80 Accelerometer board. It has 4 devices on it and I have the datasheet for each. ALL are tied to the same I2C bus on the board and have different addresses of course, which I can see when I scan it. But I am fairly new to libraries, especially ones that touch hardware for a specific platform. In my case, it is the RPI Pico 2040 W.
I just want to do it right, and not cannibalize someone’s hard work. There is too much of that already. And I have to learn somewhere, which is why I asked. To be honest, I would LOVE to be able to write libraries for all my legacy I2C (and other) hardware spanning the last 10-15 years.
I hope someone can point me in the right direction. I do not want it done for me, just a bread-crumb trail to follow to learn, practice, and achieve.
THANKS so much for your valuable time. I appreciate it!
Hop