Skip to content

fix(4-20mA): correct change-detection logic in processInput_4_20mA - #2

Open
martinhoefling wants to merge 1 commit into
OpenKNX:v1from
martinhoefling:fix/4-20mA-change-detection
Open

fix(4-20mA): correct change-detection logic in processInput_4_20mA#2
martinhoefling wants to merge 1 commit into
OpenKNX:v1from
martinhoefling:fix/4-20mA-change-detection

Conversation

@martinhoefling

Copy link
Copy Markdown
  • Use CUR_CHSensorTypes2 (physical sensor type) instead of CUR_CHSensorType2 (input mode) when selecting the relative-change threshold. The mode value 0-20mA (2) collided with the SensorType_humidity case (2), forcing a 100% relative threshold and effectively disabling relative-change sending on 0-20mA inputs.

  • Replace integer abs() with fabsf() in the absolute and relative change checks so sub-1.0 differences are no longer truncated.

  • Guard calculateSensorValueLinearFunction2 against equal 4mA/20mA scaling points (e.g. both left unconfigured), which previously caused a division by zero and a NaN value being stored/sent.

- Use CUR_CHSensorTypes2 (physical sensor type) instead of
  CUR_CHSensorType2 (input mode) when selecting the relative-change
  threshold. The mode value 0-20mA (2) collided with the
  SensorType_humidity case (2), forcing a 100% relative threshold and
  effectively disabling relative-change sending on 0-20mA inputs.

- Replace integer abs() with fabsf() in the absolute and relative change
  checks so sub-1.0 differences are no longer truncated.

- Guard calculateSensorValueLinearFunction2 against equal 4mA/20mA
  scaling points (e.g. both left unconfigured), which previously caused
  a division by zero and a NaN value being stored/sent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant