Skip to content

Commit

Permalink
basic fix to the received commands
Browse files Browse the repository at this point in the history
  • Loading branch information
flash62au committed Jan 25, 2024
1 parent c67e408 commit 2a8a23d
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/new-items.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow is to be used for all repositories to integrate with the DCC++ EX Beta Project.
# This workflow is to be used for all repositories to integrate with the DCC-EX Beta Project.
# It will add all issues and pull requests for a repository to the project, and put in the correct status.
#
# Ensure "REPO_LABEL" is updated with the correct label for the repo stream of work.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DCC++ EX Web Throttle
# DCC-EX-WebThrottle

This is a prototype for a new DCC++ EX Throttle/Controller that can connect to the DCC++ EX Commmand Station directly through the USB port of a computer.
This is a prototype for a new DCC-EX Throttle/Controller that can connect to the DCCEX EX-CommmandStation directly through the USB port of a computer.

## What you need to setup the project

Expand All @@ -25,18 +25,18 @@ NOTE: If you don't have your hardware yet or just want to play with the throttle
To get started, connect your Command Station to a computer that has a USB port and have a compatible browser installed. Use a USB serial cable from your computer to the serial connector on the Arduino. Visit DCC-EX.github.io/WebThrottle-EX/ to start using the software.


Alternativly, you can download the zip file found in the releases section and extract it. Click on the "index.html" or "exwebthrotle.html" file to load the webpage. This method is only recommended if you need a specific version as it won't be auto-updated.
Alternatively, you can download the zip file found in the releases section and extract it. Click on the "index.html" or "exwebthrotle.html" file to load the webpage. This method is only recommended if you need a specific version as it won't be auto-updated.


## Operation

To use the program, you can either click on the "serial" dropodown button and select "emulator" to run in emulator mode or after making sure your hardware is properly connected, make sure "serial" is selected and click on the "Connect DCC++ EX" button.
To use the program, you can either click on the "serial" dropdown button and select "emulator" to run in emulator mode or after making sure your hardware is properly connected, make sure "serial" is selected and click on the "Connect DCC-EX" button.

If the program finds a compatible device, it will popup a window showing you a selection. It may show a line at the top such as "Arduino Mega 2560 (COM3)". Your com port may vary. Click on your board to select it and then click the "connect" button.

You should then be connected to the Command Station (CS) and should see the response from the CS on the web page under the buttons. Make sure your debug console is open. If it isn't, use the slider button in the lower left to open it. You can also open the DevTools window in your browser to see more developer logging.

Once you are connected, you can enter the ``<s>`` command in the "direct command" textbox to get status information from your Command Station, just enter "s" (without the quotes) and press the SEND button. You can send any DCC++ API command in this way. You should see <iDCC++...> returned in the log window with your version, type of arduino, type of motor shield, and some other information.
Once you are connected, you can enter the ``<s>`` command in the "direct command" textbox to get status information from your Command Station, just enter "s" (without the quotes) and press the SEND button. You can send any DCC++ command in this way. You should see <iDCC++...> returned in the log window with your version, type of arduino, type of motor shield, and some other information.

Now you are ready to run trains! Place your loco on the track and click the power slider button to turn on power to your track. You should see lights on an Arduino Motor Board light and an indication that your loco has power.

Expand Down
8 changes: 4 additions & 4 deletions css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ hr{
.column-5 {
float: left;
width: 50%;
padding: 5px 15px;
padding: 0px 15px;
}
.column-6{
float: left;
Expand Down Expand Up @@ -75,9 +75,9 @@ hr{
display: inline-block;
}
.throttle-heading .wt-logo{
height: 48px;
width: 142px;
background: url(../images/WebThrottle.png);
height: 40px;
width: 200px;
background: url(../images/product-logo-ex-webthrottle.png);
display: inline-block;
background-size: 100%;
box-shadow: 0 0 3px #989898;
Expand Down
8 changes: 4 additions & 4 deletions css/throttle.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ label.formbuilder-file-label {
}
.fn-button.field-button-fn{
text-align: center;
padding: 8px;
padding: 5px;
display: flex;
justify-content: center;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ label.formbuilder-file-label {
text-align: center;
}
.rendered-form div.throttle-container{
min-height: 360px;
min-height: 280px;
display: flex;
align-items: center;
justify-content: right;
Expand Down Expand Up @@ -425,10 +425,10 @@ label.formbuilder-file-label {
box-shadow: 0px 0px 1px 1px #e2e2e2;
}
.power-slider .slider{
background-color: #00a349;
background-color: #ff0000;
}
input:checked + .slider {
background-color: #ff0000;
background-color: #00a349;
box-shadow: 1px 1px rgba(255,255,255,0.8);
}

Expand Down
Binary file added images/product-logo-ex-webthrottle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Fred Decker
Matt
This file is part of the DCC++ EX Project for model railroading and more.
This file is part of the DCC-EX Project for model railroading and more.
For more information, visit use at dcc-ex.com
-->
<head>
Expand Down Expand Up @@ -59,8 +59,8 @@
<script type="text/javascript" src="js/exwebthrottle.js"></script>
-->

<title>DCC++ EX Web Throttle</title>
<meta name="description" content="Chromium browser based web throttle for a DCC++ EX Command Station to control model trains">
<title>DCC-EX Web Throttle</title>
<meta name="description" content="Chromium browser based web throttle for a DCC-EX EX-CommandStation to control model trains">
<html lang="en">
</head>

Expand Down Expand Up @@ -124,7 +124,7 @@
<option value="emulator">Emulator</option>
</select>
<button type="button" class="btn-default btn" title="Connect to the Command Station" aria-state="connected" name="button-connect" access="false" id="button-connect">
<span class="con-ind"></span>Connect DCC++ EX
<span class="con-ind"></span>Connect DCC-EX
</button>
<!-- <button class="btn-grey" id="fs-toggle" state="ws" title="Fullscreen">&#10530;</button> -->
</div>
Expand Down Expand Up @@ -192,7 +192,7 @@
<span class="slider round"></span>
</label>
<span class="pow-status">
Power <span id="power-status">Off</span>
Track Power <span id="power-status">is Off</span>
</span>
</div>
<div class="note-msg column-6">
Expand Down
41 changes: 35 additions & 6 deletions js/commandController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* This is part of the DCC++ EX Project for model railroading and more.
/* This is part of the DCC-EX Project for model railroading and more.
For licence information, please see index.html
For more information, see us at dcc-ex.com.
Expand All @@ -7,6 +7,8 @@
Open a serial port and create a stream to read and write data
While there is data, we read the results in loop function
*/
let commandString = "";

$(document).ready(function(){
console.log("Command Controller loaded");
uiDisable(true)
Expand Down Expand Up @@ -68,7 +70,7 @@ async function connectServer() {
emulatorMode = true;
// Displays dummy hardware message
displayLog("\n[CONNECTION] Emulator connected")
displayLog("[RECEIVE] DCC++ EX COMMAND STATION FOR EMULATOR / EMULATOR MOTOR SHIELD: V-1.0.0 / Feb 30 2020 13:10:04")
displayLog("[RECEIVE] DCC-EX EXCOMMANDSTATION FOR EMULATOR / EMULATOR MOTOR SHIELD: V-1.0.0 / Feb 30 2020 13:10:04")
uiDisable(false)
return true;
}
Expand All @@ -82,9 +84,36 @@ async function readLoop() {
const { value, done } = await reader.read();
// if (value && value.button) { // alternate check and calling a function
// buttonPushed(value);

let thisCommandString = "";

if (value) {
displayLog('[RECEIVE] '+value);
console.log('[RECEIVE] '+value);
// displayLog('[RECEIVE] '+ value);
// console.log('[RECEIVE] '+ value);

commandString = commandString + value;

let start = -1;
let end = -1;
for (i=0; i<commandString.length; i++) {
if (commandString.charAt(i)=='<') {
start = i;
break;
}
}
for (i=start+1; i<commandString.length; i++) {
if (commandString.charAt(i)=='>') {
end = i;
break;
}
}
if ((start>=0) && (end>start)) {
thisCommandString = commandString.substring(start+1,end);
if (end>0) commandString = commandString.substring(end);
displayLog('[RECEIVE] &lt;'+ thisCommandString +"&gt;");
console.log('[RECEIVE] &lt;'+ thisCommandString +"&gt;");
}

}
if (done) {
console.log('[readLoop] DONE'+done.toString());
Expand Down Expand Up @@ -202,7 +231,7 @@ async function toggleServer(btn) {
if (port || emulatorMode) {
await disconnectServer();
btn.attr('aria-state','Disconnected');
btn.html('<span class="con-ind"></span>Connect DCC++ EX'); //<span id="con-ind"></span>Connect DCC++ EX
btn.html('<span class="con-ind"></span>Connect DCC-EX'); //<span id="con-ind"></span>Connect DCC-EX
return;
}

Expand All @@ -211,7 +240,7 @@ async function toggleServer(btn) {
// Checks if the port was opened successfully
if (success) {
btn.attr('aria-state','Connected');
btn.html('<span class="con-ind connected"></span>Disconnect DCC++ EX');
btn.html('<span class="con-ind connected"></span>Disconnect DCC-EX');
} else {
selectMethod.disabled = false;
}
Expand Down
2 changes: 1 addition & 1 deletion js/emulator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* This is part of the DCC++ EX Project for model railroading and more.
/* This is part of the DCC-EX Project for model railroading and more.
For licence information, please see index.html.
For more information, see us at dcc-ex.com.
Expand Down
8 changes: 4 additions & 4 deletions js/exwebthrottle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Mani Kumar
Matt
This is part of the DCC++ EX Project for model railroading and more.
This is part of the DCC-EX Project for model railroading and more.
For more information, see us at dcc-ex.com.
*/
window.cv=0;
Expand Down Expand Up @@ -421,7 +421,7 @@ $(document).ready(function(){

$("#info-tooltip").tooltip({
content:
"<p>DCC++ EX Web Throttle<br>(WebThrottle-EX)</p><hr><p>Version: "+version+"</p><p><b>Credits</b><br> Fred Decker <br> Mani Kumar <br> Matt H</p>",
"<p>DCC-EX EX-WebThrottle<br>(WebThrottle-EX)</p><hr><p>Version: "+version+"</p><p><b>Credits</b><br> Fred Decker <br> Mani Kumar <br> Matt H</p>",
show: {
effect: "slideDown",
delay: 100,
Expand Down Expand Up @@ -500,10 +500,10 @@ $(document).ready(function(){

if (pb == true) {
writeToStream("1");
$("#power-status").html("On");
$("#power-status").html("is On");
} else {
writeToStream("0");
$("#power-status").html("Off");
$("#power-status").html("is Off");
}
});
////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion js/storageController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* This is part of the DCC++ EX Project for model railroading and more.
/* This is part of the DCC-EX Project for model railroading and more.
For licence information, please see index.html.
For more information, see us at dcc-ex.com.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "WebThrottle-EX",
"name": "DCC++ EX Web Throttle",
"name": "DCC-EX EX-WebThrottle",
"icons": [
{
"src": "images/full-logo.png",
Expand Down

0 comments on commit 2a8a23d

Please sign in to comment.