Skip to content

Commit

Permalink
Merge pull request #55 from fuddster/main
Browse files Browse the repository at this point in the history
Add cycle timer
  • Loading branch information
fuddster authored Jan 10, 2023
2 parents 012a818 + 10d5c36 commit 6576e4c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ User defined fields can be of several different types:
* Radio Buttons - A single choice between several options (Ball pick up: ()Ground ()Loading Bay ()Both ()None)
* Checkbox - A single on/off or yes/no check box (Exit Start Line? []Yes if checked)
* Timer - A time counter to count the number of seconds it takes to do something (How long did it take to climb?)
* Cycle Timer - Start the timer and with 1 click track cycle times of robots.
* Field Image - Using an image of the field, select positions on the field. (Use to record starting point, or shooting locations)

These should cover most of your scouting team's data collection needs. PWNAGE's 2020 Infinite Recharge configuration file is included as an example. The import of the configuration file is in index.html and would need to be updated to import a different configuration file. Only import one configuration file.
Expand Down Expand Up @@ -187,6 +188,7 @@ Distributed under the GNU GPL v3.0 License. See `LICENSE` for more information.
Scouting PASS continues to evolve. Here are the changes for the 2023 Season:

* New Timer component - Start/Stop and Clear Buttons
* New Cycle component - Keep track of cycle times
* JSON simplification - The JSON structure has been simplified to make it a little easier to maintain. The previous years configuration files have been updated to use the new structure.
* Add "Flip Image" button to the Field Image component
* Add "tooltip" option for components - Tooltips will appear when hovering over the name of the component
Expand Down
39 changes: 26 additions & 13 deletions resources/js/scoutingPASS.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var checkboxAs = 'YN';

// Options
var options = {
text: "t=9998;m=99;l=q;r=b1;s=rjs;d=0;to=0;ds=5;if=0;f=15;cf=0;in=1;alp=5;aop=5;aip=5;apu=5;atr=1;atro=0;lp=20;op=10;ip=10;rc=0;pc=0;ss=[(111,111),(111,111),(111,111),(111,111),(111,111),(111,111),(111,111)];c=1;hbc=0;ac=1;hc=0;cb=0;cs=3;nh=0;p=0;b=0;tr=1;ct=3;dr=3;comm='good shooter; shot from all over the field'",
correctLevel: QRCode.CorrectLevel.L,
quietZone: 15,
quietZoneColor: '#FFFFFF'
Expand Down Expand Up @@ -48,7 +47,11 @@ function addTimer(table, idx, name, data) {
cell2.appendChild(button1);

var inp = document.createElement("input");
inp.classList.add("timer");
if (data.type == 'timer') {
inp.classList.add("timer");
} else {
inp.classList.add("cycle");
}
inp.setAttribute("id", "input_" + data.code);
inp.setAttribute("type", "text");
if (enableGoogleSheets) {
Expand Down Expand Up @@ -78,10 +81,16 @@ function addTimer(table, idx, name, data) {
button2.innerHTML += "New Cycle"
cell2.appendChild(button2);
var ct = document.createElement('input');
ct.setAttribute("type", "text"); // Change back to hidden?
ct.setAttribute("type", "hidden");
ct.setAttribute("id", "cycletime_" + data.code);
ct.setAttribute("value", "[]");
cell2.appendChild(ct);
ct = document.createElement('input');
ct.setAttribute("type", "text");
ct.setAttribute("id", "display_" + data.code);
ct.setAttribute("value", "");
ct.setAttribute("disabled", "");
cell2.appendChild(ct);
}

idx += 1
Expand Down Expand Up @@ -767,6 +776,9 @@ function getData(useStr) {
}
}
} else {
if (e.className == "cycle") {
e = document.getElementById("cycletime_" + code);
}
if (useStr) {
str = str + code + '=' + e.value.split(';').join('-')
} else {
Expand Down Expand Up @@ -862,16 +874,20 @@ function clearForm() {
var defaultValue = document.getElementById("default_" + baseCode).value
if (defaultValue != "") {
if (defaultValue == e.value) {
console.log("they match!")
e.checked = true
document.getElementById("display_" + baseCode).value = defaultValue
}
}
} else {
if (e.type == "number" || e.type == "text" || e.type == "hidden") {
if ((e.className == "counter") ||
(e.className == "timer")) {
(e.className == "timer") ||
(e.className == "cycle")) {
e.value = 0
if (e.className == "cycle") {
document.getElementById("cycletime_" + code).value = "[]"
document.getElementById("display_" + code).value = ""
}
} else {
e.value = ""
}
Expand Down Expand Up @@ -1080,21 +1096,18 @@ function counter(element, step) {
function newCycle(event)
{
let timerID = event.firstChild;
let inp = document.getElementById("input" + getIdBase(timerID.id))
let base = getIdBase(timerID.id);
let inp = document.getElementById("input" + base)
let cycleTime = inp.value
inp.value = 0

console.log(cycleTime);

let cycleInput = document.getElementById("cycletime" + getIdBase(timerID.id));
let cycleInput = document.getElementById("cycletime" + base);

console.log(cycleInput.value);
console.log(cycleInput.id);
console.log(cycleInput.class);
console.log("***"+cycleInput.value+"***");
var tempValue = Array.from(JSON.parse(cycleInput.value));
tempValue.push(cycleTime);
cycleInput.value = JSON.stringify(tempValue);
let d = document.getElementById("display" + base);
d.value = cycleInput.value.replace(/\"/g,'').replace(/\[/g, '').replace(/\]/g, '').replace(/,/g, ', ');
}

function resetTimer(event) {
Expand Down

0 comments on commit 6576e4c

Please sign in to comment.