Skip to content

Commit bcd961b

Browse files
Correction glitch
1 parent 6e05a39 commit bcd961b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

hf-data/js/connection.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ async function newStream(connection, isMobile) {
258258
}
259259

260260
async function newEvent(connection, isMobile) {
261+
// Can be good to add generic tuple types for the event (1 event instead of 2-3).
261262
const apiCalls = [];
262263
const resultHandlers = [];
263264
if (isMobile) {

hf-data/js/mobile.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ let recording = [];
1616
let is_recording;
1717
let is_showing;
1818
let is_live;
19+
let end_time_last_batch = new Date(0);
1920
let recordingTimeout = [];
2021

2122
const samplingAccRate = 15;
@@ -135,10 +136,14 @@ function animateVisu() {
135136
}
136137

137138
function recordAccelerometer(pointsAlpha, pointsBeta, pointsGamma, l) {
139+
let now = new Date();
140+
let diff = end_time_last_batch - now;
141+
diff = diff > 0 ? diff:0;
142+
end_time_last_batch = new Date(now.getTime() + diff + samplingAccRate * l);
138143
for (let i = 0; i < l; i++) {
139144
recording.push([pointsAlpha[i], pointsBeta[i], pointsGamma[i]]);
140145
if (is_live) {
141-
time = samplingAccRate * i;
146+
time = (diff + samplingAccRate * i);
142147
recordingTimeout[i] = setTimeout(() => {
143148
cubeAlphaVisu = pointsAlpha[i];
144149
cubeBetaVisu = pointsBeta[i];

0 commit comments

Comments
 (0)