From f1c953c6151418516eb446fb2e5e5b738d2fcc66 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 5 Dec 2020 12:24:41 +0100 Subject: [PATCH] add ptz --- server.py | 5 +++- static/js/cccc.js | 18 ++++++++++++++ static/ptz.html | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 static/ptz.html diff --git a/server.py b/server.py index a9884da..fb477dc 100755 --- a/server.py +++ b/server.py @@ -128,7 +128,10 @@ class API(object): 'RIGHT_UP', 'RIGHT_DOWN', 'IN', 'OUT', ): - direction = getattr(ctl.camera, data['direction']) + direction = getattr(ctl.camera, data['direction']).copy() + speed = int(data.get('speed', 1)) + for key in direction: + direction[key] *= speed ctl.camera.momentary(direction, float(data.get('duration', 1))) return result diff --git a/static/js/cccc.js b/static/js/cccc.js index dfec645..645362a 100644 --- a/static/js/cccc.js +++ b/static/js/cccc.js @@ -663,3 +663,21 @@ function init_shift() { setInterval(updateShiftStatus, 5000) }) } + +function init_ptz() { + var ptz = document.querySelector('#ptz') + if (ptz) { + ptz.querySelectorAll('button').forEach(button => { + button.addEventListener('click', event => { + var duration = parseFloat(ptz.querySelector('input[name="duration"]').value) + var speed = parseInt(ptz.querySelector('input[name="speed"]').value) + api('move', { + direction: button.dataset.direction, + duration: duration, + speed: speed + }, response=> {}) + }) + }) + } + +} diff --git a/static/ptz.html b/static/ptz.html new file mode 100644 index 0000000..069f84a --- /dev/null +++ b/static/ptz.html @@ -0,0 +1,61 @@ + + + + + + CAMP can capture canals + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+ +
+ +
+
+ + + +
+
+ + + +
+ Speed: +
+ Duration: +
+ + + +