Generic sensor library best practices
Posted: Thu Jun 30, 2022 10:46 am
Hi,
TL;DR:
I am use a driver library that I wrote and I want to publish for all to use. My library supports different versions of the same module type, and I was wondering what the best practices were for making it generic. I will elaborate:
(What I am writing here is how I understand it, feel free to correct me if I got something wrong)
In Micropython there are "ports" and libraries can work with a specific port. For instance, if I have a module that works only on board A and B but not on other boards, then it will "belong" to that port.
But, what do we do if there are drivers that support an external module, or a group of modules that perform a similair function. On one hand, the module does NOT belong to a specific port, on the other hand at any given time I will probably want to use only one of the module implementations.
For instance, if I was using Python with no memory limitations, I would have the following structure:
ModuleInterface
| -> VariationAImplementation(ModuleInterface)
| -> VariationBImplementation(ModuleInterface)
| ....
On MicroPython that means that I will probably have "unused" files on the microcontroller, and it will take up space.
What is the best practice in cases like these (I am sure there are many examples)?
TL;DR:
I am use a driver library that I wrote and I want to publish for all to use. My library supports different versions of the same module type, and I was wondering what the best practices were for making it generic. I will elaborate:
(What I am writing here is how I understand it, feel free to correct me if I got something wrong)
In Micropython there are "ports" and libraries can work with a specific port. For instance, if I have a module that works only on board A and B but not on other boards, then it will "belong" to that port.
But, what do we do if there are drivers that support an external module, or a group of modules that perform a similair function. On one hand, the module does NOT belong to a specific port, on the other hand at any given time I will probably want to use only one of the module implementations.
For instance, if I was using Python with no memory limitations, I would have the following structure:
ModuleInterface
| -> VariationAImplementation(ModuleInterface)
| -> VariationBImplementation(ModuleInterface)
| ....
On MicroPython that means that I will probably have "unused" files on the microcontroller, and it will take up space.
What is the best practice in cases like these (I am sure there are many examples)?