Add ability to use only custom start and end gcode

Patreon request!
This commit is contained in:
teachingtechYT
2021-07-30 19:56:57 +10:00
parent 7401874c91
commit 5a8caf5e12
2 changed files with 24 additions and 11 deletions

View File

@ -65,6 +65,8 @@ var startGcode = /*html*/ `<h4>Additional start gcode</h4>
<li><b>Custom ABL</b> sequence. By default, only G28 is present. This gcode will be inserted immediately afer that so custom commands can be used here.Useful for G34 auto stepper alignment and Klipper's Z_TILT_ADJUST.</li>
<li>Anything else you have in your start gcode, such as setting acceleration values, E-steps, etc.</li>
</ul>
<label>Strip <b>ALL</b> original start gcode and use only custom gcode instead: <input name="customStartOnly" type="checkbox"></label>
<p class="warning">This option will remove all start gcode except what is entered in the box below. This means you are responsible for providing commands to home the machine and heat the bed/nozzle. Advanced users only!</p>
<textarea name="startgcode"></textarea>
</div>`;
@ -317,6 +319,8 @@ var endGcode = /*html*/ `<h4>Additional end gcode</h4>
<label>Home all axes with G28 at the end (delta)<input name="deltaHome" type="checkbox" value="off"></label>
<div class="endExp">
<p>For the majority of users, you can skip this section. Any gcode entered here will be inserted at the very end of the file.</p>
<label>Strip <b>ALL</b> original end gcode and use only custom gcode instead: <input name="customEndOnly" type="checkbox"></label>
<p class="warning">This option will remove all end gcode except what is entered in the box below. This means you are responsible for providing commands to shut down all heaters, fans, motors, etc. Advanced users only!</p>
<textarea name="endgcode"></textarea>
</div>`;

View File

@ -261,29 +261,34 @@ function processGcode(formName) {
var feedMod = feed/3600;
}
// process start gcode
var gcode;
if((formName.start.checked == true) && (formName.customStartOnly.checked == true)){
gcode = ";customstart";
} else {
gcode = commonStart;
}
// bed temp
var gcode = commonStart;
if(bedTemp == 0){
gcode = gcode.replace(/;bed0a/g, "; no heated bed");
gcode = gcode.replace(/;bed0b/g, "; no heated bed");
gcode = gcode.replace(/;bed0a/g, "; no heated bed");
gcode = gcode.replace(/;bed0b/g, "; no heated bed");
} else {
gcode = gcode.replace(/;bed0a/g, "M140 S"+bedTemp+" ; custom bed temp");
gcode = gcode.replace(/;bed0b/g, "M190 S"+bedTemp+" ; custom bed temp");
}
// start hot end emp
if(abl != 4){
gcode = gcode.replace(/;temp0a/g, "M104 S"+hotendTemp+" T0 ; custom hot end temp");
gcode = gcode.replace(/;temp0b/g, "M109 S"+hotendTemp+" T0 ; custom hot end temp");
gcode = gcode.replace(/;temp0a/g, "M104 S"+hotendTemp+" T0 ; custom hot end temp");
gcode = gcode.replace(/;temp0b/g, "M109 S"+hotendTemp+" T0 ; custom hot end temp");
} else {
gcode = gcode.replace(/;temp0a/g, "; Prusa Mini");
gcode = gcode.replace(/;temp0b\n/g, "");
}
}
// abl
if(abl == 1){
gcode = gcode.replace(/;G29 ; probe ABL/, "G29 ; probe ABL");
gcode = gcode.replace(/;G29 ; probe ABL/, "G29 ; probe ABL");
}
if(abl == 2){
gcode = gcode.replace(/;M420 S1 ; restore ABL mesh/, "M420 S1 ; restore ABL mesh");
gcode = gcode.replace(/;M420 S1 ; restore ABL mesh/, "M420 S1 ; restore ABL mesh");
}
if(abl == 3){
gcode = gcode.replace(/G28 ; home all axes/, "G28 W ; home all without mesh bed level");
@ -292,7 +297,6 @@ function processGcode(formName) {
if(abl == 4){
gcode = gcode.replace(/G28 ; home all axes/, "M109 S170 T0 ; probing temperature\nG28 ; home all");
gcode = gcode.replace(/;G29 ; probe ABL/, "G29 ; probe ABL");
gcode = gcode.replace(/;M420 S1 ; restore ABL mesh/, "M109 S"+hotendTemp+" T0 ; custom hot end temp");
}
if(abl == 5){
@ -304,6 +308,7 @@ function processGcode(formName) {
if(abl == 7){
gcode = gcode.replace(/;G29 ; probe ABL/, "G29 L2 ; Load the mesh stored in slot 1\nG29 J ; Probe 3 points to tilt mesh");
}
// firstlayer test square array
if(name == "firstlayerForm"){
var originalSquare = firstlayer[nozzleLayer];
@ -348,8 +353,12 @@ function processGcode(formName) {
if(name == "accelerationForm"){
gcode += acceleration[nozzleLayer];
}
// add end common gcode
gcode += commonEnd;
// add end gcode
if((formName.customEndOnly.checked == true) && (formName.end.checked == true)){
gcode += ";customend\n";
} else {
gcode += commonEnd;
}
if(name != "firstlayerForm"){
// strip original fan command
gcode = gcode.replace(/M106 S3/, ";");