-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now has support for more than two cameras, drops support for storage …
…in NetworkTables because honestly why
- Loading branch information
1 parent
f142532
commit fd54708
Showing
1 changed file
with
14 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
// This should be added inside the definition of the 'ui' object at the starting of ui.js. | ||
|
||
, | ||
camera: document.getElementById('camera') | ||
, | ||
camera: document.getElementById('camera'), | ||
cameraId: 0, | ||
cameras: [ // Will default to first camera | ||
'INSERT FIRST CAMERA STREAM SOURCE', | ||
'INSERT SECOND CAMERA STREAM SOURCE', | ||
'INSERT THIRD CAMERA STREAM SOURCE', | ||
'INSERT FOURTH CAMERA STREAM SOURCE' | ||
] | ||
|
||
// End section | ||
|
||
|
||
|
||
// Copy this portion of the code into the large switch statement in the onValueChanged function. Then change the src's. | ||
// Unlike most addons for FRC Dashboard, this addon doesn't interact with NetworkTables and is only client-side. | ||
|
||
case '/SmartDashboard/useBackCamera': | ||
if (value) { | ||
ui.camera.src = 'INSERT HERE THE SOURCE OF YOUR BACK CAMERA'; | ||
} else { | ||
ui.camera.src = 'INSERT HERE THE SOURCE OF YOUR FRONT OR MAIN CAMERA'; | ||
} | ||
break; | ||
|
||
// End Section | ||
|
||
// Add this at the bottom of ui.js. | ||
|
||
|
||
// Add this at the bottom of ui.js with the other listeners. | ||
|
||
// Toggle between camera views | ||
// Toggle between camera views. | ||
ui.camera.onclick = function() { | ||
var cameraKey = '/SmartDashboard/Drive | backCamera'; | ||
NetworkTables.setValue(cameraKey, !NetworkTables.getValue(cameraKey)); | ||
if (ui.cameraId === ui.cameras.length) ui.cameraId = 0; | ||
ui.camera.src = cameras[ui.cameraId]; | ||
}; | ||
|
||
// End section |