Skip to content

Adding SM Prog Tab #80

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

Open
wants to merge 1 commit 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
114 changes: 112 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<script type="text/javascript" src="js/addloco.js"></script>
<script type="text/javascript" src="js/emulator.js"></script>
<script type="text/javascript" src="js/exwebthrottle.js"></script>
<script type="text/javascript" src="js/pwa.js"></script>
<script type="text/javascript" src="js/pwa.js"></script>

<!--
NOTE: You can replace the above links with these if you like if you will always run when
Expand Down Expand Up @@ -74,6 +74,7 @@
<li tabindex="0" class="throttle" id="throttle-nav"><span>Throttle</span></li>
<li tabindex="0" class="locomotives" id="loco-nav"><span>Locomotives</span></li>
<li tabindex="0" class="function-maps" id="fn-map-nav"><span>Function Maps</span></li>
<li tabindex="0" class="progtool" id="prog-nav"><span>CV Programmer</span></li>
<li tabindex="0" class="settings" id="settings-nav"><span>Settings</span></li>
</ul>
</nav>
Expand Down Expand Up @@ -239,7 +240,105 @@
</div>
</div>
</section>


<section id="prog-window" class="section" hidden="true">
<div class="row settings-heading">
<div class="column-7 pl0 hdng">
CV Programmer
</div>
</div>
<div class="row settings-content">
<div class="side-panel">
<ul>
<li id="settings-general">Programming Mode</li>
<li id="settings-storage">Address Programming</li>
<li id="settings-app">CV Programming</li>
</ul>
</div>

<div class="settings-panel scrollbar" id="settings-panel">
<div class="settings-section" id="progsettings-section">
<div class="settings-subheading">
Programming Mode
</div>
<div class="settings-group">
<div class="row setting-entry">
<label class="setting-label">
Select Mode
</label>
<div class="setting-content">
<select id="progmode-selector" class="btn progmode-selector select-control" name="progmodeselector" title="Change Programming Mode">
<option value="ServiceMode"> Service Mode </option>
<option value="OpsMode"> Operations Mode </option>
</select>
</div>
</div>
<div class="row setting-entry" id="opsadrinput">
<label class="setting-label">
DCC Address
</label>
<div class="setting-content">
<input class="column-2 align-right" type="integer" id="opsaddress" placeholder="" name="opsaddress" required>
</div>
</div>
</div>
</div>
<div class="settings-section" id="addrprog-section">
<div class="settings-subheading">
Address Programming
</div>
<div class="settings-group">
<div class="row setting-entry">
<label class="setting-label">
New DCC Address:
</label>
<div class="setting-content">
<input class="column-2 align-right" type="integer" id="dccaddress" name="dccaddress" required>
</div>
</div>
<div class="row setting-entry">
<label class="setting-label">
<button id="prog-read-addr">Read Address</button>
</label>
<label class="setting-label">
<button id="prog-write-addr">Write Address</button>
</label>
</div>
</div>
</div>
<div class="settings-section" id="cvprog-section">
<div class="settings-subheading">
CV Programming
</div>
<div class="settings-group">
<div class="row setting-entry">
<label class="setting-label">
CV #:
</label>
<div class="setting-content">
<input class="column-2 align-right" type="integer" id="cvaddress" name="cvaddress" required>
</div>
<label class="setting-label">
CV Value:
</label>
<div class="setting-content">
<input class="column-2 align-right" type="integer" id="cvvalue" name="cvvalue" required>
</div>
</div>
<div class="row setting-entry">
<label class="setting-label">
<button id="prog-read-cv">Read CV</button>
</label>
<label class="setting-label">
<button id="prog-write-cv">Write CV</button>
</label>
</div>
</div>
</div>
</div>
</div>
</section>

<section id="loco-window" class="section" hidden="true">
<div class="row settings-heading">
<div class="column-7 pl0 hdng">
Expand Down Expand Up @@ -401,6 +500,17 @@ <h4 class="fn-heading add-loco-head">Add Locomotive</h4>
</select>
</div>
</div>
<div class="row setting-entry">
<label class="setting-label">
Programming Track Mode
</label>
<div class="setting-content">
<select id="joinmode-selector" class="btn joinmode-selector select-control" name="joinmodeselector" title="Change Prog Track Mode">
<option value="joined"> JOIN Mode </option>
<option value="individual"> Programming only </option>
</select>
</div>
</div>
</div>
</div>
<div class="settings-section" id="storage-section">
Expand Down
43 changes: 42 additions & 1 deletion js/commandController.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,58 @@ async function connectServer() {
}
}

function parseCommand(thisCmd) {
console.log(thisCmd);
switch (thisCmd[1])
{
// case '*': console.log("COMMENT: " + thisCmd); break;
case 'r':
{
// console.log("ADDRESS: " + thisCmd);
var newVal = (thisCmd.slice(2, thisCmd.length - 1)).trimStart().split(" ");
dispAddrVal(newVal);
break;
}
// default: console.log("COMMAND: " + thisCmd); break;
}
}
// While there is still data in the serial buffer us an asynchronous read loop
// to get the data and place it in the "value" variable. When "done" is true
// all the data has been read or the port is closed
async function readLoop() {
var cmdBuffer = "";
while (true) {
const { value, done } = await reader.read();
// if (value && value.button) { // alternate check and calling a function
// buttonPushed(value);
if (value) {
cmdBuffer += value;
// console.log('[RECEIVE] '+ value);
// console.log(cmdBuffer);
var checkCmd = true;
while (checkCmd)
{
var start = cmdBuffer.indexOf('<', 0);
// console.log("start: ", start);
if (start >= 0)
{
var end = cmdBuffer.indexOf('>', start);
// console.log("end: ", end);
if (end > start)
{
var newCmd = cmdBuffer.substr(start, end - start + 1);
var remBuffer = cmdBuffer.substr(end + 1, cmdBuffer.length - end - 1);
cmdBuffer = remBuffer;
// console.log(cmdBuffer);
parseCommand(newCmd);
}
else
checkCmd = false;
}
else
checkCmd = false;
}
displayLog('[RECEIVE] '+value);
console.log('[RECEIVE] '+value);
}
if (done) {
console.log('[readLoop] DONE'+done.toString());
Expand Down
Loading