nickovs / kld7

A Python driver for the K-LD7 radar module
11 stars 2 forks source link

Read and set parameter examples #4

Closed ajk1982 closed 1 year ago

ajk1982 commented 2 years ago

Hi,

I have been able to get the example code in the README working using an FTDI TTL to USB Serial Converter. Radar sensor now streams TDAT data to the terminal. I really appreciate the time you spent creating this driver!

I was wondering if you could please add some example code snippets to the README on how to read and set the parameters? I am totally new to python and programming in general and I have no idea what you mean when you say: "These paramters can be read and set though a :any:RadarParamProxy object accessible as the :any:params attribute of the driver object."

Many thanks, Anthony

ajk1982 commented 2 years ago

With help from a friend I managed to get it working:

    with KLD7("/dev/tty.usbserial-FTBXDIFU") as radar:
    radar.params.RSPI = 3  # Maximum speed. 0=12.5km/h, 1=25km/h, 2=50km/h, 3=100km/h
    radar.params.RRAI = 2  # Maximum range. 0=5m, 1=10m, 2=30m, 3=100m
    radar.params.DEDI = 2  # Detection direction. 0 = Approaching, 1 = Receding, 2 = Both
    print(radar.params.RSPI, radar.params.RRAI, radar.params.DEDI)