Added depth and pressure, updated README#11
Conversation
ES-Alexander
left a comment
There was a problem hiding this comment.
Hi, just saw this! Thanks for submitting these changes :-)
Mostly looks good, just a couple of suggestions / things to consider :-)
|
|
||
| def __init__(self, bus=1): | ||
| self._bus = None | ||
| self._fluid_density = 1029 # kg/m^3 |
There was a problem hiding this comment.
This should probably use set_fluid_density (e.g. in case someone changes the function to include logging later), and should probably also have a parameter in the __init__ definition (e.g. def __init__(self, bus=1, fluid_density=1029):) so it's settable directly on object instantiation.
|
|
||
| def set_fluid_density(self, fluid_density): | ||
| ''' | ||
| Provide the density of the working fluid in kg/m^3. Default is for |
There was a problem hiding this comment.
This is a bit confusing, because the fluid_density parameter has no default value - the "default" mentioned in the docstring is instead a default from class instantiation (which is outside the scope of this function, and likely isn't relevant to mention here).
It may also be worth adding a few string-based defaults, either just 'fresh'->997 and 'sea'->1029, or could make use of wikipedia's salinity levels by water type overview. Not essential, just could be nice to have (although those levels could also be implemented separately in a Water class or something, which may be more appropriate).
Hello, I have used the C++ version of this KellerLD module that is used for microcontrollers:
https://github.com/bluerobotics/BlueRobotics_KellerLD_Library/
That library features calculations to convert the pressure obtained from the sensor to Depth and Altitude readings. I was hoping this feature could be added to this module, as we were utilizing this python module for use with Jetson Nano's, which have a GPIO pinout to read in the values from the BlueRobotics sensor.
I made modifications to the code, and tried to keep similar naming conventions / styles to that of your Python setup, as well to reference the way you have does the calculations in the C++ version of this module.
Things that were added/changed:
The modified code was tested on a Jetson Nano (by running the modified example.py script, and changing the pressure units) and seems to perform as expected.
I'm open to suggestions / changes to better match your formatting preference, but figured this would be useful for people in the future so they do not have to do their own conversions / calculations, especially if they are in a situation like me where they migrate from the functionality in the C++ microcontroller module, to this Python version.
-Raymond