1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-04 01:23:21 +00:00

Updated power-monitor for linux

This commit is contained in:
Bryan Roe
2020-05-31 08:58:28 -07:00
parent bfaddfaee2
commit 1d81dba897
2 changed files with 17 additions and 1 deletions

View File

@@ -88,6 +88,21 @@ function powerMonitor()
return (sum);
}
this._BatteryLevel = this._getBatteryLevel();
// Since Battery Levels are not propagated with ACPI, we need to periodically check the battery level
this._BatteryLevelCheck = function _BatteryLevelCheck()
{
var val = this._getBatteryLevel();
if (val != this._BatteryLevel)
{
this._BatteryLevel = val;
this.emit('batteryLevel', val);
}
};
this._BattCheckInterval = setInterval(function (self)
{
self._BatteryLevelCheck.call(self);
}, 300000, this);
}
this._acpiSink = function _acpiSink(acpiEvent)
{
@@ -95,6 +110,7 @@ function powerMonitor()
{
_acpiSink.self._ACState = acpiEvent.value;
_acpiSink.self.emit('acdc', acpiEvent.value == 1 ? 'AC' : 'BATTERY');
_acpiSink.self._BatteryLevelCheck();
}
};
this._acpiSink.self = this;