diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 009e32f..bd56b55 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,6 +2,7 @@ as accurately as possible. If this template is not filled out the pull request may be closed Thank you for your cooperation! --> + #### What does this PR do and why is it necessary? #### How was it tested? How can it be tested by the reviewer? @@ -9,9 +10,10 @@ #### Relevant issues/discussion (if any) #### Please make sure your PR ticks all the boxes below: -* [ ] If your changes are large or otherwise disruptive: You have discussed these changes by opening an issue first -* [ ] Your PR targets the `devel` branch (No PRs to master please!) -* [ ] If your changes include stylesheets: You have modified the SCSS source (**Not the compiled CSS**) -* [ ] You have run the existing unit tests against your plugin and nothing broke -* [ ] You have read the [Contribution Guidelines](https://github.com/cp2004/OctoPrint-EEPROM-Marlin/blob/master/CONTRIBUTING.md) -* [ ] You have added yourself to the contributors section :) (see `supporters-contributors.py`) + +- [ ] If your changes are large or otherwise disruptive: You have discussed these changes by opening an issue first +- [ ] Your PR targets the `devel` branch (No PRs to master please!) +- [ ] If your changes include stylesheets: You have modified the SCSS source (**Not the compiled CSS**) +- [ ] You have run the existing unit tests against your plugin and nothing broke +- [ ] You have read the [Contribution Guidelines](https://github.com/cp2004/OctoPrint-EEPROM-Marlin/blob/master/CONTRIBUTING.md) +- [ ] You have added yourself to the contributors section :) (see `supporters-contributors.py`) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f1f034..a5f0183 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,9 @@ jobs: - name: ๐จ Build a source zip run: | python setup.py sdist --formats=zip + - name: ๐ rename to sdist.zip + run: | + mv dist/Marlin\ EEPROM\ editor-*.zip dist/sdist.zip - name: โฌ Upload build result uses: actions/upload-artifact@v1 with: @@ -50,7 +53,7 @@ jobs: python -m pip install octoprint - name: ๐งช Test install of package run: | - python -m pip install "dist/Marlin EEPROM editor-*.zip" + python -m pip install dist/sdist.zip upload-asset: name: ๐ฆ Upload asset to release @@ -66,7 +69,7 @@ jobs: path: dist - name: ๐ Rename to release.zip run: | - cp "dist/Marlin EEPROM editor-*.zip" release.zip + cp dist/sdist.zip release.zip - name: ๐ฅ Catch release ID id: get_release uses: bruceadams/get-release@v1.2.2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b882c41..74ad9bd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,11 +10,11 @@ Otherwise your changes would be overwritten as soon as I clone the repository by To compile the CSS (Assuming project root, adjust the path otherwise): -* Install [Sass](https://sass-lang.com/install) using `npm install -g sass` +- Install [Sass](https://sass-lang.com/install) using `npm install -g sass` -* Run `sass octoprint_eeprom_marlin/static/scss/eeprom_marlin.scss octoprint_eeprom_marlin/static/css/eeprom_marlin.css` to compile the CSS. +- Run `sass octoprint_eeprom_marlin/static/scss/eeprom_marlin.scss octoprint_eeprom_marlin/static/css/eeprom_marlin.css` to compile the CSS. -Then you can commit *both* changes to ensure they are not overriden. +Then you can commit _both_ changes to ensure they are not overriden. #### Pre-commit @@ -22,9 +22,9 @@ There's a pre-commit suite ready in this plugin that keeps an eye on code style, It is recommended you install it, but it can also be run as a one-off or as a file watcher too. There is PR check that will validate this, and will complain if it does not pass. -* To install: `pre-commit install` -* To run against the entire codebase: `pre-commit run --hook-stage manual --all-files` -* For details of how to set this up with PyCharm Pro, please see the 'File Watcher/Pre-commit' section [OctoPrint documentation](https://docs.octoprint.org/en/master/development/environment.html#pycharm) +- To install: `pre-commit install` +- To run against the entire codebase: `pre-commit run --hook-stage manual --all-files` +- For details of how to set this up with PyCharm Pro, please see the 'File Watcher/Pre-commit' section [OctoPrint documentation](https://docs.octoprint.org/en/master/development/environment.html#pycharm) #### Adding yourself to the contributors section of the plugin @@ -39,6 +39,7 @@ CONTRIBUTORS = [ ``` Add your name as another dictionary to this list, like so: + ```diff CONTRIBUTORS = [ {"name": "Anderson Silva (Previous maintainer)", "username": "amsbr"}, @@ -48,8 +49,7 @@ Add your name as another dictionary to this list, like so: Your name should then show up under 'Show Contributors' in the plugin's settings pages. - #### Other points -* Please make your contributions against the `devel` branch, to make sure it has the latest codebase. Only exceptions are documentation fixes, such as this one. -* Please fill out the pull request template, to make things easier for me to process. I reply to a lot of things, and may not have the time to do the research myself! +- Please make your contributions against the `devel` branch, to make sure it has the latest codebase. Only exceptions are documentation fixes, such as this one. +- Please fill out the pull request template, to make things easier for me to process. I reply to a lot of things, and may not have the time to do the research myself! diff --git a/octoprint_eeprom_marlin/data.py b/octoprint_eeprom_marlin/data.py index 9db50c0..4655057 100644 --- a/octoprint_eeprom_marlin/data.py +++ b/octoprint_eeprom_marlin/data.py @@ -10,6 +10,7 @@ except ImportError: # we don't need these, just for typed comments # TODO PY3: Type annotations! + Dict = Optional = None pass COMMAND_PARAMS = { @@ -28,6 +29,7 @@ "M205": ["S", "T", "B", "X", "Y", "Z", "E", "J"], "M420": ["S", "Z"], "M145": ["S", "B", "H", "F"], + "M603": ["L", "U"], } COMMAND_NAMES = { @@ -46,6 +48,7 @@ "M205": "advanced", "M420": "autolevel", "M145": "material", + "M603": "filament_change", } @@ -128,7 +131,11 @@ def __init__(self, plugin): self.autolevel = IndividualData("autolevel", "M420", ["S", "Z"]) self.material1 = IndividualData("material1", "M145", ["S", "B", "H", "F"]) self.material2 = IndividualData("material2", "M145", ["S", "B", "H", "F"]) + self.filament_change = IndividualData( + "filament_change", "M603", COMMAND_PARAMS["M603"] + ) + # noinspection PyProtectedMember self.plugin._logger.info("EEPROM Data initialised") def from_list(self, data): @@ -155,10 +162,12 @@ def from_dict(self, data, ui=True): data_class = self.material2 else: # unable to parse again + # noinspection PyProtectedMember self.plugin._logger.error("Unable to parse M145 command") return except KeyError: # Unable to parse M145 + # noinspection PyProtectedMember self.plugin._logger.error("Unable to parse M145 command") return else: diff --git a/octoprint_eeprom_marlin/parser.py b/octoprint_eeprom_marlin/parser.py index 2993268..41dd663 100644 --- a/octoprint_eeprom_marlin/parser.py +++ b/octoprint_eeprom_marlin/parser.py @@ -44,6 +44,7 @@ def regex_creator(value_type, param_letter): "floatR": regex_creator("float", "R"), "floatS": regex_creator("float", "S"), "floatT": regex_creator("float", "T"), + "floatU": regex_creator("float", "U"), "floatX": regex_creator("float", "X"), "floatY": regex_creator("float", "Y"), "floatZ": regex_creator("float", "Z"), @@ -82,8 +83,8 @@ def parse_eeprom_data(self, line): try: params = data.COMMAND_PARAMS[command] except KeyError: - self._logger.error("Unrecognised EEPROM output line, could not parse") - self._logger.error("Line: {}".format(line)) + self._logger.warning("Did not recognise EEPROM data, skipping line") + self._logger.warning("Line: {}".format(line)) return # work out what values we have @@ -92,10 +93,10 @@ def parse_eeprom_data(self, line): try: param_match = regexes_parameters["float{}".format(param)].search(line) except KeyError: - self._logger.error( - "Unrecognised EEPROM command parameter, could not parse" + self._logger.warning( + "Did not recognise EEPROM parameter, skipping param" ) - self._logger.error("Parameter: {}".format(param)) + self._logger.warning("Parameter: {}".format(param)) continue if param_match: parameters[param] = float(param_match.group("value")) diff --git a/octoprint_eeprom_marlin/static/css/eeprom_marlin.css b/octoprint_eeprom_marlin/static/css/eeprom_marlin.css index d7a0133..af3e6ee 100644 --- a/octoprint_eeprom_marlin/static/css/eeprom_marlin.css +++ b/octoprint_eeprom_marlin/static/css/eeprom_marlin.css @@ -4,6 +4,14 @@ #touch body #navbar #all_touchui_settings #tab_plugin_eeprom_marlin_link a:before, #touch body #navbar #all_touchui_settings #tab_plugin_eeprom_marlin_link2 a:before { content: "๏ "; } +#touch body #tab_plugin_eeprom_marlin .table { + width: auto !important; + min-width: 100% !important; } +#touch body #tab_plugin_eeprom_marlin .fas-custom { + font-family: "Font Awesome 5 Free" !important; + font-weight: 900 !important; } +#touch body #tab_plugin_eeprom_marlin .btn-group { + margin-top: 2px; } #tab_plugin_eeprom_marlin div.eeprom-nav { margin-bottom: 12.5px; } diff --git a/octoprint_eeprom_marlin/static/css/eeprom_marlin.css.map b/octoprint_eeprom_marlin/static/css/eeprom_marlin.css.map index 795835b..40d2f04 100644 --- a/octo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IAAI;EACjB,aAAa,EAAE,cAAc;EAC7B,YAAY,EAAE,cAAc;EAC5B,aAAa,EAAE,SAAS;EACxB,OAAO,EAAE,GAAG;EAEZ,yCAAE;IACA,aAAa,EAAE,CAAC;AAIpB,sCAAa;EACX,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;AAGZ,gDAAuB;EACrB,UAAU,EAAE,CAAC;AAIb,2CAAE;EACA,SAAS,EAAE,QAAQ;EACnB,UAAU,EAAE,MAAM;EAElB;kDACK;IACH,aAAa,EAAE,GAAG;AAQtB;;;;;0CACE;EACA,UAAU,EAAE,MAAM;EAClB;;;;;uDAAW;IACT,WAAW,EAAE,MAAM", "sources": ["../scss/eeprom_marlin.scss"], "names": [], "file": "eeprom_marlin.css" diff --git a/octoprint_eeprom_marlin/static/js/eeprom_marlin.js b/octoprint_eeprom_marlin/static/js/eeprom_marlin.js index 8fa98f5..b63bfd3 100755 --- a/octoprint_eeprom_marlin/static/js/eeprom_marlin.js +++ b/octoprint_eeprom_marlin/static/js/eeprom_marlin.js @@ -376,6 +376,26 @@ $(function () { return steps; })(); + eeprom.filament_change = (function () { + var filament_change = {}; + + filament_change.L = ko.observable(); + filament_change.U = ko.observable(); + + filament_change.visible = ko.computed(function () { + for (let param in filament_change) { + if (param === "visible") { + continue; + } + if (filament_change[param]() !== null) { + return true; + } + } + return false; + }); + return filament_change; + })(); + return eeprom; })(); @@ -693,6 +713,18 @@ $(function () { units: "steps/mm", }, ], + filament_change: [ + { + label: "Load length", + value: self.eeprom.filament_change.L, + units: "mm", + }, + { + label: "Unload length", + value: self.eeprom.filament_change.U, + units: "mm", + }, + ], }; self.eeprom_from_json = function (data) { @@ -700,7 +732,12 @@ $(function () { for (let key in data.eeprom) { let value = data.eeprom[key]; for (let param in value.params) { - self.eeprom[key][param](value.params[param]); + try { + self.eeprom[key][param](value.params[param]); + } catch { + console.log(key); + console.log(param); + } } } self.unsaved(false); diff --git a/octoprint_eeprom_marlin/static/scss/eeprom_marlin.scss b/octoprint_eeprom_marlin/static/scss/eeprom_marlin.scss index eb8f6be..21ec192 100644 --- a/octoprint_eeprom_marlin/static/scss/eeprom_marlin.scss +++ b/octoprint_eeprom_marlin/static/scss/eeprom_marlin.scss @@ -1,6 +1,11 @@ $touchUI_icon: "\f14b"; #touch body { + // TOUCHUI Specific styles + // Yes, it annoys me that TouchUI overrides lots of styles, that make the UI look a little broken + // But we will have to deal with it for as long as touchUI exists & people want to use it + + // Touch tab icon #tabs, #navbar #all_touchui_settings { #tab_plugin_eeprom_marlin_link, @@ -10,6 +15,24 @@ $touchUI_icon: "\f14b"; } } } + // Override some styles to format things a little better **only** within my plugin + // Uses !important to override touch UI styles definitely, we risk chance otherwise. + #tab_plugin_eeprom_marlin { + // override width of the table to stop it going off screen + .table { + width: auto !important; + min-width: 100% !important; + } + // bring back custom icons to buttons + .fas-custom { + font-family: "Font Awesome 5 Free" !important; + font-weight: 900 !important; + } + // apply a *little* bit of margin to separate the button groups, should they be stacked. + .btn-group { + margin-top: 2px; + } + } } #tab_plugin_eeprom_marlin { diff --git a/octoprint_eeprom_marlin/templates/backup/content.jinja2 b/octoprint_eeprom_marlin/templates/backup/content.jinja2 index 80212b1..48a470e 100644 --- a/octoprint_eeprom_marlin/templates/backup/content.jinja2 +++ b/octoprint_eeprom_marlin/templates/backup/content.jinja2 @@ -19,13 +19,13 @@