From bcd88d6d4d515c1bdf14508ddcb4315e68021903 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Thu, 9 Aug 2018 03:48:21 +0300 Subject: [PATCH] rc: fix low battery notification throttling --- apps/ios/cleverrc/telemetry.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/ios/cleverrc/telemetry.js b/apps/ios/cleverrc/telemetry.js index 41e04612..9606136f 100644 --- a/apps/ios/cleverrc/telemetry.js +++ b/apps/ios/cleverrc/telemetry.js @@ -35,10 +35,14 @@ new ROSLIB.Topic({ }); function notifyLowBattery() { + console.log('low battery'); callNativeApp('lowBattery'); + body.classList.remove('low-battery'); + void body.offsetWidth; // trick for repeating animation + body.classList.add('low-battery'); } -notifyLowBatteryThrottled = throttle(notifyLowBattery, 10000); +notifyLowBatteryThrottled = throttle(notifyLowBattery, 15000); new ROSLIB.Topic({ ros: ros, @@ -50,11 +54,7 @@ new ROSLIB.Topic({ batteryEl.innerHTML = (message.cell_voltage[0].toFixed(2) + ' V') || ''; if (message.cell_voltage[0] < LOW_BATTERY) { - console.log('low battery'); - callNativeApp('lowBattery'); - body.classList.remove('low-battery'); - void body.offsetWidth; // trick for repeating animation - body.classList.add('low-battery'); + notifyLowBatteryThrottled(); } else { body.classList.remove('low-battery'); }