-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix counter rising edges when CounterDebounceLow/High is set #20712
Conversation
DO you have a use-case for this? I ask because there never was a reason to change this code part as far as I know and the impact is not clear to me. |
Tipping bucket rain gauge:
I wonder why the counter does not worked as described for CounterDebounceLow/High, maybe I just misunderstand the descritiopn for CounterDebounceLow/CounterDebounceHigh: "When unequal zero tasmota will check falling and rising edges on the counter's GPIO." I just wonder what CounterDebounceLow/High exists for if you can't use it to recognize both edges separately. In any case, with the current implementation it is not possible to count rising and falling edges, that's why I made this PR |
Theo, as I read the origin PR (#8021) this PR will not be backward compatible, I think the misleading part is the description for CounterDebounceLow/High. Anyway, I find the separate detection of falling and rising edges useful in cases like this. Should I solve this via an SO or an additional CounterType? |
Looking at the important part of the code:
wouldn't it make sense in your case to use PCD_low and PCD_high to use the original CHANGE interrupt? |
I saw this, this only enables IRQ on both changes but within IRQ routine rising edges are filtered: // do not count on rising edge
if bitRead(Counter.pin_state, index) {
// PWMfrequency 100
// restart PWM each second (german 50Hz has to up to 0.01% deviation)
// restart initiated by setting Counter.startReSync = true;
#ifdef USE_AC_ZERO_CROSS_DIMMER
if (index == 3) ACDimmerZeroCross(time);
#endif //USE_AC_ZERO_CROSS_DIMMER
return;
} this code part always returns for rising edged before counter is counted |
Would this solve your issue:
making sure the ZeroCross dimmer keeps working. |
try to summarize
I want to be backward compatible not touching the current behaviour but allow additonal count of falling & rising edges by an optional setting e.g CounterType 2 or some SO |
Yes, that's in my mind |
I'll change it now. |
Done. |
Description:
Counters were only set on falling edges, regardless of whether CounterDebounceLow or CounterDebounceHigh was set or not.
Checklist: