ncmreynolds / ld2410

An Arduino library for the Hi-Link LD2410 24Ghz FMCW radar sensor.
GNU Lesser General Public License v2.1
179 stars 37 forks source link

Optimization of LD2410 radar sensor reading and frame processing #31

Closed maxabba closed 1 month ago

maxabba commented 1 month ago

Optimization of LD2410 radar sensor reading and frame processing

This pull request addresses a critical issue in the LD2410 library where the read() function was always returning false, even when new data was available. The changes significantly improve the reliability and efficiency of reading data from the radar sensor.

Key modifications:

  1. Improved read() function:

    • Now returns true if new data has been read or if a complete frame has been processed.
    • This change allows for more accurate detection of new data availability.
  2. Optimized read_frame_() function:

    • Now processes data from the circular buffer instead of reading directly from UART.
    • Improves handling of partial data and reduces the possibility of data loss.
  3. Enhanced integration with the circular buffer:

    • More efficient use of buffer memory.
    • Reduced risk of buffer overflow.

Expected impact:

Tests performed:

Recommended next steps:

  1. Thorough code review.
  2. Testing in various scenarios to ensure the robustness of the changes.
  3. Consider adding additional unit tests to cover new use cases.

These changes should resolve the main reported issue and significantly improve the usability and reliability of the LD2410 library. I'm open to feedback and suggestions for further improvements.

Humancell commented 1 month ago

@ncmreynolds will you be merging these updates and creating a new release?

I was just about to update a bunch of sensors I built with this library and saw this pull that appears to improve the original code.

maxabba commented 1 month ago

@Humancell i'm using in my personal project and it is working very well. you can use mine until @ncmreynolds marge to main

https://github.com/maxabba/ld2410.git

for implement via platformio you can add to ini file like this installing git desktop

lib_deps = 
    https://github.com/maxabba/ld2410.git
ncmreynolds commented 1 month ago

Again, seems entirely reasonable to me.

Humancell commented 1 month ago

Thank you! I'll be testing soon!