Skip to content

Commit

Permalink
Merge pull request #33 from BarbourSmith/modified-PR/31
Browse files Browse the repository at this point in the history
Builds on #31 to make the alerts more subtle
  • Loading branch information
BarbourSmith authored May 29, 2024
2 parents 3b79435 + 411db45 commit 95e9101
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 10 deletions.
67 changes: 59 additions & 8 deletions www/js/tablet.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ function long_jog(target) {
sendCommand(cmd)
}

checkHomed = function () {

if(!maslowStatus.homed){
alert("Maslow does not know belt lengths. Please retract and extend before continuing.")

// Write to the console too in case the system alerts are not visible
let msgWindow = document.getElementById('messages')
let text = msgWindow.textContent
text = text + '\n' + "Maslow does not know belt lengths. Please retract and extend before continuing."
msgWindow.textContent = text
msgWindow.scrollTop = msgWindow.scrollHeight

}
return maslowStatus.homed
}

sendMove = function (cmd) {
tabletClick()
var jog = function (params) {
Expand Down Expand Up @@ -206,28 +222,44 @@ sendMove = function (cmd) {
move({ Z: 0 })
},
'X-Y+': function () {
jog({ X: -distance, Y: distance })
if(checkHomed()){
jog({ X: -distance, Y: distance })
}
},
'X+Y+': function () {
jog({ X: distance, Y: distance })
if(checkHomed()){
jog({ X: distance, Y: distance })
}
},
'X-Y-': function () {
jog({ X: -distance, Y: -distance })
if(checkHomed()){
jog({ X: -distance, Y: -distance })
}
},
'X+Y-': function () {
jog({ X: distance, Y: -distance })
if(checkHomed()){
jog({ X: distance, Y: -distance })
}
},
'X-': function () {
jog({ X: -distance })
if(checkHomed()){
jog({ X: -distance })
}
},
'X+': function () {
jog({ X: distance })
if(checkHomed()){
jog({ X: distance })
}
},
'Y-': function () {
jog({ Y: -distance })
if(checkHomed()){
jog({ Y: -distance })
}
},
'Y+': function () {
jog({ Y: distance })
if(checkHomed()){
jog({ Y: distance })
}
},
'Z-': function () {
jog({ Z: -distance })
Expand All @@ -246,6 +278,10 @@ sendMove = function (cmd) {

moveHome = function () {

if(!checkHomed()){
return;
}

//We want to move to the opposite of the machine's current X,Y cordinates
var x = parseFloat(id('mpos-x').innerText)
var y = parseFloat(id('mpos-y').innerText)
Expand Down Expand Up @@ -285,6 +321,9 @@ function saveSerialMessages() {
document.body.removeChild(link);
}

// from MINFO command
var maslowStatus = { homed: false, extended: false};

var loadedValues = {};
function tabletShowMessage(msg, collecting) {
if (
Expand All @@ -298,6 +337,12 @@ function tabletShowMessage(msg, collecting) {
return
}

//This keeps track of when we saw the last heartbeat from the machine
if (msg.startsWith('MINFO: ')) {
maslowStatus = JSON.parse(msg.substring(7));
return;
}

//This keeps track of when we saw the last heartbeat from the machine
if(msg.startsWith('[MSG:INFO: Heartbeat')){
lastHeartBeatTime = new Date().getTime();
Expand Down Expand Up @@ -793,6 +838,8 @@ function tabletInit() {
SendRealtimeCmd(0x3f); // ?
// print startup messages in serial
SendPrinterCommand('$SS');
// get maslow info
SendPrinterCommand('$MINFO');
tabletGetFileList('/');
requestModes();
loadConfigValues();
Expand Down Expand Up @@ -1337,6 +1384,10 @@ const onCalibrationButtonsClick = async (command, msg) => {
msgWindow.textContent = text
msgWindow.scrollTop = msgWindow.scrollHeight
}

if (command != '$MINFO') {
setTimeout(() => {sendCommand('$MINFO');}, 1000)
}
}

/* Calibration modal END */
22 changes: 21 additions & 1 deletion www/sub/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,28 @@
<span translate>FluidNC</span>
</button>
<button class="tablinks" onclick="opentab(event, 'tablettab', 'mainuitabscontent', 'mainuitablinks')" id="tablettablink">
<span>Maslow</span>
<svg width="2em" height="1.5em" viewBox="40 40 150 150">
<g id="Badge">
<path fill="currentColor" stroke="white" stroke-miterlimit="10" d="M125.458,44.447c-40.212,0-72.81,32.598-72.81,72.811
s32.598,72.811,72.81,72.811c40.213,0,72.81-32.598,72.81-72.811S165.671,44.447,125.458,44.447z M163.618,147.79
c-0.504,0.635-1.226,1.058-2.026,1.188c-9.372,1.516-16.004-0.435-19.718-5.795c-5.158-7.445-3.067-20.328,1.025-32.651
l-29.267,41.573c-0.625,0.889-1.628,1.381-2.659,1.381c-0.449,0-0.903-0.094-1.334-0.288c-1.42-0.642-2.187-2.2-1.826-3.716
l12.131-50.945L90.9,141.727c7.914,11.304,20.688,18.008,34.558,18.008c8.729,0,17.104-2.642,24.22-7.639
c1.468-1.031,3.496-0.677,4.527,0.793c1.031,1.469,0.677,3.495-0.792,4.526c-8.215,5.771-17.882,8.819-27.955,8.819
c-15.172,0-29.206-6.957-38.405-18.789l-0.51,0.76c-1.002,1.49-3.021,1.885-4.51,0.883c-1.49-1.001-1.885-3.021-0.883-4.51
l43.418-64.563c0.876-1.304,2.56-1.793,4.001-1.164c1.439,0.631,2.222,2.201,1.857,3.73l-12.37,51.95l34.64-49.206
c-7.611-6.45-17.175-9.981-27.237-9.981c-23.267,0-42.195,18.929-42.195,42.195c0,4.604,0.736,9.13,2.189,13.453
c0.572,1.701-0.344,3.544-2.045,4.115c-0.343,0.117-0.692,0.17-1.036,0.17c-1.357,0-2.624-0.856-3.08-2.215
c-1.677-4.99-2.528-10.213-2.528-15.523c0-26.851,21.845-48.695,48.695-48.695c11.418,0,22.279,3.941,30.991,11.149l0.954-1.355
c0.999-1.42,2.936-1.804,4.401-0.872c1.464,0.931,1.939,2.849,1.078,4.355c-9.684,16.942-22.5,47.497-15.664,57.361
c2.027,2.925,6.089,4.021,12.084,3.26c5.468-7.317,8.351-16.003,8.351-25.204c0-8.116-2.31-15.997-6.68-22.792
c-0.971-1.509-0.534-3.521,0.976-4.491c1.51-0.971,3.521-0.534,4.491,0.976c5.046,7.845,7.713,16.942,7.713,26.307
C174.154,128.646,170.511,139.107,163.618,147.79z" />
</g>
</svg>
<span><span id="homed">Maslow</span></span>
</button>

</div>

<ul class="nav navbar-nav navbar-right">
Expand Down
2 changes: 1 addition & 1 deletion www/sub/tablettab.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<div class="buttons-row">
<button class="calibration-modal-button" onclick="onCalibrationButtonsClick('$ALL','Retract All');">Retract All</button>
<span class="arrow">&#8594;</span>
<button class="calibration-modal-button" onclick="onCalibrationButtonsClick('$EXT','Extend All');">Extend All</button>>
<button class="calibration-modal-button" onclick="onCalibrationButtonsClick('$EXT','Extend All');">Extend All</button>
<div class="buttons-row-col-el">
<span class="arrow">&#8599;</span>
<span class="arrow">&#8600;</span>
Expand Down

0 comments on commit 95e9101

Please sign in to comment.