diff --git a/octoprint_CR10_Leveling/__init__.py b/octoprint_CR10_Leveling/__init__.py index 494440c..e2ef702 100644 --- a/octoprint_CR10_Leveling/__init__.py +++ b/octoprint_CR10_Leveling/__init__.py @@ -1,31 +1,15 @@ # coding=utf-8 from __future__ import absolute_import -from octoprint.settings import settings import octoprint.plugin -class Cr10_levelingPlugin(octoprint.plugin.SettingsPlugin, - octoprint.plugin.StartupPlugin): - - def on_after_startup(self): - s = settings() - addedControls = [{u'customClass': u'', u'layout': u'horizontal_grid', u'name': u'CR-10 Bed Leveling', u'children': [{u'width': u'11', u'commands': [u'M140 S50', u'M104 S170', u'M190 S50', u'M109 S170', u'', u'; Play tune', u'M300 S0 P66', u'M300 S987 P66', u'M300 S0 P66', u'M300 S1975 P66', u'M300 S0 P66', u'M300 S2959 P66', u'M300 S0 P66', u'M300 S2489 P66', u'M300 S0 P66', u'M300 S1975 P66', u'M300 S2959 P66', u'M300 S0 P133', u'M300 S2489 P133', u'M300 S0 P133', u'M300 S2093 P66', u'M300 S0 P66', u'M300 S4186 P66', u'M300 S0 P66', u'M300 S3135 P66', u'M300 S0 P66', u'M300 S2637 P66', u'M300 S0 P66', u'M300 S4186 P66', u'M300 S3135 P66', u'M300 S0 P133', u'M300 S2637 P133', u'M300 S0 P133', u'M300 S987 P66', u'M300 S0 P66', u'M300 S1975 P66', u'M300 S0 P66', u'M300 S2959 P66', u'M300 S0 P66', u'M300 S2489 P66', u'M300 S0 P66', u'M300 S1975 P66', u'M300 S2959 P66', u'M300 S0 P133', u'M300 S2489 P133', u'M300 S0 P133', u'M300 S2489 P66', u'M300 S2637 P66', u'M300 S2793 P66', u'M300 S0 P66', u'M300 S2793 P66', u'M300 S2959 P66', u'M300 S3135 P66', u'M300 S0 P66', u'M300 S3135 P66', u'M300 S3322 P66', u'M300 S1760 P66', u'M300 S0 P66', u'M300 S1975 P100'], u'customClass': u'btn btn-danger', u'name': u'Apply Heat', u'offset': u'2'}, {u'width': u'2', u'commands': [u'G1 Z10 F500', u'G1 X10 Y10 F3600', u'G1 Z0 F500', u'', u''], u'customClass': u'btn', u'name': u'Upper Left'}, {u'width': u'2', u'commands': [u'G1 Z10 F500', u'G1 X290 Y10 F3600', u'G1 Z0 F500', u''], u'customClass': u'btn', u'name': u'Upper Right', u'offset': u'2'}, {u'width': u'8', u'commands': [u'G1 Z10 F500', u'G1 X150 Y150 F3600', u'G1 Z0 F500', u''], u'customClass': u'btn', u'name': u'Center', u'offset': u'2'}, {u'width': u'2', u'commands': [u'G1 Z10 F500', u'G1 X10 Y290 F3600', u'G1 Z0 F500'], u'customClass': u'btn', u'name': u'Lower Left'}, {u'width': u'2', u'commands': [u'G1 Z10 F500', u'G1 X290 Y290 F3600', u'G1 Z0 F500'], u'customClass': u'btn', u'name': u'Lower Right', u'offset': u'2'}]}] - - addItemsToControl = True - for item in s.get(["controls"]): - if (item['name'] == 'CR-10 Bed Leveling'): - addItemsToControl = False - - if addItemsToControl: - addedControls = addedControls + s.get(["controls"]) - s.set(["controls"], addedControls) +class Cr10_levelingPlugin(octoprint.plugin.AssetPlugin): + def get_assets(self): + return dict(js=["cr10leveling.js"]) def get_update_information(self): - # Define the configuration for your plugin to use with the Software Update - # Plugin here. See https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update - # for details. return dict( CR10_Leveling=dict( displayName="CR-10 Leveling Plugin", diff --git a/octoprint_CR10_Leveling/static/cr10leveling.js b/octoprint_CR10_Leveling/static/cr10leveling.js new file mode 100644 index 0000000..4deb6fa --- /dev/null +++ b/octoprint_CR10_Leveling/static/cr10leveling.js @@ -0,0 +1,50 @@ +$(function() { + function MyCustomViewModel (parameters) { + var self = this; + + self.settings = parameters[0]; + + self.getAdditionalControls = function() { + return [{ + 'customClass': '', 'layout': 'horizontal_grid', 'name': 'CR-10 Bed Leveling', 'children': + [{'width': '11', 'commands': + ['M140 S50', 'M104 S170', 'M190 S50', 'M109 S170', '', '; Play tune', + 'M300 S0 P66', 'M300 S987 P66', 'M300 S0 P66', 'M300 S1975 P66', + 'M300 S0 P66', 'M300 S2959 P66', 'M300 S0 P66', 'M300 S2489 P66', + 'M300 S0 P66', 'M300 S1975 P66', 'M300 S2959 P66', 'M300 S0 P133', + 'M300 S2489 P133', 'M300 S0 P133', 'M300 S2093 P66', 'M300 S0 P66', + 'M300 S4186 P66', 'M300 S0 P66', 'M300 S3135 P66', 'M300 S0 P66', + 'M300 S2637 P66', 'M300 S0 P66', 'M300 S4186 P66', 'M300 S3135 P66', + 'M300 S0 P133', 'M300 S2637 P133', 'M300 S0 P133', 'M300 S987 P66', + 'M300 S0 P66', 'M300 S1975 P66', 'M300 S0 P66', 'M300 S2959 P66', + 'M300 S0 P66', 'M300 S2489 P66', 'M300 S0 P66', 'M300 S1975 P66', + 'M300 S2959 P66', 'M300 S0 P133', 'M300 S2489 P133', 'M300 S0 P133', + 'M300 S2489 P66', 'M300 S2637 P66', 'M300 S2793 P66', 'M300 S0 P66', + 'M300 S2793 P66', 'M300 S2959 P66', 'M300 S3135 P66', 'M300 S0 P66', + 'M300 S3135 P66', 'M300 S3322 P66', 'M300 S1760 P66', 'M300 S0 P66', + 'M300 S1975 P100'], + 'customClass': 'btn btn-danger', 'name': 'Apply Heat', 'offset': '2'}, + {'width': '2', 'commands': + ['G1 Z10 F500', 'G1 X10 Y10 F3600', 'G1 Z0 F500', '', ''], + 'customClass': 'btn', 'name': 'Upper Left'}, + {'width': '2', 'commands': + ['G1 Z10 F500', 'G1 X290 Y10 F3600', 'G1 Z0 F500', ''], + 'customClass': 'btn', 'name': 'Upper Right', 'offset': '2'}, + {'width': '8', 'commands': + ['G1 Z10 F500', 'G1 X150 Y150 F3600', 'G1 Z0 F500', ''], + 'customClass': 'btn', 'name': 'Center', 'offset': '2'}, + {'width': '2', 'commands': + ['G1 Z10 F500', 'G1 X10 Y290 F3600', 'G1 Z0 F500'], + 'customClass': 'btn', 'name': 'Lower Left'}, + {'width': '2', 'commands': + ['G1 Z10 F500', 'G1 X290 Y290 F3600', 'G1 Z0 F500'], + 'customClass': 'btn', 'name': 'Lower Right', 'offset': '2'}] + }] + } + } + + OCTOPRINT_VIEWMODELS.push({ + construct: MyCustomViewModel, + dependencies: ["controlViewModel"] + }); +}) diff --git a/setup.py b/setup.py index 5d4cd31..3f70d66 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "CR-10 Leveling" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.0.7" +plugin_version = "1.1.0" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module