From 7f92fb6cd4c236fff33872770281a681a4cf12c5 Mon Sep 17 00:00:00 2001 From: Alexey Zholtikov Date: Tue, 3 Nov 2026 12:13:48 +0300 Subject: [PATCH] doc: updated comments --- include/zh_inclinometer.h | 4 ++-- zh_inclinometer.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/zh_inclinometer.h b/include/zh_inclinometer.h index 7da81a9..09b2891 100644 --- a/include/zh_inclinometer.h +++ b/include/zh_inclinometer.h @@ -2,7 +2,7 @@ * @file zh_inclinometer.h * * @brief Header file for the zh_inclinometer library providing encoder-based - * angle measurement and position tracking functionality. + * angle measurement and position tracking functionality. * * This library implements an inclinometer interface based on a quadrature * encoder connected to two GPIO pins. It uses the ESP-IDF pulse counter @@ -99,7 +99,7 @@ extern "C" * PCNT unit, frees the inclinometer handle memory, and sets the handle to * NULL. * - * @param[in,out] handle Pointer to the unique inclinometer handle (must not be NULL) + * @param[in,out] handle Pointer to the inclinometer handle pointer (will be set to NULL) * * @note After deinitialization, the handle is invalidated and must not be * used. Call zh_inclinometer_init() again to reinitialize. diff --git a/zh_inclinometer.c b/zh_inclinometer.c index 15a9f90..5b18ec5 100644 --- a/zh_inclinometer.c +++ b/zh_inclinometer.c @@ -101,7 +101,10 @@ esp_err_t zh_inclinometer_get(zh_inclinometer_handle_t **handle, float *angle) ZH_ERROR_CHECK(pcnt_unit_get_count((*handle)->pcnt_unit_handle, &pcnt_count) == ESP_OK, ESP_FAIL, NULL, "Inclinometer get position failed. PCNT unit get count fail."); float angle_temp = pcnt_count * (*handle)->degrees_per_pulse; *angle = (*handle)->rotation == true ? angle_temp : -angle_temp; - *angle += 0.0f; + if (*angle == 0.0) + { + *angle = 0.0; + } ZH_LOGI("Inclinometer get position completed successfully."); return ESP_OK; }