aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2012-10-22 15:18:35 +0800
committerAndy Green <andy.green@linaro.org>2012-10-31 17:39:14 +0100
commitbe38afe88bbb124573a82a15f2314de7aaf8ef13 (patch)
tree3878a3f70e450e1b1ee3f676922364c0fc82be8c
parent807b18c08eade9c0f5c695930d6d69accef380c7 (diff)
allow dragging scrollbar
Signed-off-by: Andy Green <andy.green@linaro.org>
-rw-r--r--aepd/share/aepscope.html95
-rw-r--r--aepd/websocket-protocol.c5
-rw-r--r--config2
3 files changed, 94 insertions, 8 deletions
diff --git a/aepd/share/aepscope.html b/aepd/share/aepscope.html
index 68427ef..5def4c2 100644
--- a/aepd/share/aepscope.html
+++ b/aepd/share/aepscope.html
@@ -233,6 +233,8 @@ var trigger_level = 0.05;
var trigger_drag = 0;
var trigger_channel = 0;
+var scroll_drag = 0;
+
var rates = [ 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 4, 3, 2, 1 ];
var intervals = [ 50, 20, 10, 5, 2, 1, 1, 0.5, 0.25, 0.1, 0.05, 0.05, 0.025, 0.025, 0.01 ];
var sigs = [ 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 2, 3, 3, 2 ];
@@ -270,9 +272,26 @@ function event_wheel(e)
return cancelEvent(e);
}
+function set_scroll_left_x(xp)
+{
+ xp = (xlen + y_axis_width) - xp;
+
+ if (xp < 0)
+ xp = 0;
+ if (xp > (xlen + y_axis_width) /*- get_scrollbar_xpos(1) */)
+ xp = (xlen + y_axis_width) /* - get_scrollbar_xpos(1) */;
+
+ viewport_offset_time = - (xp / (xlen + y_axis_width)) * (ring_head_time - (rates[rate] * 0.0001 * xlen));
+ document.getElementById("val").textContent = xp.toFixed(4) + " " + viewport_offset_time.toFixed(3) + " " + ring_head_time.toFixed(4);
+
+
+ update_options();
+}
+
function event_drag_start(e)
{
- var x, y, n;
+ var x, y, n, lscroll;
+
if (e.offsetX) {
x = e.offsetX;
y = e.offsetY;
@@ -281,10 +300,29 @@ function event_drag_start(e)
y = e.layerY - offsetY;
}
+ trigger_drag = 0;
+ caliper_drag_index = -1;
+ scroll_drag = 0;
+
+ /*
+ * dragging the scrollbar?
+ */
+ if (y > ylen + x_axis_height + caliper_headroom - 16) {
+
+// lscroll = get_scrollbar_xpos(0);
+
+// if (x > lscroll && x < lscroll + get_scrollbar_xpos(1)) {
+// scroll_drag = x - lscroll;
+
+ scroll_drag = 1;
+ e.stopPropagation ();
+ return;
+// }
+ }
+
/*
* dragging a caliper?
*/
- caliper_drag_index = -1;
for (n = 0; n < 2; n++) {
if (x > cal_pos[n] - 8 && x < cal_pos[n] + 16) {
caliper_drag_index = n;
@@ -296,7 +334,6 @@ function event_drag_start(e)
/*
* dragging the trigger level?
*/
- trigger_drag = 0;
n = ylen -(ylen * (trigger_level / watts_fullscale)) + caliper_headroom;
if (n < caliper_headroom)
n = caliper_headroom;
@@ -326,20 +363,36 @@ function event_drag(e)
x -= 8;
+ /* caliper drag? */
+
if (caliper_drag_index >= 0) {
if (cal_pos[caliper_drag_index] != x) {
cal_pos[caliper_drag_index] = x;
dirty = 1;
caliper_changed();
+ e.stopPropagation ();
+ return false;
}
}
+ /* trigger drag? */
+
if (trigger_drag && y <= ylen) {
n = ylen -(ylen * (trigger_level / watts_fullscale)) + caliper_headroom;
trigger_level = ((ylen - (y - caliper_headroom)) / ylen) * watts_fullscale;
dirty = 1;
trigger_level_changed();
+ e.stopPropagation ();
+ return false;
+ }
+
+ /* scrollbar drag? */
+
+ if (scroll_drag != 0) {
+ set_scroll_left_x(x - scroll_drag);
+ e.stopPropagation ();
+ return false;
}
e.stopPropagation ();
@@ -350,6 +403,7 @@ function event_drag_end(e)
{
caliper_drag_index = -1;
trigger_drag = 0;
+ scroll_drag = 0;
dirty = 1;
}
@@ -720,10 +774,12 @@ function conn_retry()
f = msg.data.substr(1);
y = f.split(',');
+ ring_head_time = parseFloat(y[0]);
+
chan = 0;
- while (chan < y.length) {
+ while (chan < (y.length - 1)) {
- x = y[chan].split(' ');
+ x = y[chan + 1].split(' ');
if (x.length != 3) {
chan++;
continue;
@@ -834,6 +890,7 @@ function conn_retry()
ring_head = 0;
tpt += (rates[rate] * 0.0001);
+
if (loading)
loading--;
@@ -841,7 +898,7 @@ function conn_retry()
block++;
}
- if (!channel_data)
+ if (channel_data == 0)
peak_time = tpt;
if (!channel_data && do_title)
@@ -939,6 +996,27 @@ function units3(n) {
return ('0');
}
+function get_scrollbar_xpos(which)
+{
+ var ro, rx, extent, x2, xx;
+
+ x2 = xlen + y_axis_width;
+ extent = rates[rate] * 0.0001 * xlen;
+ ro = ring_head_time /*+ viewport_offset_time */;
+ rx = ro - extent;
+ if (rx < 0)
+ rx = 0;
+
+ x = (x2 * (rx / peak_time));
+ xx = x2 * (extent / peak_time);
+ if (xx < 10) { // minimum width
+ x -= (10 - xx) / 2;
+ xx = 10;
+ }
+ if (which == 0)
+ return x;
+ return xx;
+}
function show(cv)
{
@@ -996,6 +1074,11 @@ function show(cv)
// document.getElementById("val").textContent = (ring_head_time - ring_start_time)+" "+ro+" "+extent+" "+rx+" "+x;
ctx.fillRect(x, ylen + x_axis_height + caliper_headroom - 12, xx, 8);
+/*
+ ctx.fillRect(get_scrollbar_xpos(0),
+ ylen + x_axis_height + caliper_headroom - 12,
+ get_scrollbar_xpos(1), 8);
+*/
/*
* waveform drawing
diff --git a/aepd/websocket-protocol.c b/aepd/websocket-protocol.c
index a59df63..e3b3e64 100644
--- a/aepd/websocket-protocol.c
+++ b/aepd/websocket-protocol.c
@@ -145,6 +145,7 @@ callback_linaro_aepd(struct libwebsocket_context *context,
*/
if (ms10 != pss->ms10_last_caliper && aepd_shared->chans) {
+
pss->ms10_last_caliper = ms10;
if (pss->caliper_time[0] > aepd_shared->fifo_head_time ||
@@ -185,6 +186,7 @@ callback_linaro_aepd(struct libwebsocket_context *context,
(aepd_shared->chans * sizeof(double) * 3);
*p++ = 'c';
+ p += sprintf(p, "%f,", aepd_shared->fifo_head_time);
m = 0;
for (n = 0; n < aepd_shared->chans; n++) {
@@ -236,7 +238,8 @@ bad_caliper:
extent /= aepd_shared->chans * sizeof(double) * 3;
- p += sprintf(p, "t%f %f %f %d", aepd_shared->fifo_head_time - ((double)extent * 0.0001), aepd_shared->fifo_tail_time, aepd_shared->fifo_head_time, aepd_shared->stop_flag ^ 1);
+
+ p += sprintf(p, "t%f %f %f %d %d", aepd_shared->fifo_head_time - ((double)extent * 0.0001), aepd_shared->fifo_tail_time, aepd_shared->fifo_head_time, aepd_shared->stop_flag ^ 1, pss->viewport_budget);
goto send;
}
diff --git a/config b/config
index 01e02b7..ab395d1 100644
--- a/config
+++ b/config
@@ -5,7 +5,7 @@ PandaBoardES-B1-ANDY
# <device path>
/dev/ttyACM0
- VDD_VCORE1 0.220000 -14.500000 -0.015950 0.011774 -0.000311 0.000943 0 SoCVCORE1/MPU VBAT #ff0000 SoC
+ VDD_VCORE1 0.220000 -14.500000 -0.009721 0.011774 -0.000311 0.000943 0 SoCVCORE1/MPU VBAT #ff0000 SoC
VDD_VCORE2 0.470000 -45.000000 -0.015710 0.007876 -0.002165 0.000874 0 SoCVCORE2/IVA\\_AUDIO VBAT #c00000 SoC
VDD_VCORE3 0.470000 -27.500000 -0.016074 0.002175 -0.000272 0.000625 0 SoCVCORE3/CORE VBAT #a00000 SoC