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

scrolling text #284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions octoprint_wled/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def get_settings_defaults(self) -> Dict[str, Any]:
"id": 0,
"override_on": False,
"unique_id": "yqvg8h0c",
"scrolling_text": False,
}
],
},
Expand All @@ -368,6 +369,7 @@ def get_settings_defaults(self) -> Dict[str, Any]:
"id": 0,
"override_on": False,
"unique_id": "sduhc3fh",
"scrolling_text": False,
}
],
"tool": True,
Expand All @@ -384,6 +386,7 @@ def get_settings_defaults(self) -> Dict[str, Any]:
"id": 0,
"override_on": False,
"unique_id": "argrsh53",
"scrolling_text": False,
}
],
"bed_or_tool": "tool",
Expand Down
7 changes: 5 additions & 2 deletions octoprint_wled/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def set_progress(self, value: int, progress_type: str):
for segment in effect_settings:
if segment["override_on"]:
turn_lights_on = True
if segment["scrolling_text"]:
effect_scrolling_text = True

self._logger.debug(
f"Setting {progress_type} progress to segment {segment['id']}"
Expand All @@ -77,9 +79,10 @@ def set_progress(self, value: int, progress_type: str):
"brightness": int(segment["brightness"]),
"color_primary": hex_to_rgb(segment["color_primary"]),
"color_secondary": hex_to_rgb(segment["color_secondary"]),
"effect": "Percent",
"intensity": int(value),
"effect": "Scrolling Text" if effect_scrolling_text else "Percent",
"intensity": 128 if effect_scrolling_text else int(value),
"on": lights_on,
"n": f"{value}% Complete" if effect_scrolling_text else None,
},
)

Expand Down
6 changes: 5 additions & 1 deletion octoprint_wled/static/src/wled.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ $(function () {
brightness: ko.observable(200),
color_primary: ko.observable('#ffffff'),
color_secondary: ko.observable('#000000'),
override_on: ko.observable(false)
override_on: ko.observable(false),
scrolling_text: ko.observable(false)
})

self.setEditingObservables = (effect, data) => {
Expand Down Expand Up @@ -111,6 +112,9 @@ $(function () {
observables.override_on(
settings.progress[name].settings()[index].override_on()
)
observables.scrolling_text(
settings.progress[name].settings()[index].scrolling_text()
)
self.progress[name].segments.push(observables)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
{{ settingsInput("Brightness", "number", "progress", identifier, "brightness") }}
{{ settingsInput("Progress Color", "color", "progress", identifier, "color_primary") }}
{{ settingsInput("Base Color", "color", "progress", identifier, "color_secondary") }}
{{ settingsInput("Scrolling Text", "checkbox", "progress", identifier, "scrolling_text") }}
{{ settingsInput("Overrides on/off", "checkbox", "progress", identifier, "override_on", "When checked, this effect will always turn all the WLED LEDs back on, if they are off") }}
</div>
<div class="modal-footer">
Expand Down
2 changes: 2 additions & 0 deletions octoprint_wled/wled/wled.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def segment(
start: int | None = None,
stop: int | None = None,
transition: int | None = None,
n: str | None = None,
) -> None:
"""Change state of a WLED Light segment."""
if self._device is None:
Expand All @@ -266,6 +267,7 @@ def segment(
"start": start,
"stop": stop,
"sx": speed,
"n": n,
}

# > WLED 0.10.0, does not support segment control on/bri.
Expand Down