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

Add support for output_pin and fan templates #6695

Merged
merged 5 commits into from
Sep 30, 2024

Conversation

KevinOConnor
Copy link
Collaborator

This PR adds support for specifying a math formula for output_pin and fan_generic objects. This works similarly to the "led template" support - one can specify a [display_template my_template] config section that contains a Jinja2 macro providing a formula, and that formula will then be evaluated periodically to determine the pin/fan setting to apply.

The settings from the formula do not pass through the g-code command queue, so the updates are applied even during homing and other long running commands.

This should make it possible to define more flexible pin and fan control schemes.

-Kevin

@@ -476,6 +476,20 @@ enabled.
`SET_FAN_SPEED FAN=config_name SPEED=<speed>` This command sets the
speed of a fan. "speed" must be between 0.0 and 1.0.

`SET_FAN_SPEED PIN=config_name TEMPLATE=<template_name>
[<param_x>=<literal>]`: If `TEMPLATE` is specified then it assigns a
[display_template](Config_Reference.md#display_template) to the given
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps display_template could get a secondary name of just template?
It feels very confusing to be connecting an output pin / fan to a 'display_template' when the intent is to not display anything, but to have it all work in the background...

Maybe dynamic_variable or dynamic_value or something else might be a good secondary name. Just something that doesn't tie it specifically to a 'display' usage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for reviewing.

I agree that display_template is a confusing name. Roughly I'd like to introduce something like macro_template, make render() always available from Jinja2, and deprecate display_template. That change seems orthogonal though, so didn't want to complicate this PR with a config rename.

-Kevin

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
@KevinOConnor KevinOConnor force-pushed the work-pin-template-20240815 branch from d32ea61 to 8f361a1 Compare September 30, 2024 16:30
@KevinOConnor KevinOConnor merged commit 8f361a1 into master Sep 30, 2024
2 checks passed
@KevinOConnor KevinOConnor deleted the work-pin-template-20240815 branch September 30, 2024 16:32
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