Update sumorobot.js

This commit is contained in:
Silver Kuusik 2017-11-14 14:59:19 +01:00 committed by GitHub
parent e34572a8f2
commit bef66dfbda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,7 +55,7 @@ Sumorobot.prototype.connect = function() {
var data = evt.data.replace(/'/g, '"').toLowerCase(); var data = evt.data.replace(/'/g, '"').toLowerCase();
console.log(data); console.log(data);
var battery = JSON.parse(data)["battery_voltage"]; var battery = JSON.parse(data)["battery_voltage"];
battery = Math.round((((battery - 3.0) * 100) / (4.2 - 3.6))); battery = Math.round((((battery - 3.0) * 100) / (4.2 - 3.0)));
$("#battery").html(battery + "%"); $("#battery").html(battery + "%");
$("#bar").html("Battery"); $("#bar").html("Battery");
$("#bar").addClass("connected"); $("#bar").addClass("connected");