Ok. I am working on a class for reading a vl53l0x sensor. I got the class in the same folder as the test sketch and using from vl53l0x import * but I keep getting an error about no module with that name. The file name is vl53l0x.py. So the question is how do I do this?
Unfortunately, the link is not working (502 Bad Gateway).
Can you describe some sort of best practise when working with OpenMV IDE and custom modules?
As far as I know, I need to copy them to the camera board by hand. This is rather tedious during development…
Hi, we will be releasing a library feature for OpenMV using OpenMV IDE in the next version.
So, in your home directory will be a library folder (think Arduino). We may also scan a MP library directory too for general purpose MP code.
Anyway, when you click run for your script OpenMV IDE will regex any import statements, and if it sees a module not built-in it will look on the file system for it. If it doesn’t see it it will look in the library dirs first for the module and if it finds it copy it to the required location. It will fallback to a shipped system library directory otherwise and copy those instead. Note that if it sees a change between the library files on the PC and in your code it will update your system.
While this sounds heavy it only has to do this for any custom libraries you use.
We’ll be shipping a MQTT library with the next OpenMV IDE release.
Hi, library management is now working in OpenMV IDE. It will automatically scan a user folder now along with the examples folder for imports in your code and copy/update modules as necessary.
I’m having troubles using the import feature. I can import but ONLY if I specify exactly what I need. For example, if I create a constants.py file with a variable, I can only access it if I import that variable.
constants.py:
AREA_THRESHOLD = 20
Then, from another file, I try this, but it doesn’t work:
import constants
print(AREA_THRESHOLD)
But this works:
from constants import AREA_THRESHOLD
print(AREA_THRESHOLD)
Is this a bug? I’m doing this on a Mac. Or am I just not doing it right?