Skip to content

Commit

Permalink
Alpha v0.9.1
Browse files Browse the repository at this point in the history
Turns out Web Sockets isn’t that great for sending GCode. Now GCode is
sent via the REST API and the printer response is displayed via Web
Sockets.

Relative Position will be only resent when needed. ie after a home
request or after page reload.

Better print/cancel button status.
  • Loading branch information
joeycortez42 committed Feb 23, 2018
1 parent d2bfcdd commit 4a06f0d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 42 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

Upgrade the Malyan M200 or the Monoprice Select Mini's V1 Web UI and enable faster Wi-Fi file uploads automatically. For V2, download the [V2 branch](https://github.com/nokemono42/MP-Select-Mini-Web/tree/v2).

Note: Requires UI Controller firmware version 42 or greater to enable the custom Web UI. This has not been tested on anything lower then firmware version 42.
Note: Requires UI Controller firmware version 42 or greater to enable a custom Web UI.

![Image of printer LCD](https://mpselectmini.com/_detail/firmware_version_explanation.png)
![Image of printer LCD](https://mpselectmini.com/_media/firmware_version_explanation.png?cache= =333x250)

This Web UI is built using Bootstrap so its mobile-friendly and tablet-friendly. Multiple browser connections are supported. GCode commands are sent via Web Sockets so all browser windows will display the printer responses.
This Web UI is built using Bootstrap so its mobile-friendly and tablet-friendly. Multiple browser connections are supported. GCode responses are sent via Web Sockets so all browser windows will display the printer responses. GCode commands are sent via the REST API since sending via Web Sockets proved to be unreliable.

![Image of the WebUI](https://raw.githubusercontent.com/nokemono42/MP-Select-Mini-Web/master/screenshot.png)

Expand Down Expand Up @@ -36,9 +36,9 @@ M563 parameters can be values between S2 - S6. Transfers happen over telnet whic
| M563 S# | Avg Transfer Speed | Supported On |
| ------- | -----------------: | ------------------------ |
| S2 | 39 Kbps | Same as Firmware Default |
| S3 | 63 Kbps | All |
| S4 | 90 Kbps | All |
| S5 | 102 Kbps | V2 / Delta |
| S3 | 63 Kbps | V1 / V2 / Delta |
| S4 | 91 Kbps | V1 / V2 / Delta |
| S5 | 103 Kbps | V2 |
| S6 | 112 Kbps | V1 |


Expand Down Expand Up @@ -71,12 +71,13 @@ Mario Anthony Galliano (Facebook Group posting with upgrade/downgrade instructio

## Upcoming Improvements

* Test on MPSM V2
* Test on MP Select Mini V2
* Create V2 Branch
* Create Delta Mini repo
* Change multiplier
* Show time lasped / time remaining
* Show filename that is printing
* Rename cache.gc file with M566 after upload
* Rename cache.gc file with M566 after upload (Pending more SD functions)
* Query SD card for list of files M20
* Delete file from SD card M30
* Print file from SD card M24
* Pause print M25
* Start printer state. If inquiry not able to load, reset page bool values. (Same as page refresh)
67 changes: 41 additions & 26 deletions source/webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ URL: https://github.com/nokemono42/MP-Select-Mini-Web

$(document).ready(function() {
printerStatus();
startup();
initWebSocket();

setTimeout(function() {
startup();
}, 2000);

setInterval(function() {
printerStatus();
Expand All @@ -23,6 +27,7 @@ $(document).ready(function() {
}

sendCmd(code, 'Home ' + comment);
setPositioning = false;
});

$(".movement .direction button").click(function() {
Expand All @@ -32,17 +37,22 @@ $(document).ready(function() {
axis = $(this).attr("data-axis");
comment = 'Move ' + axis;

if (setPositioning == false) {
sendCmd('G91', 'Set to Relative Positioning');
setPositioning = true;
}

if (movement == 'up' || movement == 'left') { rate = rate * -1; }
if (axis == 'Z' && movement == 'down') { comment = 'Raise Z '; }
if (axis == 'Z' && movement == 'up') { comment = 'Lower Z '; }
if (axis == 'E' && movement == 'plus') { comment = 'Extrude '; }
if (axis == 'E' && movement == 'minus') {
sendCmd(command + axis + '-' + rate, 'Retract ' + rate + 'mm');
return false;
return;
}
if (movement == 'disable') {
sendCmd('M18', 'Disable motor lock');
return false;
return;
}

sendCmd(command + axis + rate, comment + ' ' + rate + 'mm');
Expand Down Expand Up @@ -108,6 +118,7 @@ $(document).ready(function() {
});

var timers = {};
var setPositioning = false;

function pad(num, size) {
s = '000' + num;
Expand All @@ -120,10 +131,20 @@ function scrollConsole() {
}

function feedback(output) {
msg = output.replace(/N0 P15 B15/g, '');
msg = msg.replace(/N0 P14 B15/g, '');
msg = msg.replace(/echo:/g, '');
$("#gCodeLog").append('<p class="text-warning">' + msg + '</p>');
if (output.substring(0, 2) == 'T:') {
//Hide temperature reporting
return;
}

if (output.substring(0, 5) == 'ok N0') {
output = 'ok';
}

$("#gCodeLog").append('<p class="text-warning">' + output + '</p>');

//if (output.substring(0, 5) == 'Begin') {
//$(".sd-files").html('<p>' + output + '</p>');
//}
scrollConsole();
}

Expand All @@ -132,13 +153,8 @@ function sendCmd(code, comment, type) {

$("#gCodeLog").append('<p class="text-primary">' + code + ' <span class="text-muted">; ' + comment + '</span></p>');

if (type == 'cmd') {
$.ajax({ url: 'set?' + type + '=' + code, cache: false }).done(function(data) {
feedback(data);
});
} else {
ws.send(code);
}
$.ajax({ url: 'set?' + type + '=' + code, cache: false }).done();
//ws.send(code);

scrollConsole();
}
Expand All @@ -149,7 +165,7 @@ function initWebSocket() {
try {
ws = new WebSocket('ws://' + url + ':81');
ws.onopen = function() {
feedback('Connected');
feedback('Connection Established');
};
ws.onmessage = function(a) {
feedback(a.data);
Expand Down Expand Up @@ -183,7 +199,7 @@ Dropzone.options.mydz = {
accept: function(file, done) {
if (file.name.contains('.g')) {
//window.startTimer = new Date();

done();
$(".print-actions button").addClass('btn-disable');
$(".movement button").addClass('btn-disable');
Expand Down Expand Up @@ -214,7 +230,10 @@ Dropzone.options.mydz = {
$(".movement button").removeClass('btn-disable');
$("#gCodeSend").removeClass('btn-disable');
$(".temperature button").removeClass('btn-disable');
sendCmd('M566 ' + file.name, '');

//setTimeout(function() {
//sendCmd('M566 ' + file.name, '');
//}, 1000);
});
}
};
Expand Down Expand Up @@ -245,12 +264,14 @@ function printerStatus() {
if (c == 'I') {
$("#stat").text('Idle');
$("#pgs").css('width', '0%');
$("#start_print").removeClass('btn-disable');
$(".movement button").removeClass('btn-disable');
$("#gCodeSend").removeClass('btn-disable');
} else if (c == 'P') {
$("#stat").text('Printing');
$("#pgs").css('width', data.match(/\d+/g )[4] + '%');
$("#pgs").html(data.match(/\d+/g )[4] + '% Complete');
$("#start_print").addClass('btn-disable');
$(".movement button").addClass('btn-disable');
$("#gCodeSend").addClass('btn-disable');
} else {
Expand All @@ -260,15 +281,8 @@ function printerStatus() {
}

function startup() {
initWebSocket();

if ($("#stat").text() != 'Printing') {
setTimeout(function() {
sendCmd('M563 S4', 'Enable faster Wi-Fi file uploads');
sendCmd('G91', 'Set to Relative Positioning');
}, 1750);
} else {
alert('Printing');
sendCmd('M563 S6', 'Enable faster Wi-Fi file uploads');
}
}

Expand Down Expand Up @@ -304,5 +318,6 @@ function delaySyncTemperatures(extruder, platform) {
}

function refreshSD() {
sendCmd('M563 S3', 'Enable faster Wi-Fi file uploads');
sendCmd('M21', 'Initialize SD card');
sendCmd('M20', 'List SD card files');
}
2 changes: 1 addition & 1 deletion source/webui.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4a06f0d

Please sign in to comment.