Skip to content

Added support for inverting logic of PIR pins#5300

Open
skykingjwc wants to merge 3 commits intowled:mainfrom
skykingjwc:AnimatedStaircasePIRInvert
Open

Added support for inverting logic of PIR pins#5300
skykingjwc wants to merge 3 commits intowled:mainfrom
skykingjwc:AnimatedStaircasePIRInvert

Conversation

@skykingjwc
Copy link

@skykingjwc skykingjwc commented Jan 16, 2026

Added config options and logic to invert the output of PIR sensors for the Animated Staircase usermod. Some sensors go low when the beam is broken. This PR adds support for those modules.

Summary by CodeRabbit

  • New Features
    • Added per-sensor inversion for top and bottom motion sensors in animated staircase mode, allowing each sensor's active logic to be flipped independently.
    • Inversion settings are saved to and restored from configuration, affect sensor behavior immediately, and are reflected in published device state.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

Walkthrough

Adds per-sensor inversion for top and bottom PIR/trigger pins, including two boolean flags, a private helper to read a pin with optional inversion, new PROGMEM manifest keys, and serialization/deserialization of the inversion flags; replaces direct digitalRead usage with the helper in sensor checks.

Changes

Cohort / File(s) Summary
Animated Staircase PIR Inversion
usermods/Animated_Staircase/Animated_Staircase.cpp
Adds topAPinInvert and bottomAPinInvert members; adds private readPIRPin(int8_t pin, bool invert) helper; replaces direct digitalRead calls with readPIRPin(...) where appropriate; introduces PROGMEM keys _topPIRorTrigger_pin_invert and _bottomPIRorTrigger_pin_invert; persists/deserializes invert flags in addToConfig() and readFromConfig()/state handling; updates manifest/state publishing to include invert keys.
Workspace metadata
.vscode/extensions.json
Whitespace / EOF newline adjustment only (no semantic change).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Added support for inverting logic of PIR pins' directly and specifically describes the main change: introducing per-sensor inversion configuration for PIR pins in the Animated Staircase usermod.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator

@DedeHai DedeHai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I am not familiar with this UM but looks ok in general, just a few minor things. someone with more knowledge about the code should check though.

@skykingjwc skykingjwc requested a review from DedeHai January 26, 2026 03:12
@skykingjwc
Copy link
Author

thanks, I am not familiar with this UM but looks ok in general, just a few minor things. someone with more knowledge about the code should check though.

For what it's worth, I'm not super familiar with this UM either. I just installed an animated staircase at my house and I needed to invert the logic for the IR sensors I purchased, I compiled the changes and it has been working at my home for a few weeks now with no issue. I figured I would turn it into a PR so others might benefit.

Copy link
Member

@softhack007 softhack007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me, too. Just I don't have a PIR to test with, either.

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.

3 participants