언어 설정

Menu
Sites
Language
Utility for gear

I want to develop a utility that allows the gear watch to remain on while charging.  This could be used so that the gear can be used as a clock while it charges.

I have the code to stop the gear from turning off during the application run ie the clock being displayed but need to condition with the charging status.  Any advice on how to check if the unit is currently charging requested.

If the charge, the utility could be turned off.

Responses

1 댓글
daniel kim

Hi, I wish this code will help you.

<script>

/* As Tizen is webkit-based, it uses the webkit prefix */

var battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery;

   window.addEventListener('load', function(e)
   {
      /* Charging status: true or false */
      document.querySelector('#charging').textContent = battery.charging ? 'charging' : 'not charging';

      /* Battery charging time: seconds (for example, 3600) or Infinity */
      document.querySelector('#chargingTime').textContent = battery.chargingTime / 60;

      /* Battery life: seconds (for example, 3600) or Infinity */
      document.querySelector('#dischargingTime').textContent = battery.dischargingTime / 60;

      /* Battery.level: between 0 and 1 (for example, 0.50) */
      document.querySelector('#level').textContent = Math.floor(battery.level * 100) + '%';  
   }, false);
</script>