Update sumorobot.js

This commit is contained in:
Silver Kuusik 2017-11-14 14:55:15 +01:00 committed by GitHub
parent f9dce03f27
commit 93ea803a5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,9 +55,9 @@ Sumorobot.prototype.connect = function() {
var data = evt.data.replace(/'/g, '"').toLowerCase();
console.log(data);
var battery = JSON.parse(data)["battery_voltage"];
battery = Math.round((((battery - 3.6) * 100) / (4.2 - 3.6)));
//$("#battery").html(battery + "");
$("#bar").html("Connected");
battery = Math.round((((battery - 3.0) * 100) / (4.2 - 3.6)));
$("#battery").html(battery + "");
//$("#bar").html("Connected");
$("#bar").addClass("connected");
};
/* when there is an WebSocket error */