diff --git a/docs/configuration/AFC.cfg.md b/docs/configuration/AFC.cfg.md index 4372717..c1734fd 100644 --- a/docs/configuration/AFC.cfg.md +++ b/docs/configuration/AFC.cfg.md @@ -133,27 +133,43 @@ led_name: AFC_Indicator # LED name from the [AFC_led] section in AFC_Hardware.cfg. # All LEDs use the (R,G,B,W) format. R = Red, G = Green, B = Blue, W = White. # 0 = off, 1 = full brightness. +# +# These are the system-wide defaults for the states below; each can be +# overridden per unit or per lane. See the [AFC_lane] section in +# AFC_UnitType_1.cfg for full details on when each state is triggered, +# including which ones respect led_use_filament_color and which apply +# to the toolhead status LED instead of the lane's own LED. led_fault: 1,0,0,0 -# Fault color +# Fault color - shown when AFC flags a fault on the lane (jam, sensor +# mismatch, failed load/unload, etc). led_ready: 0,0.8,0,0 -# Ready color +# Ready color - shown once filament is staged behind the hub, and on +# the lane's own LED again after a tool unload. led_not_ready: 1,0,0,0 -# Not ready color +# Not ready color - shown when the lane is empty, and also when a +# lane is unloaded back out of the hub but still has a spool prepped. led_loading: 1,1,1,0 -# Loading color +# Loading color - shown while filament is actively feeding into the +# lane (loading to the toolhead, or loading a spool into the lane). led_tool_loaded: 0,0,1,0 # Default: 0,0,1,0 -# Color to set when lane is loaded into toolhead extruder. +# Color shown on the lane's LED (and toolhead status LED) while this +# lane is the active/loaded tool. led_unloading: 1,1,.5,0 # Default: 1,1,.5,0 -# Color to set when unloading a lane. +# Color shown while filament is backing out of the lane (unloading +# from the toolhead, or ejecting the lane). led_tool_loaded_idle: 0.4,0.4,0,0 # Default: 0.4,0.4,0,0 -# LED color used when a lane is loaded into the toolhead and idle. +# LED color used on the lane's LED and toolhead status LED when this +# lane's tool is loaded but idle/parked (e.g. between tool changes +# on a toolchanger). # Format: (R,G,B,W) where 0 = off and 1 = full brightness. led_tool_unloaded: 1,0,0,0 # Default: 1,0,0,0 -# LED color used when a lane is not loaded in the toolhead. +# Toolhead status LED color shown when this lane's tool has just +# been unloaded. Does not affect the lane's own LED, which instead +# reverts to led_ready. # Format: (R,G,B,W) where 0 = off and 1 = full brightness. led_buffer_advancing: 0,0,1,0 # Default: 0,0,1,0 @@ -176,9 +192,12 @@ led_spool_illuminate: 1,1,1,0 # and can be overridden in AFC_QuattroBox section led_use_filament_color: False # Default: False -# When True, lane LED colors will use the filament color from the spool color -# field (set manually or synced from Spoolman) instead of the configured LED -# state colors. +# When True, the lane's LED (and, where noted above, the toolhead +# status LED) uses the filament color from the spool color field (set +# manually or synced from Spoolman) instead of the configured +# led_ready/led_tool_loaded_idle colors. Other states (fault, loading, +# unloading, not ready, tool loaded) always use their configured +# color regardless of this setting. n20_break_delay_time: 0.200 # Default: 0.200 # Time to wait between braking N20 motors(nSleep/FWD/RWD all 1) and then diff --git a/docs/configuration/AFC_UnitType_1.cfg.md b/docs/configuration/AFC_UnitType_1.cfg.md index 1e34773..200713d 100644 --- a/docs/configuration/AFC_UnitType_1.cfg.md +++ b/docs/configuration/AFC_UnitType_1.cfg.md @@ -130,32 +130,46 @@ load: ^!Turtle_1:EXT1 # extruder body located AFTER the extruder motor. led_fault: 1,0,0,0 # Default: 1,0,0,0 -# LED color to set when faults occur in lane. +# LED color used when AFC flags a fault on the lane (jam, sensor +# mismatch, failed load/unload, etc) and the lane needs attention. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) section. led_ready: 0,0.8,0,0 # Default: 0,0.8,0,0 -# LED color to set when lane is ready. +# LED color used once filament is staged and confirmed ready behind +# the hub. Also used for the lane's own LED after a tool unload, +# since filament stays staged at the hub (see led_tool_unloaded +# below for the separate toolhead LED color used at that point). +# Overridden by the filament's color when led_use_filament_color is +# enabled below. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) section. led_not_ready: 1,0,0,0 # Default: 1,0,0,0 -# LED color to set when lane is not ready. +# LED color used when the lane is empty, with no spool prepped +# (prep and load sensors both false). Also reused when a lane is +# unloaded back out of the hub but a spool is still prepped in the +# lane (prep sensor still true). # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) section. led_loading: -# Default: -# LED color to set when lane is loading. +# Default: 1,1,1,0 +# LED color used while filament is actively feeding into the lane, +# either loading to the toolhead or loading a spool into the lane +# itself. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) section. led_unloading: 1,1,1,0 # Default: 1,1,1,0 -# LED color to set when lane is unloading. +# LED color used while filament is backing out of the lane, either +# unloading from the toolhead or ejecting the lane. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) section. led_tool_loaded: 0,0,1,0 # Default: 0,0,1,0 -# LED color to set when lane is loaded in toolhead. +# LED color used on the lane's LED (and its toolhead status LED, if +# `status_led_idx` is set on the extruder) while this lane is the +# active/loaded tool. Not affected by led_use_filament_color. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) section. led_spool_index: @@ -169,14 +183,21 @@ led_spool_index: # eg. AFC_Indicator_4:1,2,3,4, 6-9, 11-14, 16-18 led_tool_loaded_idle: 0.4,0.4,0,0 # Default: 0.4,0.4,0,0 -# LED color used when this lane is loaded into the toolhead and idle. +# LED color used on the lane's LED and its toolhead status LED +# (`status_led_idx`) when this lane's tool is loaded but idle/parked, +# e.g. waiting between tool changes on a toolchanger. Overridden by +# the filament's color when led_use_filament_color is enabled below. # Format: (R,G,B,W) where 0 = off and 1 = full brightness. # # Setting value here overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) # section. led_tool_unloaded: 1,0,0,0 # Default: 1,0,0,0 -# LED color used when this lane is not loaded in the toolhead. +# Toolhead status LED color (`status_led_idx` on the extruder) shown +# when this lane's tool has just been unloaded from the toolhead. +# This does not affect the lane's own LED, which instead reverts to +# led_ready (or the filament color, if led_use_filament_color is +# enabled). # Format: (R,G,B,W) where 0 = off and 1 = full brightness. # # Setting value here overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) @@ -186,9 +207,12 @@ led_spool_illuminate: 1,1,1,0 # Loading color to illuminate spool, currently only for QuattroBox units. led_use_filament_color: False # Default: False -# When True, lane LED colors will use the filament color from the spool color -# field (set manually or synced from Spoolman) instead of the configured LED -# state colors. +# When True, the lane's LED (and, where noted above, the toolhead +# status LED) uses the filament color from the spool color field (set +# manually or synced from Spoolman) instead of the configured +# led_ready/led_tool_loaded_idle colors. Other states (fault, loading, +# unloading, not ready, tool loaded) always use their configured +# color regardless of this setting. # # Setting value here overrides values set in unit(AFC_BoxTurtle/NightOwl/etc) # section. @@ -771,51 +795,71 @@ espool_rot_dist: 132.9 # [AFC_stepper/AFC_lane] sections. led_fault: 1,0,0,0 # Default: 1,0,0,0 -# LED color to set when faults occur in lane +# LED color used when AFC flags a fault on the lane (jam, sensor +# mismatch, failed load/unload, etc) and the lane needs attention. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in AFC.cfg file. led_ready: 1,1,0,0 # Default: 1,1,0,0 -# LED color to set when lane is ready +# LED color used once filament is staged and ready behind the hub. +# Also used for the lane's own LED after a tool unload; see +# led_tool_unloaded below for the separate toolhead LED color used +# at that point. Overridden by the filament's color when +# led_use_filament_color is enabled below. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in AFC.cfg file. led_not_ready: 1,1,0,0 # Default: 1,1,0,0 -# LED color to set when lane is not ready +# LED color used when the lane is empty (no spool prepped). Also +# reused when a lane is unloaded back out of the hub but a spool is +# still prepped in the lane. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in AFC.cfg file. led_loading: 1,0,0,0 # Default: 1,0,0,0 -# LED color to set when lane is loading +# LED color used while filament is actively feeding into the lane, +# either loading to the toolhead or loading a spool into the lane. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in AFC.cfg file. led_unloading: 1,1,.5,0 # Default: 1,1,.5,0 -# LED color to set when lane is unloading +# LED color used while filament is backing out of the lane, either +# unloading from the toolhead or ejecting the lane. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in AFC.cfg file. led_tool_loaded: 1,1,0,0 # Default: 1,1,0,0 -# LED color to set when lane is loaded in toolhead +# LED color used on the lane's LED (and its toolhead status LED, if +# `status_led_idx` is set on the extruder) while this lane is the +# active/loaded tool. Not affected by led_use_filament_color. # (R,G,B,W) 0 = off, 1 = full brightness. Setting value here # overrides values set in AFC.cfg file. led_tool_loaded_idle: 0.4,0.4,0,0 # Default: 0.4,0.4,0,0 -# LED color used when a lane is loaded into the toolhead and idle. +# LED color used on the lane's LED and its toolhead status LED +# when this lane's tool is loaded but idle/parked, e.g. waiting +# between tool changes on a toolchanger. Overridden by the +# filament's color when led_use_filament_color is enabled below. # Format: (R,G,B,W) where 0 = off and 1 = full brightness. # # Setting value here overrides values set in AFC.cfg file. led_tool_unloaded: 1,0,0,0 # Default: 1,0,0,0 -# LED color used when a lane is not loaded in the toolhead. +# Toolhead status LED color (`status_led_idx` on the extruder) +# shown when this lane's tool has just been unloaded. Does not +# affect the lane's own LED, which instead reverts to led_ready +# (or the filament color, if led_use_filament_color is enabled). # Format: (R,G,B,W) where 0 = off and 1 = full brightness. # # Setting value here overrides values set in AFC.cfg file. led_use_filament_color: False # Default: False -# When True, lane LED colors will use the filament color from the spool color -# field (set manually or synced from Spoolman) instead of the configured LED -# state colors. +# When True, the lane's LED (and, where noted above, the toolhead +# status LED) uses the filament color from the spool color field +# (set manually or synced from Spoolman) instead of the configured +# led_ready/led_tool_loaded_idle colors. Other states (fault, +# loading, unloading, not ready, tool loaded) always use their +# configured color regardless of this setting. # # Setting value here overrides values set in AFC.cfg file. long_moves_speed: 100 diff --git a/docs/features.md b/docs/features.md index 2cf5c5b..50d887e 100644 --- a/docs/features.md +++ b/docs/features.md @@ -423,7 +423,7 @@ Endpoint returns all mapped tools in system in a json format like the following: - Name: Filament product name - Bed Temp: Bed temperature pulled from spoolman data - Nozzle Temp: Nozzle temperature pulled from spoolman data -- Scan Temp: Only is populated if TD-1 is connected and enabled in system and filament was scanned +- Scan Time: Only is populated if TD-1 is connected and enabled in system and filament was scanned - Lane: Tool number for this entry's `T(n)` key with the `T` stripped off. eg. entry key `T0` reports `"lane": "0"` - Extruder Index: Current extruder index that lane is attached to, useful in multi-toolhead setups where multiple lanes can be going to one toolhead. This variable is exposed so that third-party tools could use this variable to group filament/lanes attached to a single toolhead. - Spool ID: Spool ID assigned to this lane via [SET_SPOOL_ID](klipper/internal/spool.md#AFC_spool.AFCSpool.cmd_SET_SPOOL_ID) or [SET_NEXT_SPOOL_ID](klipper/internal/spool.md#AFC_spool.AFCSpool.cmd_SET_NEXT_SPOOL_ID). Value is an integer when a spool is assigned, or `null` when the lane is empty/ejected diff --git a/docs/features/led-effects.md b/docs/features/led-effects.md new file mode 100644 index 0000000..2c14cf6 --- /dev/null +++ b/docs/features/led-effects.md @@ -0,0 +1,225 @@ +# LED Effects + +AFC can layer animated effects from the [klipper-led_effect](https://github.com/julianschill/klipper-led_effect) +plugin on top of its normal lane/extruder status LEDs. This is fully optional: if you don't define any matching +`[led_effect]` sections, AFC continues to just set static LED colors as it always has. + +!!! warning "Install klipper-led_effect first" + + This feature requires the [klipper-led_effect](https://github.com/julianschill/klipper-led_effect) plugin. + It is not bundled with AFC and must be installed separately - follow the installation instructions on its + GitHub repository before continuing. None of the effects below will work until the plugin is installed + correctly and Klipper service has been restarted. + +## How it works + +AFC already sets a static color on a lane/extruder's LED any time it changes state (ready, loading, fault, etc.), +using the `led_ready`, `led_loading`, `led_fault`, etc. options from your [AFC_lane/AFC_stepper](../configuration/AFC_UnitType_1.cfg.md#afc_lane-lane_name-section) +config. When AFC changes a lane or extruder's state, it now also looks for a `[led_effect _]` section +that matches the lane/extruder name and the state it just entered. If one exists, AFC calls `SET_LED_EFFECT` to +overlay that animation on top of the static color; if it doesn't exist, nothing else happens. + +- `` is the lane name (e.g. `lane1`) or extruder name (e.g. `extruder`) as defined in your config. +- `` is one of the [callable states](#callable-states) below. +- Only that lane or extruder's own previously running effect is stopped when its state changes, so effects on + other lanes/extruders are not interrupted. + +!!! warning + + Since AFC itself calls `SET_LED_EFFECT` to start these effects, set `autostart: false` on every `[led_effect]` + section used with this feature. Otherwise the effect will also start on its own at Klipper startup, fighting + with AFC's static color. + +## Installing klipper-led_effect + +1. Install the plugin by following the instructions in the [klipper-led_effect repository](https://github.com/julianschill/klipper-led_effect). +2. Restart Klippers service once the plugin is installed. +3. Add `[led_effect _]` sections named to match your lanes/extruders and the states you want to + animate, using the [AFC_led](../configuration/AFC_UnitType_1.cfg.md#afc_led-led_name-section) chain/indexes you + already have configured for AFC's static LEDs. See [Example Configuration](#example-configuration) below. + +## Callable States + +| State | Applies to | Description | +|-------|-----------|--------------| +| `not_ready` | Lane only | Lane is empty, no spool prepped (prep and load sensors both `False`). | +| `loaded` | Lane only | Filament is staged and confirmed ready, behind the hub. | +| `loading` | Lane only | Filament is actively feeding into the lane, either loading to the toolhead or loading a spool into the lane itself. | +| `unloading` | Lane only | Filament is backing out of the lane, either unloading from the toolhead or ejecting from a lane. | +| `unloaded` | Lane only | Lane is no longer loaded, but a spool is still prepped (prep sensor still `True`). | +| `fault` | Lane only | Lane needs attention (jam, sensor mismatch, failed load/unload, etc). | +| `tool_loaded_gears` | Lane + extruder | Filament has reached the toolhead gears, part-way through a load, before `tool_loaded` fires. | +| `tool_loaded` | Lane + extruder | Lane is the active/loaded tool right now; fires on any tool change. | +| `tool_unloaded` | Lane + extruder | Tool was just unloaded from the toolhead. | +| `tool_loaded_idle` | Lane + extruder | Tool is loaded but idle/parked (e.g. on a toolchanger, toolhead is docked and lane is loaded into toolhead). | + +For the four "Lane + extruder" states, AFC triggers both a `_` effect and a matching +`_` effect at the same time, so you can animate the lane's LEDs and the toolhead's LEDs +together (or independently, by giving each its own colors/LED chain). + +## Example Configuration + +The following examples are from +[`templates/led_effects_examples.cfg`](https://github.com/AFCProject/AFC-Klipper-Add-On/blob/main/templates/led_effects_examples.cfg) +in the AFC-Klipper-Add-On repository. Update the `leds:` line and the LED index range/count on each `layers:` line +to match your own LED chain name and length before use - they will not work as-is with a different setup. + +### Loading / Unloading + +Rainbow gradient sweeps across the lane's LEDs. The pin order is reversed between loading and unloading so the +sweep visually travels in the direction filament is moving. + +```cfg +[led_effect lane1_loading] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + # All RGB values reduced by 50% (e.g., 1.0 -> 0.5) + gradient 1.0 1.0 add (0.5,0.0,0.0),(0.5,0.25,0.0),(0.5,0.5,0.0),(0.0,0.5,0.0),(0.0,0.0,0.5),(0.15,0.0,0.25) + +[led_effect lane1_unloading] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (16,15,14,13,12,11,10,9) +layers: + gradient 1.0 1.0 add (0.5,0.0,0.0),(0.5,0.25,0.0),(0.5,0.5,0.0),(0.0,0.5,0.0),(0.0,0.0,0.5),(0.15,0.0,0.25) +``` + +### Fault + +Fast red blink - the most urgent-looking state, distinct from the slower red breathe used by `not_ready`/`unloaded`. + +```cfg +[led_effect lane1_fault] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (16,15,14,13,12,11,10,9) +layers: + blink 1.0 0.5 top (1.0,0.0,0.0) +``` + +### Not Ready / Loaded + +Slow red breathe when the lane is empty, and the same slow breathe in the "good" color once filament is staged and +ready, so ready vs. empty is obvious at a glance. + +```cfg +[led_effect lane1_not_ready] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + breathing 2.5 0 top (1.0,0.0,0.0) + +[led_effect lane1_loaded] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + breathing 2.5 0 top (0.0,0.5,0.0) +``` + +### Unloaded + +A quick decaying flash for feedback when a lane is unloaded but still has a spool prepped, before the LED settles +back into whichever state follows. + +```cfg +[led_effect lane1_unloaded] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + strobe 2.0 3.0 add (1.0,0.0,0.0) +``` + +### Tool Loaded + +Fires on both the lane and its extruder any time that lane becomes the active/loaded tool. Two chase layers moving +in opposite directions, blended with `add` so both stay visible as they cross - the closest thing to a "back and +forth" animation the effect plugin supports, since it has no true bounce/ping-pong on a single layer. + +```cfg +[led_effect lane1_tool_loaded] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + chase 1.5 2 add (0.0,0.3,0.5),(0.0,0.15,0.25) + chase -1.5 2 add (0.0,0.3,0.5),(0.0,0.15,0.25) + +# Extruder counterpart, fires at the same time as lane1_tool_loaded. Named "extruder" here for a +# single toolhead setup - adjust to match your own [AFC_extruder] section name. +[led_effect extruder_tool_loaded] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + chase 1.5 2 add (0.0,0.3,0.5),(0.0,0.15,0.25) + chase -1.5 2 add (0.0,0.3,0.5),(0.0,0.15,0.25) +``` + +### Tool Loaded (Gears) + +Fires part-way through a load, once filament reaches the toolhead gears but before `tool_loaded` fires. Same blue +as `tool_loaded`, but a fast twinkle instead of a chase, so this intermediate step reads as distinct from the +completed load. + +```cfg +[led_effect lane1_tool_loaded_gears] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + twinkle 5 .5 top (0.0,0.3,0.5),(0.0,0.15,0.25) + +[led_effect extruder_tool_loaded_gears] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + twinkle 5 .5 top (0.0,0.3,0.5),(0.0,0.15,0.25) +``` + +### Tool Unloaded + +Fast, sparse purple sparkle when a tool is just unloaded from the toolhead - reads as the tool's presence +dissipating, with no directionality needed. + +```cfg +[led_effect lane1_tool_unloaded] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (16,15,14,13,12,11,10,9) +layers: + twinkle 5 .5 top (0.5,0.0,0.5),(0.25,0.0,0.25) + +[led_effect extruder_tool_unloaded] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (16,15,14,13,12,11,10,9) +layers: + twinkle 5 .5 top (0.5,0.0,0.5),(0.25,0.0,0.25) +``` + +### Tool Loaded (Idle) + +Tool loaded but idle, parked on dock between tool changes on a toolchanger. Slower breathe than `loaded` so "actively the +tool" vs. "just staged" feel distinct. + +```cfg +[led_effect lane1_tool_loaded_idle] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + breathing 4.0 0 top (0.4,0.4,0,0) + +[led_effect extruder_tool_loaded_idle] +autostart: false +frame_rate: 24 +leds: AFC_led:AFC_Indicator (9,10,11,12,13,14,15,16) +layers: + breathing 4.0 0 top (0.4,0.4,0,0) +``` diff --git a/mkdocs.yml b/mkdocs.yml index b056bae..f6b1439 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,7 +13,9 @@ nav: - Troubleshooting: troubleshooting/troubleshooting.md - AFC-Klipper-Add-On: - Overview: index.md - - Features: features.md + - Features: + - Overview: features.md + - LED Effects: features/led-effects.md - GUI Support: gui.md - Installation: - Getting Started: installation/getting-started.md