From fd54708626c8c577a4d4104e8dce176be0d6a1fa Mon Sep 17 00:00:00 2001 From: ErikBoesen Date: Sat, 4 Jun 2016 15:55:08 -0400 Subject: [PATCH] Now has support for more than two cameras, drops support for storage in NetworkTables because honestly why --- multicamera.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/multicamera.js b/multicamera.js index 4b4e7b7..e5add27 100644 --- a/multicamera.js +++ b/multicamera.js @@ -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 \ No newline at end of file