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

feat: hides thermal sensors starting with "_" #1443

Merged
Merged
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
13 changes: 9 additions & 4 deletions docs/customize/hide_outputs.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
layout: default
title: Hide macros, output pins and fans
title: Hide macros, output pins, fans and sensors
parent: Customize
nav_order: 3
permalink: /customize/hide
---

# Hide macros, output pins and fans
# Hide macros, output pins, fans and sensors
{: .no_toc }

---

Fluidd allows you to hide macros, output pins and fans by prefixing them
with an underscore (`_`).
Fluidd allows you to hide macros, output pins, fans and sensors by prefixing
them with an underscore (`_`).

By doing this - you're removing them from Fluidd. This can be handy in
situations where you have a large quantiy of macros, or whereby you have an
Expand All @@ -31,6 +31,11 @@ gcode:
pin: z:P1.30
```

```yaml
[temperature_sensor _MCU]
sensor_type: MCU
```

Macros can also be hidden directly from the Fluidd settings by toggling their
visibility, in order to not change their name:
![screenshot](/assets/images/macro_visibility.png)
14 changes: 3 additions & 11 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,9 @@ export const getters: GetterTree<PrinterState, RootState> = {
const sensors = Object.keys(state.printer)
.reduce((groups, item) => {
const [type, nameFromSplit] = item.split(' ', 2)
const name = nameFromSplit ?? item

if (supportedSensors.includes(type)) {
const name = nameFromSplit ?? item
if (supportedSensors.includes(type) && !name.startsWith('_')) {
const prettyName = supportedDrivers.includes(type)
? i18n.t('app.general.label.stepper_driver',
{
Expand Down Expand Up @@ -775,19 +775,11 @@ export const getters: GetterTree<PrinterState, RootState> = {
]
]

const filterByPrefix = [
'temperature_fan'
]

const printerKeys = Object.keys(state.printer)

const sensors = keyGroups.flatMap(keyGroup => {
const keyGroupRegExpArray = keyGroup
.map(x => new RegExp(
filterByPrefix.includes(x)
? `^${x}(?! _)`
: `^${x}`)
)
.map(x => new RegExp(`^${x}(?! _)`))

return printerKeys
.filter(key => keyGroupRegExpArray.some(x => x.test(key)))
Expand Down