feat(valve): Implement obstacle detection with configurable thresholds

Introduces separate configurable current thresholds for obstacle detection
during valve opening and closing movements.

- Added  state to .
- Added  and
   to .
- Modified  to implement obstacle detection in ,
  setting  on high current, and to load/save
  these new thresholds via settings.
- Added new setter/getter functions for obstacle thresholds to  and .
- Updated  with new shell commands (, )
  and updated  to display these settings.
- Updated  to document the new registers and error states.
- Updated  to include new register definitions, menu options,
  and display of obstacle current thresholds.
This commit is contained in:
2025-07-11 00:27:31 +02:00
parent a3e8d5c168
commit 3c2235733b
6 changed files with 152 additions and 8 deletions

View File

@@ -89,9 +89,21 @@ enum {
*/
REG_HOLDING_MAX_CLOSING_TIME_S = 0x0002,
/**
* @brief Minimum current threshold in mA for end-position detection.
* @brief Minimum current threshold in mA for end-position detection during opening.
*/
REG_HOLDING_VALVE_END_CURRENT_THRESHOLD_MA = 0x0003,
REG_HOLDING_END_CURRENT_THRESHOLD_OPEN_MA = 0x0003,
/**
* @brief Minimum current threshold in mA for end-position detection during closing.
*/
REG_HOLDING_END_CURRENT_THRESHOLD_CLOSE_MA = 0x0004,
/**
* @brief Obstacle current threshold in mA for opening.
*/
REG_HOLDING_OBSTACLE_CURRENT_THRESHOLD_OPEN_MA = 0x0005,
/**
* @brief Obstacle current threshold in mA for closing.
*/
REG_HOLDING_OBSTACLE_CURRENT_THRESHOLD_CLOSE_MA = 0x0006,
/**
* @brief Bitmask for reading and writing digital outputs. Bit 0: Output 1,
* Bit 1: Output 2. 1=ON, 0=OFF.

View File

@@ -32,7 +32,8 @@ enum valve_movement {
VALVE_MOVEMENT_IDLE, /**< The valve is not moving. */
VALVE_MOVEMENT_OPENING, /**< The valve is currently opening. */
VALVE_MOVEMENT_CLOSING, /**< The valve is currently closing. */
VALVE_MOVEMENT_ERROR /**< An error occurred during movement. */
VALVE_MOVEMENT_ERROR, /**< An error occurred during movement. */
VALVE_MOVEMENT_OBSTACLE /**< An obstacle was detected during movement. */
};
/**
@@ -113,6 +114,20 @@ void valve_set_end_current_threshold_open(uint16_t current_ma);
*/
void valve_set_end_current_threshold_close(uint16_t current_ma);
/**
* @brief Sets the current threshold for obstacle detection during opening.
*
* @param current_ma The current threshold in milliamps.
*/
void valve_set_obstacle_current_threshold_open(uint16_t current_ma);
/**
* @brief Sets the current threshold for obstacle detection during closing.
*
* @param current_ma The current threshold in milliamps.
*/
void valve_set_obstacle_current_threshold_close(uint16_t current_ma);
/**
* @brief Gets the current threshold for end-position detection during opening.
*
@@ -141,6 +156,20 @@ uint16_t valve_get_max_open_time(void);
*/
uint16_t valve_get_max_close_time(void);
/**
* @brief Gets the current threshold for obstacle detection during opening.
*
* @return The current threshold in milliamps.
*/
uint16_t valve_get_obstacle_current_threshold_open(void);
/**
* @brief Gets the current threshold for obstacle detection during closing.
*
* @return The current threshold in milliamps.
*/
uint16_t valve_get_obstacle_current_threshold_close(void);
/**
* @brief Gets the current drawn by the valve motor during opening.
*