diff --git a/assets/img/battery_disconnected.png b/assets/img/battery_disconnected.png new file mode 100644 index 0000000..3a8d37b Binary files /dev/null and b/assets/img/battery_disconnected.png differ diff --git a/assets/img/battery_empty.png b/assets/img/battery_empty.png new file mode 100644 index 0000000..0396634 Binary files /dev/null and b/assets/img/battery_empty.png differ diff --git a/assets/img/battery_full.png b/assets/img/battery_full.png new file mode 100644 index 0000000..8d78a32 Binary files /dev/null and b/assets/img/battery_full.png differ diff --git a/assets/img/battery_half.png b/assets/img/battery_half.png new file mode 100644 index 0000000..7ac38ab Binary files /dev/null and b/assets/img/battery_half.png differ diff --git a/assets/js/sumorobot.js b/assets/js/sumorobot.js index 9cc56b4..5bbee19 100755 --- a/assets/js/sumorobot.js +++ b/assets/js/sumorobot.js @@ -31,8 +31,7 @@ Sumorobot.prototype.connect = function() { // Setup connection watchdog interval self.connectionTimer = setInterval(function() { if (self.watchdogCounter == 0 && !self.terminate) { - $('#battery').removeClass('connected'); - $('#battery').html('Disconnected'); + $("#battery img").attr("src", "assets/img/battery_disconnected.png"); } // Reset watchdog counter self.watchdogCounter = 0; @@ -66,8 +65,13 @@ Sumorobot.prototype.connect = function() { self.sensors = JSON.parse(data); // When sensor data received if (self.sensors['battery_voltage']) { - $('#battery').html(self.sensors['battery_voltage'] + 'V'); - $('#battery').addClass('connected'); + if (self.sensors['battery_voltage'] > 4.0) { + $("#battery img").attr("src", "assets/img/battery_full.png"); + } else if (self.sensors['battery_voltage'] > 3.1) { + $("#battery img").attr("src", "assets/img/battery_half.png"); + } else { + $("#battery img").attr("src", "assets/img/battery_empty.png"); + } } // Count data received packets self.watchdogCounter += 1; diff --git a/index.html b/index.html index 497e186..5d6ef51 100755 --- a/index.html +++ b/index.html @@ -12,10 +12,13 @@ - + + + + @@ -23,15 +26,12 @@ - - - - + -
Disconnected
+