Skip to content

Commit

Permalink
Now has support for more than two cameras, drops support for storage …
Browse files Browse the repository at this point in the history
…in NetworkTables because honestly why
  • Loading branch information
ErikBoesen committed Jun 4, 2016
1 parent f142532 commit fd54708
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions multicamera.js
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

0 comments on commit fd54708

Please sign in to comment.