Skip to content

Commit

Permalink
Merge pull request #10 from Z-Bolt/2.6.0-dev
Browse files Browse the repository at this point in the history
2.6.0 dev into master
  • Loading branch information
JeffB42 authored Dec 29, 2020
2 parents 56eca75 + 0b20396 commit 32f6672
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 43 deletions.
39 changes: 24 additions & 15 deletions octoprint_zbolt_octoscreen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ZBoltOctoScreenPlugin(octoprint.plugin.SettingsPlugin,
def initialize(self):
Notifications.initialize(self._plugin_manager)
self.Settings = ZBoltOctoScreenSettings(self._settings)


def get_assets(self):
return dict(
Expand All @@ -31,7 +30,7 @@ def get_assets(self):
)

def get_settings_defaults(self):
return ZBoltOctoScreenSettings.default_settings()
return ZBoltOctoScreenSettings.default_settings()

def get_template_vars(self):
return ZBoltOctoScreenSettings.template_vars()
Expand All @@ -46,34 +45,44 @@ def on_settings_save(self, data):
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)

def on_api_command(self, command, data):
# Warning! get_notification and get_settings have been moved.
# They are no longer POST operations and are now GET operations.
# This code will remain here for a few release but will eventually
# be deprecated.
if command == "get_notification":
return flask.jsonify(message = Notifications.get_message_to_display())
elif command == "get_settings":
elif command == "get_settings":
return flask.jsonify(self.Settings.get_all())

def on_api_get(self, request):
return flask.jsonify(printer_name="test2")

if len(request.values) != 0:
command = request.values["command"]
if command == "get_notification":
msg = Notifications.get_message_to_display()
if msg is None:
msg = ""
return flask.jsonify(message = msg)
elif command == "get_settings":
return flask.jsonify(self.Settings.get_all())

def get_template_configs(self):
return [
dict(type="settings", name="Z-Bolt OctoScreen", custom_bindings=False),
]


##~~ Softwareupdate hook
def get_update_information(self):
return dict(
zbolt_octoscreen=dict(
displayName = "Z-Bolt OctoScreen",
displayVersion = self._plugin_version,
zbolt_octoscreen = dict(
displayName = "Z-Bolt OctoScreen",
displayVersion = self._plugin_version,

type="github_release",
user="Z-Bolt",
repo="OctoPrint-Z-Bolt-OctoScreen",
current=self._plugin_version,
type = "github_release",
user = "Z-Bolt",
repo = "OctoPrint-Z-Bolt-OctoScreen",
current = self._plugin_version,

pip="https://github.com/Z-Bolt/OctoPrint-Z-Bolt-OctoScreen/archive/{target_version}.zip"
pip = "https://github.com/Z-Bolt/OctoPrint-Z-Bolt-OctoScreen/archive/{target_version}.zip"
)
)

Expand All @@ -82,7 +91,7 @@ def get_update_information(self):
__plugin_pythoncompat__ = ">=2.7,<4"

def __plugin_load__():
global __plugin_implementation__
global __plugin_implementation__
__plugin_implementation__ = ZBoltOctoScreenPlugin()

global __plugin_hooks__
Expand Down
5 changes: 0 additions & 5 deletions octoprint_zbolt_octoscreen/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def send_message(self, message):
payload['text'] = message['text']
self._plugin_manager.send_plugin_message("zbolt_octoscreen", payload)


def get_message_to_display(self):
if not self._message:
return None
Expand All @@ -32,7 +31,3 @@ def get_message_to_display(self):
return m

Notifications = NotificationsStorage()




45 changes: 23 additions & 22 deletions octoprint_zbolt_octoscreen/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import json

zbolt_toolchanger_installed = True


default_menu_structure = """[
{
Expand All @@ -20,9 +18,9 @@
"panel": "move"
},
{
"name": "Extrude",
"icon": "filament",
"panel": "extrude_multitool"
"name": "Filament",
"icon": "filament-spool",
"panel": "filament"
},
{
"name": "Fan",
Expand All @@ -38,18 +36,13 @@
"name": "Control",
"icon": "control",
"panel": "control"
},
{
"name": "ToolChanger",
"icon": "toolchanger",
"panel": "toolchanger"
}
]
},
{
"name": "Filament",
"icon": "filament",
"panel": "filament_multitool"
"icon": "filament-spool",
"panel": "filament"
},
{
"name": "Configuration",
Expand Down Expand Up @@ -87,6 +80,15 @@ def __init__(self, settings):
self.default_menu_structure = default_menu_structure

def get_all(self):
json_menu_structure = None
try:
menu_structure = self._settings.get(["menu_structure"])
if menu_structure is None or menu_structure == "":
menu_structure = "[]"
json_menu_structure = json.loads(menu_structure)
except:
json_menu_structure = []

return {
"filament_in_length": float(self._settings.get(["filament_in_length"])),
"filament_out_length": float(self._settings.get(["filament_out_length"])),
Expand All @@ -95,23 +97,22 @@ def get_all(self):
"x_axis_inverted": bool(self._settings.get(["x_axis_inverted"])),
"y_axis_inverted": bool(self._settings.get(["y_axis_inverted"])),
"z_axis_inverted": bool(self._settings.get(["z_axis_inverted"])),
"menu_structure": json.loads(self._settings.get(["menu_structure"])),
"menu_structure": json_menu_structure,
}

@staticmethod
def default_settings():
return dict(
filament_in_length=750,
filament_out_length=800,
toolchanger=False,
x_axis_inverted=False,
y_axis_inverted=False,
z_axis_inverted=True,
gcodes=dict(auto_bed_level="G29"),
filament_in_length = 750,
filament_out_length = 800,
toolchanger = False,
x_axis_inverted = False,
y_axis_inverted = False,
z_axis_inverted = False,
gcodes=dict(auto_bed_level = "G29"),
menu_structure=default_menu_structure,
)

@staticmethod
def template_vars():
return dict(default_menu_structure=default_menu_structure)

return dict(default_menu_structure = default_menu_structure)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-Z-Bolt-OctoScreen"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.2.0"
plugin_version = "2.6.0"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 32f6672

Please sign in to comment.