waltmoorhouse / OctoPrint-Filamentstorage

OctoPrint Plugin for an Open Source Filament Storage system.
https://github.com/waltmoorhouse/FilamentBox
22 stars 4 forks source link

Set the amount of spools #7

Open TheSin- opened 4 years ago

TheSin- commented 4 years ago

Would it be possible to have a variable to set how many spools in the box I have a need for 5 spools since I run a dual nozzle with a pallet.

TheSin- commented 4 years ago

just looking at the code it seems that reading the input put could use a bit better splitting, you could use a regex match that does

/([HTSLP])([0-9]+)?:([0-9]{1,2}.[0-9]{2}|ON|OFF)/g

Then you can read $1, if $2 is required to find out which one and $3 for the value

https://regex101.com/r/c0Zbg3/1

Then you could easily check your functions to include a Spool number in the call based on $2 and not have to have 4 duplication functions, and the amount of spools would be able to change from 1+

It would simplify the code and allow more variance

waltmoorhouse commented 2 years ago

Please submit a PR and I will review and approve. I'm not a Python developer, so I know there are things that could be improved.