User Tools

Site Tools


sample_code_for_web_interface

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sample_code_for_web_interface [2016/09/01 13:32]
admin
sample_code_for_web_interface [2019/03/20 04:21] (current)
Line 1: Line 1:
  
 +More API will be add soon. 
 +
 +
 +Send GCODE M565 to start print file cache.gc
 +<​code>​
 +function start_p(){
 + $.ajax({
 + url: "​set?​code=M565",​
 + cache: false
 + }).done(function(html) {
 + });
 +}
 +</​code>​
 +
 +Send GCODE M566 to rename file cache.gc
 +<​code>​
 +M566 newfilename.gc
 +</​code>​
 +
 +Get printing status
 +<​code>​
 +$.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:​ ");
 +});
 +</​code>​
 +
 +Send Control command {P:X} to cancel print
 +<​code>​
 +function cancel_p(){
 +    $.ajax({
 + url: "​set?​cmd={P:​X}",​
 + cache: false
 + }).done(function(html) {
 + });
 +}
 +</​code>​
 +
 +
 +Set extruder temperature
 +<​code>​
 +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) {
 +});
 +</​code>​
 +
 +
 +Stop preheat heat bed
 +<​code>​
 +$("#​clrp"​).click(function(){
 + $.ajax({
 + url: "​set?​cmd={C:​P000}",​
 + cache: false
 + }).done(function(html) {
 + });
 +});
 +</​code>​
 +
 +Set printing speed: ​
 +<​code>​
 +1X Speed: {C:S10}
 +1.5X Speed: {C:S15}
 +5X Max
 +</​code>​
 +
 +Enable fast mode for web uploading: ​
 +<​code>​
 +GCode: S value can be 2~6
 +M563 S6
 +</​code>​
 +
 +Send gcode though websocket interface: ​
 +<​code>​
 +<​script>​
 +var ws = new WebSocket('​ws://​192.168.43.50:​81'​);​
 +ws.onopen = function () {
 +  ws.send("​G28"​);​
 +}
 +</​script>​
 +</​code>​
 +
 +High speed web downloading:​
 +
 +<​code>​
 +M563 S6
 +</​code>​
sample_code_for_web_interface.txt ยท Last modified: 2019/03/20 04:21 (external edit)