Skip to content

Commit

Permalink
Update exwebthrottle.js
Browse files Browse the repository at this point in the history
The direction slider sends <t> commands to loco 0 if no loco is selected. #62
  • Loading branch information
ManiAkasapu committed Aug 24, 2021
1 parent ad6fca6 commit 0b3f4d7
Showing 1 changed file with 43 additions and 35 deletions.
78 changes: 43 additions & 35 deletions js/exwebthrottle.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,47 +579,55 @@ $(document).ready(function(){

// Allows user to change the direction of the loco and STOP.
$(".dir-btn").on("click", function () {
current = $(this);
dir = current.attr("aria-label");
$(".dir-btn").removeClass("selected");
current.addClass("selected", 200);
console.log(dir);
$(".dir-toggle").removeClass("forward backward stop");
$(".dir-toggle").addClass(dir);

// Do direction stuff here
switch (dir) {
case "forward": {
isStopped = false;
setDirection(1);
setSpeedofControllers();
writeToStream("t 01 " + getCV() + " " + getSpeed() + " 1");
break;
}
case "backward": {
setDirection(0);
setSpeedofControllers();
isStopped = false;
writeToStream("t 01 " + getCV() + " " + getSpeed() + " 0");
break;
if (getCV() != 0){
current = $(this);
dir = current.attr("aria-label");
$(".dir-btn").removeClass("selected");
current.addClass("selected", 200);
console.log(dir);
$(".dir-toggle").removeClass("forward backward stop");
$(".dir-toggle").addClass(dir);
// Do direction stuff here
switch (dir) {
case "forward": {
isStopped = false;
setDirection(1);
setSpeedofControllers();
writeToStream("t 01 " + getCV() + " " + getSpeed() + " 1");
break;
}
case "backward": {
isStopped = false;
setDirection(0);
setSpeedofControllers();
writeToStream("t 01 " + getCV() + " " + getSpeed() + " 0");
break;
}
case "stop": {
isStopped = true;
dir = getDirection();
setSpeed(0);
setSpeedofControllers();
writeToStream("t 01 " + getCV() + " 0 " + dir);
break;
}
}
case "stop": {
}else{
console.log("No loco acquired");
}
});

$("#emergency-stop").on("click", function () {
if (getCV() != 0){
isStopped = true;
dir = getDirection();
setSpeed(0);
setSpeedofControllers();
writeToStream("t 01 " + getCV() + " 0 " + dir);
break;
writeToStream("t 01 " + getCV() + " -1 " + dir);
}
else{
console.log("No loco acquired");
}
}
});

$("#emergency-stop").on("click", function () {
isStopped = true;
dir = getDirection();
setSpeed(0);
setSpeedofControllers();
writeToStream("t 01 " + getCV() + " -1 " + dir);
});

// Hide/Show the Loco, Connect server fields (on top)
Expand Down

0 comments on commit 0b3f4d7

Please sign in to comment.