tfluna-python icon indicating copy to clipboard operation
tfluna-python copied to clipboard

Refactor the sensor library

Open clementnuss opened this issue 3 years ago • 3 comments

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 avatar Apr 15 '21 14:04 clementnuss