Skip to content

Commit

Permalink
- fixes #49
Browse files Browse the repository at this point in the history
- gbs now honors system "enable webcam support" checkbox
- further clean up of html
  • Loading branch information
synman committed Dec 26, 2021
1 parent 9816fdb commit c451f59
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 62 deletions.
2 changes: 1 addition & 1 deletion octoprint_bettergrblsupport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def saveGrblSettings(self):

self.grblSettingsText = ret
return ret


def on_settings_save(self, data):
self._logger.debug("saving settings")
Expand Down
25 changes: 18 additions & 7 deletions octoprint_bettergrblsupport/static/js/bettergrblsupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ $(function() {
var radioButtons = $('#radio_buttons');
var frameButton = $('#frame_button');
var laserButtons = $('#laser_buttons');
var webcam_div = $('#webcam_div');
var webcam_image_framing = $('#webcam_image_framing');

var container;

Expand Down Expand Up @@ -252,15 +254,19 @@ $(function() {
break;
}
}

if (self.settings.settings.webcam.webcamEnabled()) {
document.getElementById("webcam_image_framing").src = self.settings.settings.webcam.streamUrl() + "&nonce=" + Math.floor(Math.random() * 1000000);
}
};

self.onTabChange = function (current, previous) {
var streamImg = document.getElementById("webcam_image_framing");

if (current == "#tab_plugin_bettergrblsupport") {
streamImg.src = self.settings.settings.webcam.streamUrl() + "&nonce=" + Math.floor(Math.random() * 1000000);
} else if (previous == "#tab_plugin_bettergrblsupport") {
streamImg.src = "about:blank";
if (self.settings.settings.webcam.webcamEnabled()) {
if (current == "#tab_plugin_bettergrblsupport") {
document.getElementById("webcam_image_framing").src = self.settings.settings.webcam.streamUrl() + "&nonce=" + Math.floor(Math.random() * 1000000);
} else if (previous == "#tab_plugin_bettergrblsupport") {
document.getElementById("webcam_image_framing").src = "about:blank";
}
}
};

Expand Down Expand Up @@ -400,7 +406,6 @@ $(function() {

self.fsClick = function () {
// console.log("fsClick");
var streamImg = document.getElementById("webcam_image_framing");

$body.toggleClass('inlineFullscreen');
$container.toggleClass("inline fullscreen");
Expand Down Expand Up @@ -439,6 +444,12 @@ $(function() {

self.onWebcamFrameErrored = function() {
// alert("webcam frame error");
webcam_div.hide();
webcam_image_framing.src = self.settings.settings.webcam.streamUrl() + "&nonce=" + Math.floor(Math.random() * 1000000);
}
self.onWebcamFrameLoaded= function() {
// alert("webcam frame error");
webcam_div.show();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ $(function() {

self.onBeforeBinding = function() {
// initialize stuff here
self.pushGrblSettings(self.settings.settings.plugins.bettergrblsupport.grblSettingsText());
var settingsText = self.settings.settings.plugins.bettergrblsupport.grblSettingsText();
if (settingsText != null) {
self.pushGrblSettings(settingsText);
}
};

self.pushGrblSettings = function(grblSettingsText) {
Expand Down
96 changes: 44 additions & 52 deletions octoprint_bettergrblsupport/templates/bettergrblsupport_tab.jinja2
Original file line number Diff line number Diff line change
@@ -1,61 +1,54 @@
<!-- <div class="webcam_fixed_ratio_inner" style="padding: 10px 0px 0px 0px;">
<img id="webcam_image_framing" data-bind="css: { flipH: settings.webcam_flipH(), flipV: settings.webcam_flipV() }" class="flipH flipV" src="/webcam/?action=stream">
</div> -->
<!-- ko if: settings.settings.webcam.webcamEnabled -->
<hr>
<div id="webcam_container_framing">
<div id="webcam_rotator_framing" data-bind="css: { webcam_rotated: settings.webcam_rotate90(), webcam_unrotated: !settings.webcam_rotate90() }">
<div class="webcam_fixed_ratio" data-bind="css: webcamFrameRatioClass">
<div class="webcam_fixed_ratio_inner">
<img id="webcam_image_framing" data-bind="click: function() { fsClick() }, css: { flipH: settings.webcam_flipH(), flipV: settings.webcam_flipV() }, event: { error: onWebcamFrameErrored }">
<div id="webcam_div" class="webcam_fixed_ratio_inner">
<img id="webcam_image_framing" data-bind="click: function() { fsClick() }, css: { flipH: settings.webcam_flipH(), flipV: settings.webcam_flipV() }, event: { load: onWebcamFrameLoaded, error: onWebcamFrameErrored }">
</div>
</div>
</div>
</div>

<hr>
<h5>&nbsp;Control</h5>
<!-- /ko -->

<div style="text-align: center; overflow: hidden">
<span with="200px" style="padding: 20px 40px 40px 20px; display: inline-block;">
<table border=1 style="border-spacing: 1px; border: 1px; border-radius: 5px;">
<tr>
<td>
<table border=0>
<tr>
<td style="padding: 5px 10px 0px 5px;" align="right" valign="middle">Mode</td>
<td style="padding: 5px 5px 0px 5px;" align="right" valign="middle" width="40px"><strong data-bind="text: mode()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">State</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle" width="40px"><strong data-bind="text: state()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">X</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: xPos()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">Y</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: yPos()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">Z</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: zPos()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">Power</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: power()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 5px 5px;" align="right" valign="middle">Speed</td>
<td style="padding: 3px 5px 5px 5px;" align="right" valign="middle"><strong data-bind="text: speed()"></strong></td>
</tr>
</table>
</td>
</tr>
<div style="text-align: center; overflow: hidden" valign="top" align="center">
<span style="display: inline-block; border: 1px solid; border-radius: 10px; margin: 0px 60px 20px 0px;" ">
<table align="center" style="margin: 0 auto;">
<tr>
<td style="padding: 5px 10px 0px 5px;" align="right" valign="middle">Mode</td>
<td style="padding: 5px 5px 0px 5px;" align="right" valign="middle" width="60px"><strong data-bind="text: mode()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">State</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: state()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">X</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: xPos()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">Y</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: yPos()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">Z</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: zPos()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 0px 5px;" align="right" valign="middle">Power</td>
<td style="padding: 3px 5px 0px 5px;" align="right" valign="middle"><strong data-bind="text: power()"></strong></td>
</tr>
<tr>
<td style="padding: 3px 10px 5px 5px;" align="right" valign="middle">Speed</td>
<td style="padding: 3px 5px 5px 5px;" align="right" valign="middle"><strong data-bind="text: speed()"></strong></td>
</tr>
</table>
</span>
<span width="400px" style="padding: 0px 40px 40px 40px; display: inline-block;">
<table class="jog-panel" id="jog_panel" border=0>
<span style="display: inline-block; margin: 0px 60px 20px 0px;">
<table class="jog-panel" id="jog_panel" border=0 style="margin: 0 auto;"">
<tr>
<td style="padding: 0px 55px 0px 0px;" align="center">
<h5>Z</h5>
Expand Down Expand Up @@ -132,12 +125,11 @@
</table>
</span>

<span id="laser_buttons" valign="middle" style="padding: 0px 20px 0px 40px; display: inline-block;" >
<!-- <td id="laser_buttons" align="right" valign="middle" width="25%" style="padding: 0px 20px 0px 0px;" > -->
<span id="laser_buttons" valign="top" style="margin: 0px 0px 40px 0px; display: inline-block;" >
<!-- ko if: settings.settings.plugins.bettergrblsupport.laserMode -->
<button id="grblLaserButton" style="width: 130px" class="btn" data-bind="enable: is_operational() && !is_printing() && state() == 'Idle', click: function() { toggleWeak() }">Weak Laser</button>
<br>
<br>
<button id="grblLaserButton" style="width: 130px" class="btn" data-bind="enable: is_operational() && !is_printing() && state() == 'Idle', click: function() { toggleWeak() }">Weak Laser</button>
<br>
<br>
<!-- /ko -->
<button style="width: 130px" class="btn" data-bind="enable: is_operational() && !is_printing() && (state() == 'Idle' || state() == 'Alarm'), click: function() { sendCommand('homing') }">Machine Home</button>
<br>
Expand Down Expand Up @@ -183,7 +175,7 @@
</table>
</span>

<span style="padding: 0px 30px 20px 30px; display: inline-block;">
<span id="framingPanel" style="padding: 0px 30px 20px 30px; display: inline-block;">
<table width="200px" border=0 cellpadding=0>
<tr>
<td align="center" valign="bottom" style="padding: 10px 0px 0px 0px;">
Expand Down Expand Up @@ -220,7 +212,7 @@
</table>
</span>

<span style="padding: 0px 20px 10px 30px; display: inline-block;" >
<span id="frame_button" style="padding: 0px 20px 10px 30px; display: inline-block;" >
<table width="130px" height="68px" border=0>
<tr>
<td valign="top" align="center">
Expand Down
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 = "Better Grbl Support"

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

# 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 c451f59

Please sign in to comment.