firmware-base/docs/ValueWrapper.md
2025-06-04 08:19:09 +02:00

1.5 KiB

title description keywords
ValueWrapper - Threshold-based Value Change Notification A template class that wraps values with threshold-based change notification logic, designed for efficient Modbus communication
ESP32
Modbus
ValueWrapper
Threshold
Notification
C++
Template

ValueWrapper

Path: src/ValueWrapper.h

Revision History: Initial documentation

ValueWrapper is a template class that wraps a value (of any type T) and provides threshold-based change notification. When the value changes beyond a specified threshold, it automatically generates Modbus notification messages, reducing network traffic by only sending significant changes.

REQUIREMENTS

  • C++17 compiler support
  • No specific hardware pins required

FEATURES

  • Supports any data type, including primitives and enums
  • Two threshold check modes:
    • DIFFERENCE: Notifies when absolute difference exceeds threshold
    • INTERVAL_STEP: Notifies when value crosses interval boundaries
  • Automatic Modbus message generation when thresholds are crossed
  • Callback support for additional logic on value changes
  • Type-safe conversion operations
  • Specialized handling for different data types (signed, unsigned, enum)

DEPENDENCIES