From c7edd538debfbb904b5ac1ed5c5c86784a3a9cee Mon Sep 17 00:00:00 2001 From: Aman Palanati Date: Mon, 4 Nov 2024 23:18:11 -0800 Subject: [PATCH 1/2] Documented class, member variables, constructor, and destructor --- src/watersensor/waterSensor.hpp | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/watersensor/waterSensor.hpp b/src/watersensor/waterSensor.hpp index 80a549b0..3f6fc2eb 100644 --- a/src/watersensor/waterSensor.hpp +++ b/src/watersensor/waterSensor.hpp @@ -24,27 +24,72 @@ #define WATER_SENSOR_HIGH_STATE 1 #define WATER_SENSOR_LOW_STATE 0 +/** + * @brief Represents a sensor that detects water presence using a moving window of samples + */ class WaterSensor { private: // which pin is the water sensor on? + /** + * @brief Pin that enables the water detection sensor + */ uint8_t water_detect_en_pin; + /** + * @brief Pin that reads the water detection status + */ uint8_t water_detect_pin; + // how many samples to look at for the moving window + /** + * @brief Size of the moving sample window used for water detection + */ uint8_t moving_window_size; + /** + * @brief Minimum percentage of high state readings to trigger a change to "out of water" + */ uint8_t low_detect_percentage = DEFAULT_WATER_SENSOR_LOW_PERCENTAGE; + /** + * @brief Minimum percentage of high state readings to trigger a change to "in water" + */ uint8_t high_detect_percentage = DEFAULT_WATER_SENSOR_HIGH_PERCENTAGE; + // how many samples have been taken since a reset (signally a valid measurement) + /** + * @brief Number of samples taken since the last reset + */ uint8_t samples_taken_since_reset = 0; + // sum of the array, initially set to zero. + /** + * @brief Sum of the current samples in the window + */ uint8_t array_sum = 0; + // current location in the array + /** + * @brief Current position in the array of samples + */ uint8_t array_location = 0; + // the last water reading, for hystersis, starting with "out of the water" + /** + * @brief Previous water detection status used for hystersis + */ uint8_t last_water_detect = 0; public: + /** + * @brief Initializes the WaterSensor with specific pins and window size + * + * @param water_detect_en_pin Pin that enables the water sensor + * @param water_detect_pin_to_set Pin that reads the sensor value + * @param window_size Size of the moving sample window used for water detection + */ WaterSensor(uint8_t water_detect_en_pin, uint8_t water_detect_pin_to_set, uint8_t window_size); + /** + * @brief Destroys the WaterSensor instance + */ ~WaterSensor(); // resets the array to zero From 8a331255a3dde3a4f93f6b561baba9509106a34a Mon Sep 17 00:00:00 2001 From: Aman Palanati Date: Mon, 11 Nov 2024 22:06:23 -0800 Subject: [PATCH 2/2] Deleted extraneous/redundant comments --- src/watersensor/waterSensor.hpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/watersensor/waterSensor.hpp b/src/watersensor/waterSensor.hpp index 3f6fc2eb..48de91d1 100644 --- a/src/watersensor/waterSensor.hpp +++ b/src/watersensor/waterSensor.hpp @@ -30,7 +30,6 @@ class WaterSensor { private: - // which pin is the water sensor on? /** * @brief Pin that enables the water detection sensor */ @@ -39,8 +38,6 @@ class WaterSensor * @brief Pin that reads the water detection status */ uint8_t water_detect_pin; - - // how many samples to look at for the moving window /** * @brief Size of the moving sample window used for water detection */ @@ -53,26 +50,18 @@ class WaterSensor * @brief Minimum percentage of high state readings to trigger a change to "in water" */ uint8_t high_detect_percentage = DEFAULT_WATER_SENSOR_HIGH_PERCENTAGE; - - // how many samples have been taken since a reset (signally a valid measurement) /** * @brief Number of samples taken since the last reset */ uint8_t samples_taken_since_reset = 0; - - // sum of the array, initially set to zero. /** * @brief Sum of the current samples in the window */ uint8_t array_sum = 0; - - // current location in the array /** * @brief Current position in the array of samples */ uint8_t array_location = 0; - - // the last water reading, for hystersis, starting with "out of the water" /** * @brief Previous water detection status used for hystersis */