Skip to content

Commit

Permalink
Merge pull request #40 from BarbourSmith/Add-a-time-lock-on-setting-home
Browse files Browse the repository at this point in the history
Add a time lock on setting home button
  • Loading branch information
BarbourSmith authored Jul 9, 2024
2 parents 9dbaade + 1987702 commit ebd44b6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions www/js/tablet.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,39 @@ inputBlurred = function () {
isInputFocused = false
}

//Timer function counting down from 5
var timeoutID = null
var timer = function () {
var buttonText = document.getElementById('defineHomeBTN').textContent
if (buttonText > 0) {
document.getElementById('defineHomeBTN').textContent = buttonText - 1
timeoutID = setTimeout(timer, 1000)
}
else {
zeroAxis('X')
zeroAxis('Y')
document.getElementById('defineHomeBTN').textContent = 'Define Home'
setTimeout(refreshGcode, 100)
}
}

//Click down starts the timer function and sets the button text to 5
setHomeClickDown = function () {
document.getElementById('defineHomeBTN').textContent = 5
timer()
}

//Click up stops the timer function and sets the button text to 'Define Home'
setHomeClickUp = function () {
document.getElementById('defineHomeBTN').textContent = 'Define Home';

//Cancel the timer
if (timeoutID != null) {
clearTimeout(timeoutID)
}

}

zeroAxis = function (axis) {
tabletClick()
setAxisByValue(axis, 0)
Expand Down
4 changes: 2 additions & 2 deletions www/sub/tablettab.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<div class="maslow-grid-item maslow-grid-item-btn" style="background-color: #f2f0e4;" id="disM">100</div>
<div class="maslow-grid-item maslow-grid-item-btn" style="background-color: #f2f0e4;" id="units" title="Toggle Units"
onclick="toggleUnits()">mm</div>
<div class="maslow-grid-item maslow-grid-item-btn" style="background-color: #f2f0e4;"
onmousedown="zeroAxis('X');zeroAxis('Y');" onmouseup="refreshGcode();">Define Home</div>
<div class="maslow-grid-item maslow-grid-item-btn" id="defineHomeBTN" style="background-color: #f2f0e4;"
onmousedown="setHomeClickDown();" onmouseup="setHomeClickUp();">Define Home</div>
</div>
<div class="maslow-grid-container tablettab-controls-item" style="height: 60px;">
<select class="form-control" id="filelist" onchange="selectFile()">
Expand Down

0 comments on commit ebd44b6

Please sign in to comment.