From 054cec74670cc50933f286ff38ea89ed5d1bf51c Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 15 Mar 2022 22:31:30 +0200 Subject: [PATCH] sensors/MLX9064x: Sync frame reading. * Fix frame glitches when reading speed is slower than framerate. --- src/omv/modules/py_fir.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/omv/modules/py_fir.c b/src/omv/modules/py_fir.c index d2a25eef8..4f0e5cd31 100644 --- a/src/omv/modules/py_fir.c +++ b/src/omv/modules/py_fir.c @@ -152,6 +152,9 @@ static void fir_MLX90640_get_frame(float *Ta, float *To) { uint16_t *data = fb_alloc(MLX90640_FRAME_DATA_SIZE * sizeof(uint16_t), FB_ALLOC_NO_HINT); + // Wait for a new data to be available before calling GetFrameData. + MLX90640_SynchFrame(MLX90640_ADDR); + // Calculate 1st sub-frame... PY_ASSERT_TRUE_MSG(MLX90640_GetFrameData(MLX90640_ADDR, data) >= 0, "Failed to read the MLX90640 sensor data!"); @@ -173,6 +176,9 @@ static void fir_MLX90641_get_frame(float *Ta, float *To) { uint16_t *data = fb_alloc(MLX90641_FRAME_DATA_SIZE * sizeof(uint16_t), FB_ALLOC_NO_HINT); + // Wait for a new data to be available before calling GetFrameData. + MLX90641_SynchFrame(MLX90641_ADDR); + PY_ASSERT_TRUE_MSG(MLX90641_GetFrameData(MLX90641_ADDR, data) >= 0, "Failed to read the MLX90641 sensor data!"); *Ta = MLX90641_GetTa(data, fir_mlx_data);