Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables/disables directional buttons and play/pause based on the gcode uploader #170

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions static/scripts/frontpageControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,27 @@ function moveAction(direction) {

function processStatusMessage(data){
//console.log(data)
if (data.uploadFlag){
if (!isDisabled){
if (data.uploadFlag==1){
if (isDisabled!=data.uploadFlag){
$('.disabler').prop('disabled', true);
isDisabled = true;
$('.ndisabler').prop('disabled', false);
$('.gcdisabler').prop('disabled', true);
isDisabled =data.uploadFlag;
}
} else {
if (isDisabled){
} else if (data.uploadFlag==2 || data.uploadFlag==-1 ){
if (isDisabled!=data.uploadFlag){
$('.gcdisabler').prop('disabled', true);
$('.disabler').prop('disabled', false);
isDisabled = false;
$('.ndisabler').prop('disabled', false);
isDisabled = data.uploadFlag;
}
}
else {
if (isDisabled!=data.uploadFlag){
$('.disabler').prop('disabled', false);
$('.ndisabler').prop('disabled', true);
$('.gcdisabler').prop('disabled', false);
isDisabled = data.uploadFlag;
}
}
$("#currentTool").text(data.currentTool.toString());
Expand Down
32 changes: 16 additions & 16 deletions templates/frontpage3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,44 @@
<div class="flex-fixed-width-item"><!--"col my-sidebar">-->
<h3>Controls</h3>
<div>
<div class="controls row">
<div class="controls row" ><!-- This block needs to be disabled while code running. -->
<div class="col-3 mb-1">
<button type="button" class="btn btn-secondary btn-block disabler" onclick="moveAction('upLeft')"><i data-feather="arrow-up-left"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-dark btn-block" onclick="moveAction('up')"><i data-feather="arrow-up"></i></button>
<button type="button" class="btn btn-dark btn-block disabler" onclick="moveAction('up')"><i data-feather="arrow-up"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-secondary btn-block" onclick="moveAction('upRight')"><i data-feather="arrow-up-right"></i></button>
<button type="button" class="btn btn-secondary btn-block disabler" onclick="moveAction('upRight')"><i data-feather="arrow-up-right"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-primary btn-block" onclick="action('macro1')">{{ macro1_title }}</button>
<button type="button" class="btn btn-primary btn-block disabler" onclick="action('macro1')">{{ macro1_title }}</button>
</div>
<div class="w-100"></div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-dark btn-block" onclick="moveAction('left')"><i data-feather="arrow-left"></i></button>
<button type="button" class="btn btn-dark btn-block disabler" onclick="moveAction('left')"><i data-feather="arrow-left"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-dark btn-block" onclick="action('home')"><i data-feather="home"></i></button>
<button type="button" class="btn btn-dark btn-block disabler" onclick="action('home')"><i data-feather="home"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-dark btn-block" onclick="moveAction('right')"><i data-feather="arrow-right"></i></button>
<button type="button" class="btn btn-dark btn-block disabler" onclick="moveAction('right')"><i data-feather="arrow-right"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-primary btn-block" onclick="action('macro2')">{{ macro2_title }}</button>
<button type="button" class="btn btn-primary btn-block disabler" onclick="action('macro2')">{{ macro2_title }}</button>
</div>
<div class="w-100"></div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-secondary btn-block" onclick="moveAction('downLeft')"><i data-feather="arrow-down-left"></i></button>
<button type="button" class="btn btn-secondary btn-block disabler" onclick="moveAction('downLeft')"><i data-feather="arrow-down-left"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-dark btn-block" onclick="moveAction('down')"><i data-feather="arrow-down"></i></button>
<button type="button" class="btn btn-dark btn-block disabler" onclick="moveAction('down')"><i data-feather="arrow-down"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-secondary btn-block" onclick="moveAction('downRight')"><i data-feather="arrow-down-right"></i></button>
<button type="button" class="btn btn-secondary btn-block disabler" onclick="moveAction('downRight')"><i data-feather="arrow-down-right"></i></button>
</div>
<div class="col-3 mb-1">
<button type="button" class="btn btn-primary btn-block" onclick="requestPage('zAxis');">ZAxis</button>
<button type="button" class="btn btn-primary btn-block disabler" onclick="requestPage('zAxis');">ZAxis</button>
</div>
<div class="w-100"></div>
<div class="col-3 mb-1">
Expand All @@ -71,10 +71,10 @@ <h3>Controls</h3>
<form id="distInput" onsubmit="return false;"><input class="form-control" type="text" pattern="^[0-9]*(\.[0-9]{0,3})?$" id="distToMove" title="Positive number with maximum 3 decimal places"></form>
</div>
<div class="col-3 mb-1">
<button id="units" type="button" class="btn btn-secondary" onclick="unitSwitch();">--</button>
<button id="units" type="button" class="btn btn-secondary disabler" onclick="unitSwitch();">--</button>
</div>
<div class="col-3 mb-1">
<button id="btnDefHome" type="button" class="btn btn-primary btn-block" onclick="action('defineHome')" ><i data-feather="save">Def.</i> <i data-feather="home">Home</i></button>
<button id="btnDefHome" type="button" class="btn btn-primary btn-block disabler" onclick="action('defineHome')" ><i data-feather="save">Def.</i> <i data-feather="home">Home</i></button>
</div>
</div>
<div class="row">
Expand All @@ -84,10 +84,10 @@ <h3>Controls</h3>
</div>
<div class="row">
<div class="col mb-1">
<button type="button" class="btn btn-block btn-success" onclick="action('startRun')">Play</button>
<button type="button" class="btn btn-block btn-success gcdisabler" onclick="action('startRun')">Play</button>
</div>
<div class="col mb-1">
<button type="button" id="pauseButton" class="btn btn-block btn-warning" onclick="pauseRun()">Pause</button>
<button type="button" id="pauseButton" class="btn btn-block btn-warning ndisabler" onclick="pauseRun()">Pause</button>
</div>
<div class="col mb-1">
<button type="button" id="stopButton" class="btn btn-block btn-danger" onclick="$(this).removeClass('stopbutton'); action('stopRun')">Stop</button>
Expand Down
28 changes: 14 additions & 14 deletions templates/frontpage3d_mobilecontrols.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,51 @@
<h3>Controls</h3>
<div class="row">
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-secondary btn-block" onclick="action('move','upLeft',$('#distToMove').val())">
<button type="button" class="btn btn-lg btn-secondary btn-block disabler" onclick="action('move','upLeft',$('#distToMove').val())">
<i data-feather="arrow-up-left"></i>
</button>
</div>
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-dark btn-block" onclick="action('move','up',$('#distToMove').val())";>
<button type="button" class="btn btn-lg btn-dark btn-block disabler" onclick="action('move','up',$('#distToMove').val())";>
<i data-feather="arrow-up"></i>
</button>
</div>
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-secondary btn-block" onclick="action('move','upRight',$('#distToMove').val())">
<button type="button" class="btn btn-lg btn-secondary btn-block disabler" onclick="action('move','upRight',$('#distToMove').val())">
<i data-feather="arrow-up-right"></i>
</button>
</div>
</div>
<div class="row">
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-dark btn-block" onclick="action('move','left',$('#distToMove').val())">
<button type="button" class="btn btn-lg btn-dark btn-block disabler" onclick="action('move','left',$('#distToMove').val())">
<i data-feather="arrow-left"></i>
</button>
</div>
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-dark btn-block" onclick="action('home')">
<button type="button" class="btn btn-lg btn-dark btn-block disabler" onclick="action('home')">
<i data-feather="home"></i>
</button>
</div>
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-dark btn-block" onclick="action('move','right',$('#distToMove').val())">
<button type="button" class="btn btn-lg btn-dark btn-block disabler" onclick="action('move','right',$('#distToMove').val())">
<i data-feather="arrow-right"></i>
</button>
</div>
</div>
<div class="row">
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-secondary btn-block" onclick="action('move','downLeft',$('#distToMove').val())">
<button type="button" class="btn btn-lg btn-secondary btn-block disabler" onclick="action('move','downLeft',$('#distToMove').val())">
<i data-feather="arrow-down-left"></i>
</button>
</div>
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-dark btn-block" onclick="action('move','down',$('#distToMove').val())">
<button type="button" class="btn btn-lg btn-dark btn-block disabler" onclick="action('move','down',$('#distToMove').val())">
<i data-feather="arrow-down"></i>
</button>
</div>
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-secondary btn-block" onclick="action('move','downRight',$('#distToMove').val())">
<button type="button" class="btn btn-lg btn-secondary btn-block disabler" onclick="action('move','downRight',$('#distToMove').val())">
<i data-feather="arrow-down-right"></i>
</button>
</div>
Expand All @@ -73,12 +73,12 @@ <h3>Controls</h3>
<button type="button" class="btn btn-lg btn-primary btn-block" onclick="action('macro2')" >{{ macro2_title }}</button>
</div>
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-primary btn-block" onclick="requestPage('zAxis');">ZAxis</button>
<button type="button" class="btn btn-lg btn-primary btn-block disabler" onclick="requestPage('zAxis');">ZAxis</button>
</div>
</div>
<div class="row">
<div class="col-5 mb-1">
<button type="button" class="btn btn-lg btn-primary btn-block" onclick="action('defineHome')" >Def. Home</button>
<button type="button" class="btn btn-lg btn-primary btn-block disabler" onclick="action('defineHome')" >Def. Home</button>
</div>
</div>
<div class="row">
Expand All @@ -89,7 +89,7 @@ <h3>Controls</h3>
<input class="form-control" type="number" id="distToMove" value="0.01">
</div>
<div class="col-4 mb-1">
<button id="units" type="button" class="btn btn-lg btn-secondary" onclick="unitSwitch();">--</button>
<button id="units" type="button" class="btn btn-lg btn-secondary disabler" onclick="unitSwitch();">--</button>
</div>
</div>
<div class="row">
Expand All @@ -100,10 +100,10 @@ <h3>Controls</h3>

<div class="row">
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-block btn-success" onclick="action('startRun')">Play</button>
<button type="button" class="btn btn-lg btn-block btn-success gcdisabler" onclick="action('startRun')">Play</button>
</div>
<div class="col-4 mb-1">
<button type="button" id="pauseButton" class="btn btn-lg btn-block btn-warning" onclick="pauseRun()">Pause</button>
<button type="button" id="pauseButton" class="btn btn-lg btn-block btn-warning ndisabler" onclick="pauseRun()">Pause</button>
</div>
<div class="col-4 mb-1">
<button type="button" class="btn btn-lg btn-block btn-danger" id="stopButton" onclick="$(this).removeClass('stopbutton'); action('stopRun')">Stop</button>
Expand Down