-
-
Notifications
You must be signed in to change notification settings - Fork 460
fix(cpn): logical switch global variable compare range #7007
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
Conversation
| bool mod = false; | ||
|
|
||
| if (value < range.min) { | ||
| value = round((range.min - range.offset) / range.step); | ||
| mod = true; | ||
| } else if (value > range.max) { | ||
| value = round((range.max - range.offset) / range.step); | ||
| mod = true; | ||
| } | ||
|
|
||
| if (mod) { | ||
| model->logicalSw[i].val2 = value; | ||
| emit modified(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it doesn't make it more confusing, you can use a ternary operator to remove the need for flags... ie.
| bool mod = false; | |
| if (value < range.min) { | |
| value = round((range.min - range.offset) / range.step); | |
| mod = true; | |
| } else if (value > range.max) { | |
| value = round((range.max - range.offset) / range.step); | |
| mod = true; | |
| } | |
| if (mod) { | |
| model->logicalSw[i].val2 = value; | |
| emit modified(); | |
| } | |
| if (value < range.min || value > range.max) { | |
| value = (value < range.min) | |
| ? round((range.min - range.offset) / range.step) | |
| : round((range.max - range.offset) / range.step); | |
| model->logicalSw[i].val2 = value; | |
| emit modified(); | |
| } |
Just a suggestion, whatever works best ;) There is also a std::clamp that came in in C++ '17, but lets not go there just yet. 🤭
|
I don't think this will work correctly for the ABS and DELTA logical switch functions. For ABS allowable range must always be positive. |
Yes and UI widget minimum and maximum also need fixing for these functions too |
|
I'm still testing the latest commit and trying to fix the lack of value acceleration. |
|
Testing complete subject to someone finding me out. Tried many approaches and asked Google but to date unable to solve the lack of value Acceleration. |
Partially Fixes #7005 and some housekeeping
Applies to 2.11, 2.12 and 3.0