User Tools

Site Tools


Sidebar


User's Manual & Quick Start Guide

Specifications

Where to Purchase

Donations & Support

Replacements Parts & Information

Mods & Improvements

How-to

OctoPrint

Slicer Stuff

Troubleshooting

Maintenance

WiFi

Web UI

Firmware

Downloads

Donations & Support



Looking for the Monoprice MP Mini Delta Wiki?

communications

This is an old revision of the document!


Sample code for web interface

Send GCODE M565 to start print file cache.gc

function start_p(){
	$.ajax({
		url: "set?code=M565",
		cache: false
	}).done(function(html) {
	});
}


Get printing status

$.get("inquiry",function(data,status){
	$("#rde").text(data.match(/\d+/g)[0]);
	$("#rdp").text(data.match(/\d+/g)[2]);
	var c=data.charAt(data.length-1);
	if (c=='I')
	{
		$("#stat").text("Status: Idle");
		$("#pgs").css("width","0%");
	}
	else if (c=='P')
	{
		$("#stat").text("Status: Printing");
		$("#pgs").css("width",data.match(/\d+/g)[4]+"%");
	}
	else $("#stat").text("Status: ");
});


Send Control command {P:X} to cancel print

function cancel_p(){
    $.ajax({
		url: "set?cmd={P:X}",
		cache: false
	}).done(function(html) {
	});
}


Set extruder temperature

function pad(num, size) {
    var s = "000" + num;
    return s.substr(s.length-size);
}

var value=pad($("#wre").val(),3);
$.ajax({
	url: 'set?cmd={C:T0'+value+'}',
	cache: false
}).done(function(html) {
});


Stop preheat heat bed

$("#clrp").click(function(){
	$.ajax({
		url: "set?cmd={C:P000}",
		cache: false
	}).done(function(html) {
	});
});


Set printing speed

1X Speed: {C:S10}
1.5X Speed: {C:S15}
5X Max


REST

Using AJAX and REST a single line of code g-code can be sent without socket connection:

http://IP_ADDRESS/set?code=G28


Send gcode though websocket interface

<script>
var ws = new WebSocket('ws://192.168.20.164:81');
ws.onopen = function () {
  ws.send("G28");
}
</script>


Testing web page for Web socket

Note: This html file can be saved to your computer and opened directly from your browser.

websocket test





Message
communications.1486072822.txt.gz · Last modified: 2017/02/02 22:00 (external edit)