Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the sensor library #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

clementnuss
Copy link

Hi!

I spent some time refactoring this library as a "ressource" class:
in the src/ folder, you'll find the examples, as well as a python module tfluna.
In this module, I defined the TfLuna class, that you can use as follows :

with tfluna.TfLuna(baud_speed=115200) as tfluna:
    tfluna.get_version()
    distance,strength,temperature = tfluna.read_tfluna_data() # read values
    # etc

This makes using the sensor far easier, as the resource closing is handled by the with-resource concept, and the sensor code is centralized.

@clementnuss
Copy link
Author

I have also created a python module here: https://pypi.org/project/tfluna-driver/
It might be simpler not to merge this PR in the end: keep this repo as example code, and point to my repo where I will continue to update the driver.
As you prefer! Best regards,
Clément

@BaitaSquirrel
Copy link

Hi clementnuss, appreciate what you've done with this. I just picked up a TF-luna so haven't gone to implement. Just curious. Is there a reason for using UART over i2c with this unit?

@clementnuss
Copy link
Author

Hi, no reason at all. I simply reused the serial code that was already written. Feel free to implement it if you have time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants