GeezerVison is showing github.com — bugfix: split fan/speed slider callbacks to fix gcode dispatch collision by gmmcosta15 · Pull Request #212 · BlocksTechnology/BlocksScreen
Conversation
gmmcosta15
commented
Apr 13, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
- Feature
- Bug fix
- Code refactor
- Documentation
Description
- controlTab.on_slider_change / tunePage.on_slider_change: now dispatch the correct gcode per fan object type -> M106 S{0–255} for [fan], SET_FAN_SPEED FAN={name} SPEED={0.0–1.0} for [fan_generic]
- tunePage: add _on_speed_slider_change for print speed (M220); speed slider routed there, fan slider to on_slider_change
- Fixed M106 S-value calculation: round(percent * 255 / 100) avoids float imprecision at 50% duty cycle
- Extracted shared fan gcode logic to lib/utils/gcode.py::fan_speed_gcode() — removes duplication between controlTab and tunePage
- Removed unused from helper_methods import normalize from both files
- Fixed RUF012: mutable class-level dict defaults moved to init in ControlTab and TuneWidget
- Fixed SIM910, RUF046, E501 violations in controlTab.py
- Added contextlib.suppress disconnect guards for slider and numpad signals
Motivation
When a fan_generic was named "speed", both controlTab and tunePage would dispatch conflicting gcodes (SET_FAN_SPEED and M220) on the same slider event. Additionally, [fan] objects require M106 not SET_FAN_SPEED, and the previous code used M220 (feedrate override) on the fan path entirely. Splitting the callbacks and centralising gcode generation eliminates the collision and ensures the correct command is always sent regardless of fan type or name
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
This needs more work.
There is no reason whatsoever where the slider should only emit a gcode for fan speed changes on objects that are [fan_generic]. Normal fans [fan] should have their speed changed using the slider as well.
So the slider needs to emit the appropriate gcode according to the fan object declaration.
Second thing, the gcode command M220 has nothing to do with fan speeds, that command sets the feedrate percentage . The appropriate command that i believe you were looking for is M106 SX, where X is an integer between [0-255].
Additionally, what happened with the ControlTab.py file, because the entire file is diff. I suggest just having just the actual changes.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…ic]; drop normalize dependency and ruff fixes
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
HugoCLSC
HugoCLSC approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|