From cf664c185f6e8fd9e660236b27b4a04d47739ab6 Mon Sep 17 00:00:00 2001 From: Nicholas264 Date: Thu, 15 Feb 2018 08:20:51 -0800 Subject: [PATCH 01/42] Fixed things (more info in des.) Fixed ui.js where it wouldn't connect due to half of an object being thrown halfway across the file, leaving the other half broken, causing errors. Fixed positioning in index.html and style.css --- css/style.css | 12 +++++++++--- index.html | 2 +- ui.js | 10 +++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/css/style.css b/css/style.css index 9780bec..723450f 100644 --- a/css/style.css +++ b/css/style.css @@ -52,13 +52,15 @@ body > * { #timer { font-family: monospace; display: block; - height: 7vh; - width: 10vw; + height: fit-content; + width: fit-content; top: 0; left: 0; - font-size: 7vh; + font-size: 3em; line-height: .8; z-index: 1; + background-color: hsla(0,0%,40%,.5); + padding: .2em; } header { width: 20vw; @@ -284,4 +286,8 @@ html, body { top: 10px; right: 10px; z-index: 1; +} +.offset { + position: relative; + top:250px; } \ No newline at end of file diff --git a/index.html b/index.html index 8b05e8f..cb4121e 100644 --- a/index.html +++ b/index.html @@ -66,7 +66,7 @@
2:15
-
+
diff --git a/ui.js b/ui.js index 0246203..536de47 100644 --- a/ui.js +++ b/ui.js @@ -1,4 +1,9 @@ // Define UI elements +let ui = { + timer: document.getElementById('timer'), + robotState: document.getElementById('robot-state').firstChild, + gyro: { + container: document.getElementById('gyro'), val: 0, offset: 0, visualVal: 0, @@ -31,11 +36,6 @@ }; let address = document.getElementById('connect-address'), connect = document.getElementById('connect'); -let ui = { - timer: document.getElementById('timer'), - robotState: document.getElementById('robot-state').firstChild, - gyro: { - container: document.getElementById('gyro'), // Sets function to be called on NetworkTables connect. Commented out because it's usually not necessary. // NetworkTables.addWsConnectionListener(onNetworkTablesConnection, true); From e93cdfcbee2eb01b5d6742713fc2a04436322c6e Mon Sep 17 00:00:00 2001 From: Jacob Golden-Needham Date: Thu, 15 Feb 2018 17:18:17 -0800 Subject: [PATCH 02/42] Trying to fix things - Nick --- index.html | 48 ++++++++++++++++++++++++++----------- ui.js | 69 ++---------------------------------------------------- 2 files changed, 36 insertions(+), 81 deletions(-) diff --git a/index.html b/index.html index cb4121e..99dbc49 100644 --- a/index.html +++ b/index.html @@ -9,14 +9,10 @@ -
-
- -
@@ -49,13 +45,22 @@ - +
-
- +
+ +
Unknown state
+ +
-
+ + -
-
2:15
-
-
+
2:15
+
+ + + + + + + @@ -85,11 +95,21 @@
+ +
+
+

Adjust arm height

+ +
diff --git a/ui.js b/ui.js index 536de47..b8f2dfe 100644 --- a/ui.js +++ b/ui.js @@ -86,7 +86,7 @@ function onRobotConnection(connected) { connect.disabled = false; connect.firstChild.data = 'Connect'; // Add the default address and select xxxx - address.value = ''; + address.value = 'roborio-4738-FRC.local'; address.focus(); address.setSelectionRange(8, 12); // On click try to connect and disable the input and the button @@ -102,33 +102,9 @@ function onRobotConnection(connected) { /**** KEY Listeners ****/ -// Gyro rotation -let updateGyro = (key, value) => { - ui.gyro.val = value; - ui.gyro.visualVal = Math.floor(ui.gyro.val - ui.gyro.offset); - if (ui.gyro.visualVal < 0) { - ui.gyro.visualVal += 360; - } - ui.gyro.arm.style.transform = `rotate(${ui.gyro.visualVal}deg)`; - ui.gyro.number.innerHTML = ui.gyro.visualVal + 'º'; -}; -NetworkTables.addKeyListener('/SmartDashboard/drive/navx/yaw', updateGyro); - // The following case is an example, for a robot with an arm at the front. // Info on the actual robot that this works with can be seen at thebluealliance.com/team/1418/2016. -NetworkTables.addKeyListener('/SmartDashboard/arm/encoder', (key, value) => { - // 0 is all the way back, 1200 is 45 degrees forward. We don't want it going past that. - if (value > 1140) { - value = 1140; - } - else if (value < 0) { - value = 0; - } - // Calculate visual rotation of arm - var armAngle = value * 3 / 20 - 45; - // Rotate the arm in diagram to match real arm - ui.robotDiagram.arm.style.transform = `rotate(${armAngle}deg)`; -}); + NetworkTables.addKeyListener('/SmartDashboard/time_running', (key, value) => { // Sometimes, NetworkTables will pass booleans as strings. This corrects for that. if (typeof value === 'string') @@ -208,11 +184,6 @@ NetworkTables.addKeyListener('/SmartDashboard/time_running', (key, value) => { ui.autoSelect.value = NetworkTables.getValue('/SmartDashboard/currentlySelectedMode'); }); -// Load list of prewritten autonomous modes -NetworkTables.addKeyListener('/SmartDashboard/autonomous/selected', (key, value) => { - ui.autoSelect.value = value; -}); - // Global Listener function onValueChanged(key, value, isNew) { console.log("valuechanged"); @@ -285,42 +256,6 @@ function onValueChanged(key, value, isNew) { } } -// The rest of the doc is listeners for UI elements being clicked on -ui.example.button.onclick = function () { - // Set NetworkTables values to the opposite of whether button has active class. - NetworkTables.putValue('/SmartDashboard/example_variable', this.className != 'active'); -}; -// Reset gyro value to 0 on click -ui.gyro.container.onclick = function () { - // Store previous gyro val, will now be subtracted from val for callibration - ui.gyro.offset = ui.gyro.val; - // Trigger the gyro to recalculate value. - updateGyro('/SmartDashboard/drive/navx/yaw', ui.gyro.val); -}; -// Open tuning section when button is clicked -ui.tuning.button.onclick = function () { - if (ui.tuning.list.style.display === 'none') { - ui.tuning.list.style.display = 'block'; - } - else { - ui.tuning.list.style.display = 'none'; - } -}; -// Manages get and set buttons at the top of the tuning pane -ui.tuning.set.onclick = function () { - // Make sure the inputs have content, if they do update the NT value - if (ui.tuning.name.value && ui.tuning.value.value) { - NetworkTables.putValue('/SmartDashboard/' + ui.tuning.name.value, ui.tuning.value.value); - } -}; -ui.tuning.get.onclick = function () { - ui.tuning.value.value = NetworkTables.getValue(ui.tuning.name.value); -}; -// Update NetworkTables when autonomous selector is changed -ui.autoSelect.onchange = function () { - NetworkTables.putValue('/SmartDashboard/autonomous/selected', this.value); -}; -// Get value of arm height slider when it's adjusted ui.armPosition.oninput = function () { NetworkTables.putValue('/SmartDashboard/arm/encoder', parseInt(this.value)); } From d5b3f08ca1cce59f00191aa9f9e4b947ce19ee56 Mon Sep 17 00:00:00 2001 From: Nicholas264 Date: Thu, 15 Feb 2018 19:19:46 -0800 Subject: [PATCH 03/42] Fixed thing --- css/style.css | 3 +++ index.html | 44 +++++++++++++++++++++++++++++---- ui.js | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 108 insertions(+), 6 deletions(-) diff --git a/css/style.css b/css/style.css index 723450f..fd9fd26 100644 --- a/css/style.css +++ b/css/style.css @@ -290,4 +290,7 @@ html, body { .offset { position: relative; top:250px; +} +.dontshowthisbecausejavascriptgetsmad { + display: none; } \ No newline at end of file diff --git a/index.html b/index.html index 99dbc49..e07a9b7 100644 --- a/index.html +++ b/index.html @@ -9,10 +9,14 @@ +
+
+ +
@@ -45,9 +49,40 @@ + +
+
+ + +
+ + + +
+
2:15
+
+
+ + + + + + + + + + + +
-
+ +
Unknown state
@@ -55,7 +90,7 @@ -