-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 74d8fe5
Showing
12 changed files
with
376 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# OctoPrint-BedLevelVisualizer | ||
|
||
 | ||
|
||
This plugin utilizes [Plotly](https://plot.ly/plotly-js-scientific-d3-charting-library/) js library to render a 3D surface of the bed's reported mesh on a tab within OctoPrint. | ||
|
||
**Note:** Currently only tested with a UBL report, but should work with others as long as `G29 T1` command responds like below. Also currently reuires Marlin temperature auto-reporting enabled until I can figure out how to pause OctoPrint's temperature polling. | ||
|
||
``` | ||
Send: G29 T1 | ||
Recv: echo:Home XYZ first | ||
Recv: | ||
Recv: Bed Topography Report for CSV: | ||
Recv: | ||
Recv: 0.256,0.170,0.140,0.535,0.183,0.159,0.054,0.197,0.105,0.105 | ||
Recv: 0.488,0.277,0.174,-0.049,0.125,0.020,0.027,0.070,-0.006,-0.006 | ||
Recv: 0.479,0.197,0.220,0.062,0.116,0.062,-0.053,0.169,0.038,0.038 | ||
Recv: 0.315,0.306,0.126,0.079,-0.096,-0.008,0.014,-0.105,0.011,0.127 | ||
Recv: 0.444,0.362,0.162,0.084,-0.160,-0.100,-0.074,-0.079,0.038,0.154 | ||
Recv: 0.506,0.293,0.195,0.274,0.093,-0.040,0.040,-0.083,-0.131,-0.131 | ||
Recv: 0.583,0.265,0.174,0.517,0.042,-0.021,-0.083,-0.094,-0.130,-0.130 | ||
Recv: 0.425,0.267,0.270,0.370,0.073,-0.125,-0.075,-0.057,-0.056,-0.056 | ||
Recv: 0.499,0.356,0.280,0.266,0.056,0.053,-0.021,0.120,-0.171,-0.171 | ||
Recv: 0.438,0.265,0.188,-0.154,0.141,0.005,-0.041,-0.117,-0.135,-0.135 | ||
Recv: ok P15 B3 | ||
``` | ||
|
||
## Setup | ||
|
||
Install via the bundled [Plugin Manager](https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager) | ||
or manually using this URL: | ||
|
||
https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/archive/master.zip | ||
|
||
## Changelog | ||
|
||
- **[0.0.1]** (04/14/2018): Initial Release | ||
|
||
[0.0.1]: https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/tree/0.0.1 | ||
|
||
## To-Do | ||
- [ ] Pause standard OctoPrint temperature polling or squash the responses until processing is completed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[python: */**.py] | ||
[jinja2: */**.jinja2] | ||
extensions=jinja2.ext.autoescape, jinja2.ext.with_ | ||
|
||
[javascript: */**.js] | ||
extract_messages = gettext, ngettext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
layout: plugin | ||
|
||
id: bedlevelvisualizer | ||
title: Bed Level Visualizer | ||
description: Displays 3D mesh of bed topography report. | ||
author: jneilliii | ||
license: MIT License | ||
|
||
date: 2018-04-14 | ||
|
||
homepage: https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/ | ||
source: https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/ | ||
archive: https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/archive/master.zip | ||
|
||
tags: | ||
- bed level | ||
- mesh | ||
- tab | ||
- graph | ||
|
||
screenshots: | ||
- url: /assets/img/plugins/bedlevelvisualizer/screenshot.png | ||
alt: Screenshot | ||
caption: Bed Level Visualizer | ||
|
||
featuredimage: /assets/img/plugins/bedlevelvisualizer/screenshot.png | ||
|
||
compatibility: | ||
octoprint: | ||
- 1.2.0 | ||
os: | ||
- linux | ||
- windows | ||
- macos | ||
- freebsd | ||
|
||
--- | ||
|
||
This plugin utilizes [Plotly](https://plot.ly/plotly-js-scientific-d3-charting-library/) js library to render a 3D surface of the bed's reported mesh on a tab within OctoPrint. | ||
|
||
**Note:** Currently only tested with a UBL report, but should work with others as long as `G29 T1` command responds like below. | ||
|
||
``` | ||
Send: G29 T1 | ||
Recv: echo:Home XYZ first | ||
Recv: | ||
Recv: Bed Topography Report for CSV: | ||
Recv: | ||
Recv: 0.256,0.170,0.140,0.535,0.183,0.159,0.054,0.197,0.105,0.105 | ||
Recv: 0.488,0.277,0.174,-0.049,0.125,0.020,0.027,0.070,-0.006,-0.006 | ||
Recv: 0.479,0.197,0.220,0.062,0.116,0.062,-0.053,0.169,0.038,0.038 | ||
Recv: 0.315,0.306,0.126,0.079,-0.096,-0.008,0.014,-0.105,0.011,0.127 | ||
Recv: 0.444,0.362,0.162,0.084,-0.160,-0.100,-0.074,-0.079,0.038,0.154 | ||
Recv: 0.506,0.293,0.195,0.274,0.093,-0.040,0.040,-0.083,-0.131,-0.131 | ||
Recv: 0.583,0.265,0.174,0.517,0.042,-0.021,-0.083,-0.094,-0.130,-0.130 | ||
Recv: 0.425,0.267,0.270,0.370,0.073,-0.125,-0.075,-0.057,-0.056,-0.056 | ||
Recv: 0.499,0.356,0.280,0.266,0.056,0.053,-0.021,0.120,-0.171,-0.171 | ||
Recv: 0.438,0.265,0.188,-0.154,0.141,0.005,-0.041,-0.117,-0.135,-0.135 | ||
Recv: ok P15 B3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# coding=utf-8 | ||
from __future__ import absolute_import | ||
|
||
import octoprint.plugin | ||
import re | ||
|
||
class bedlevelvisualizer(octoprint.plugin.StartupPlugin, | ||
octoprint.plugin.TemplatePlugin, | ||
octoprint.plugin.AssetPlugin): | ||
|
||
def __init__(self): | ||
self.processing = False | ||
self.mesh = [] | ||
|
||
##~~ StartupPlugin | ||
def on_after_startup(self): | ||
self._logger.info("OctoPrint-BedLevelVisualizer loaded!") | ||
|
||
##~~ AssetPlugin | ||
def get_assets(self): | ||
return dict( | ||
js=["js/bedlevelvisualizer.js","js/plotly-latest.min.js"] | ||
) | ||
|
||
##~~ GCODE hook | ||
def processGCODE(self, comm, line, *args, **kwargs): | ||
if "Bed Topography Report for CSV:" in line: | ||
self.processing = True | ||
self.mesh = [] | ||
return line | ||
|
||
if self.processing and "ok" not in line and re.match(r"^(-?(\d+.\d+)[,|\s])+", line.strip()): | ||
self.mesh.append(line.strip().split(",")) | ||
return line | ||
|
||
if self.processing and "ok" in line: | ||
self.processing = False | ||
self._plugin_manager.send_plugin_message(self._identifier, dict(mesh=self.mesh)) | ||
|
||
return line | ||
|
||
##~~ Softwareupdate hook | ||
def get_update_information(self): | ||
return dict( | ||
bedlevelvisualizer=dict( | ||
displayName="Bed Visualizer", | ||
displayVersion=self._plugin_version, | ||
|
||
# version check: github repository | ||
type="github_release", | ||
user="jneilliii", | ||
repo="OctoPrint-BedLevelVisualizer", | ||
current=self._plugin_version, | ||
|
||
# update method: pip | ||
pip="https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/archive/{target_version}.zip" | ||
) | ||
) | ||
|
||
__plugin_name__ = "Bed Visualizer" | ||
|
||
def __plugin_load__(): | ||
global __plugin_implementation__ | ||
__plugin_implementation__ = bedlevelvisualizer() | ||
|
||
global __plugin_hooks__ | ||
__plugin_hooks__ = { | ||
"octoprint.comm.protocol.gcode.received": __plugin_implementation__.processGCODE, | ||
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information | ||
} |
59 changes: 59 additions & 0 deletions
59
octoprint_bedlevelvisualizer/static/js/bedlevelvisualizer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
$(function () { | ||
function bedlevelvisualizerViewModel(parameters) { | ||
var self = this; | ||
|
||
self.settingsViewModel = parameters[0]; | ||
self.controlViewModel = parameters[1]; | ||
self.loginStateViewModel = parameters[2]; | ||
|
||
self.processing = ko.observable(false); | ||
self.loadedData = ko.observableArray(); | ||
|
||
self.onDataUpdaterPluginMessage = function(plugin, data) { | ||
if (plugin != "bedlevelvisualizer") { | ||
return; | ||
} | ||
if (data.mesh) { | ||
self.processing(false); | ||
self.controlViewModel.sendCustomCommand({type:'command',command:'M155 S3'}); | ||
var data = [{ | ||
z: data.mesh, | ||
type: 'surface' | ||
}]; | ||
|
||
var layout = { | ||
//title: 'Bed Leveling Mesh', | ||
autosize: true, | ||
margin: { | ||
l: 0, | ||
r: 0, | ||
b: 0, | ||
t: 0, | ||
} | ||
}; | ||
Plotly.newPlot('bedlevelvisualizergraph', data, layout); | ||
self.loadedData(data.mesh); | ||
} | ||
} | ||
|
||
self.onAfterTabChange = function (current, previous) { | ||
if (current == "#tab_plugin_bedlevelvisualizer" && self.controlViewModel.isOperational() && !self.controlViewModel.isPrinting() && self.loginStateViewModel.isUser() && !self.processing()) { | ||
if(!self.loadedData().length > 0) { | ||
self.updateMesh(); | ||
} | ||
} | ||
}; | ||
|
||
self.updateMesh = function(){ | ||
self.processing(true); | ||
self.controlViewModel.sendCustomCommand({type:'command',command:'M155 S0'}); | ||
self.controlViewModel.sendCustomCommand({type:'command',command:'G29 T1'}); | ||
} | ||
} | ||
|
||
OCTOPRINT_VIEWMODELS.push({ | ||
construct: bedlevelvisualizerViewModel, | ||
dependencies: [ "settingsViewModel","controlViewModel","loginStateViewModel" ], | ||
elements:[ "#tab_plugin_bedlevelvisualizer" ] | ||
}); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
octoprint_bedlevelvisualizer/templates/bedlevelvisualizer_tab.jinja2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="row-fluid" id="bedlevelvisualizerwait" style="text-align: center;font-size: 25px;vertical-align: middle;" data-bind="visible: controlViewModel.isOperational() && !controlViewModel.isPrinting() && loginStateViewModel.isUser() && processing()"><i class="icon-spinner icon-spin icon-3"></i> <b>Please wait, retrieving current mesh.</b></div> | ||
<div class="row-fluid" id="bedlevelvisualizerwarning" style="text-align: center;font-size: 25px;vertical-align: middle;" data-bind="visible: ((!controlViewModel.isOperational() || controlViewModel.isPrinting()) && loginStateViewModel.isUser())"><i class="icon-warning-sign icon-3" style="color:red"></i> <b>You must be connected and not printing!</b></div> | ||
<div class="row-fluid" data-bind="visible: controlViewModel.isOperational() && !controlViewModel.isPrinting() && loginStateViewModel.isUser() && !processing()"> | ||
<div class="row-fluid" id="bedlevelvisualizergraph"></div> | ||
<div class="row-fluid" id="bedlevelvisualizerbutton" style="text-align: center;padding-top: 20px;"><button class="btn" data-bind="click: updateMesh,enable: controlViewModel.isOperational() && !controlViewModel.isPrinting() && loginStateViewModel.isUser() && !processing()">Update</button></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### | ||
# This file is only here to make sure that something like | ||
# | ||
# pip install -e . | ||
# | ||
# works as expected. Requirements can be found in setup.py. | ||
### | ||
|
||
. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# coding=utf-8 | ||
|
||
######################################################################################################################## | ||
### Do not forget to adjust the following variables to your own plugin. | ||
|
||
# The plugin's identifier, has to be unique | ||
plugin_identifier = "bedlevelvisualizer" | ||
|
||
# The plugin's python package, should be "octoprint_<plugin identifier>", has to be unique | ||
plugin_package = "octoprint_bedlevelvisualizer" | ||
|
||
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the | ||
# plugin module | ||
plugin_name = "Bed Visualizer" | ||
|
||
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module | ||
plugin_version = "0.0.1" | ||
|
||
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin | ||
# module | ||
plugin_description = """A plugin to allow streaming live to YouTube.""" | ||
|
||
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module | ||
plugin_author = "jneilliii" | ||
|
||
# The plugin's author's mail address. | ||
plugin_author_email = "jneilliii+octoprint@gmail.com" | ||
|
||
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module | ||
plugin_url = "https://github.com/jneilliii/OctoPrint-BedLevelVisualizer" | ||
|
||
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module | ||
plugin_license = "AGPLv3" | ||
|
||
# Any additional requirements besides OctoPrint should be listed here | ||
plugin_requires = [] | ||
|
||
### -------------------------------------------------------------------------------------------------------------------- | ||
### More advanced options that you usually shouldn't have to touch follow after this point | ||
### -------------------------------------------------------------------------------------------------------------------- | ||
|
||
# Additional package data to install for this plugin. The subfolders "templates", "static" and "translations" will | ||
# already be installed automatically if they exist. | ||
plugin_additional_data = [] | ||
|
||
# Any additional python packages you need to install with your plugin that are not contains in <plugin_package>.* | ||
plugin_addtional_packages = [] | ||
|
||
# Any python packages within <plugin_package>.* you do NOT want to install with your plugin | ||
plugin_ignored_packages = [] | ||
|
||
# Additional parameters for the call to setuptools.setup. If your plugin wants to register additional entry points, | ||
# define dependency links or other things like that, this is the place to go. Will be merged recursively with the | ||
# default setup parameters as provided by octoprint_setuptools.create_plugin_setup_parameters using | ||
# octoprint.util.dict_merge. | ||
# | ||
# Example: | ||
# plugin_requires = ["someDependency==dev"] | ||
# additional_setup_parameters = {"dependency_links": ["https://github.com/someUser/someRepo/archive/master.zip#egg=someDependency-dev"]} | ||
additional_setup_parameters = {} | ||
|
||
######################################################################################################################## | ||
|
||
from setuptools import setup | ||
|
||
try: | ||
import octoprint_setuptools | ||
except: | ||
print("Could not import OctoPrint's setuptools, are you sure you are running that under " | ||
"the same python installation that OctoPrint is installed under?") | ||
import sys | ||
sys.exit(-1) | ||
|
||
setup_parameters = octoprint_setuptools.create_plugin_setup_parameters( | ||
identifier=plugin_identifier, | ||
package=plugin_package, | ||
name=plugin_name, | ||
version=plugin_version, | ||
description=plugin_description, | ||
author=plugin_author, | ||
mail=plugin_author_email, | ||
url=plugin_url, | ||
license=plugin_license, | ||
requires=plugin_requires, | ||
additional_packages=plugin_addtional_packages, | ||
ignored_packages=plugin_ignored_packages, | ||
additional_data=plugin_additional_data | ||
) | ||
|
||
if len(additional_setup_parameters): | ||
from octoprint.util import dict_merge | ||
setup_parameters = dict_merge(setup_parameters, additional_setup_parameters) | ||
|
||
setup(**setup_parameters) |