wahajmurtaza / HLS-LFCD2

HLS-LFCD2 interfacing with python
MIT License
3 stars 3 forks source link

Wrong distance calculation #1

Open levietduc0712 opened 1 month ago

levietduc0712 commented 1 month ago

Your formula for calculating distance is incorrect. You need to use the bytes [6, 7, 12, 13, 18, 19, 24, 25, 30, 31, 36, 37] instead of [4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25]. You can check again in the datasheet.

levietduc0712 commented 1 month ago

So the final corrected code will be

for i in range(6): distance = (bytes_data[6 + (i*6) + 1] << 8) | (bytes_data[6 + (i*6)])