Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonoff basic toggle with low pass filtering #76

Merged
merged 2 commits into from
May 23, 2018

Conversation

pcsaito
Copy link
Contributor

@pcsaito pcsaito commented May 11, 2018

This PR implements a low pass filter on gpio value instead of a time debounce to toggle.

With the default parameters it will filter up to 6 wrong readings and introduces about 60ms delay.

Fixes #70

@maximkulkin
Copy link
Owner

Can the same thing be done without using tasks (e.g. interrupt handlers + timers) ? Having a task for each toggle is too expensive.

@pcsaito
Copy link
Contributor Author

pcsaito commented May 22, 2018

I think it is.

The only purpose I used a task is to keep a contant update on the LPF values. Anything that executes periodically could do that.

All the toggles could share the same task or interrupt handler if they share the same “refresh” rate.

Is it still preferable to use interrupts instead only one task shared with all toggles?

@pcsaito
Copy link
Contributor Author

pcsaito commented May 22, 2018

I implemented the only-one-task solution.

As the LPF_INTERVAL is a #define, all the toggles already have the same interval, so more than one task never made sense.

If you judge that a interrupt handlers + timers implementation is more adequate I can follow this approach, just used a task because I'm more used to it.

@maximkulkin
Copy link
Owner

Ok, since I do not have bandwidth to do it myself and since it is for this particular example only, I'm fine with current implementation as long as it improves people experiences. Maybe someday somebody will hit this problem and volunteer to improve resource usage (or maybe not).

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.

None yet

2 participants