battery() code refactoring, cleanup, updated docs
This commit is contained in:
parent
04abd0c2a9
commit
95f72bbb1a
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 4.20.1 | 2020-01-26 | `battery()` code refactoring, cleanup, updated docs |
|
||||
| 4.20.0 | 2020-01-25 | `battery()` added designcapacity, voltage, unit |
|
||||
| 4.19.4 | 2020-01-24 | `mem()` prevent log messages, `memgetDefaultNetworkInterface()` catch errors |
|
||||
| 4.19.3 | 2020-01-24 | `memLayout()` bank info fix macOS |
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>capacity unit (mWh)</td>
|
||||
<td>capacity unit (mWh if possible)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
@ -225,6 +225,32 @@
|
||||
<td></td>
|
||||
<td>battery serial</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan="7">
|
||||
<h5>Example</h5>
|
||||
<pre><code class="js">const si = require('systeminformation');
|
||||
si.battery().then(data => console.log(data));</code></pre class="example">
|
||||
<pre class="example">
|
||||
{
|
||||
hasbattery: true,
|
||||
cyclecount: 35,
|
||||
ischarging: false,
|
||||
designedcapacity: 64958,
|
||||
maxcapacity: 65865,
|
||||
currentcapacity: 64856,
|
||||
voltage: 12.767,
|
||||
capacityUnit: 'mWh',
|
||||
percent: 100,
|
||||
timeremaining: 551,
|
||||
acconnected: false,
|
||||
type: 'Li-ion',
|
||||
model: '',
|
||||
manufacturer: 'Apple',
|
||||
serial: 'F9Y19860Y9AH9XBAX'
|
||||
}
|
||||
</pre>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h2>Known issues</h2>
|
||||
|
||||
@ -83,6 +83,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">4.20.1</th>
|
||||
<td>2020-01-26</td>
|
||||
<td><span class="code">battery()</span> code refactoring, cleanup, updated docs</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.20.0</th>
|
||||
<td>2020-01-25</td>
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
<img class="logo" src="assets/logo.png">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span></div>
|
||||
<div class="version">Current Version: <span id="version">4.20.0</span></div>
|
||||
<div class="version">Current Version: <span id="version">4.20.1</span></div>
|
||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||
</div>
|
||||
<div class="down">
|
||||
@ -206,7 +206,7 @@
|
||||
<div class="title">Downloads last month</div>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||
<div class="numbers">239</div>
|
||||
<div class="numbers">240</div>
|
||||
<div class="title">Dependends</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -586,6 +586,10 @@ pre {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.example {
|
||||
background-color: unset;
|
||||
}
|
||||
|
||||
footer {
|
||||
background-color: #eee;
|
||||
margin-top: 30px;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -406,6 +406,9 @@ pre {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
.example {
|
||||
background-color: unset;
|
||||
}
|
||||
footer {
|
||||
background-color: #eee;
|
||||
margin-top: 30px;
|
||||
|
||||
@ -64,11 +64,11 @@ module.exports = function (callback) {
|
||||
result.ischarging = (util.getValue(lines, 'POWER_SUPPLY_STATUS', '=').toLowerCase() === 'charging');
|
||||
result.acconnected = result.ischarging;
|
||||
result.voltage = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_VOLTAGE_NOW', '='), 10) / 1000000.0;
|
||||
result.capacityUnit = result.voltage ? 'mWh' : 'mAh';
|
||||
result.cyclecount = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CYCLE_COUNT', '='), 10);
|
||||
result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL', '='), 10) / 1000.0 / (result.voltage || 1) * 100) / 100;
|
||||
result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL_DESIGN', '='), 10) / 1000.0 / (result.voltage || 1) * 100) / 100| result.maxcapacity;
|
||||
result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10) / 1000.0 / (result.voltage || 1) * 100) / 100;
|
||||
result.capacityUnit = 'mWh';
|
||||
result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL', '='), 10) / 1000.0 / (result.voltage || 1));
|
||||
result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL_DESIGN', '='), 10) / 1000.0 / (result.voltage || 1))| result.maxcapacity;
|
||||
result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10) / 1000.0 / (result.voltage || 1));
|
||||
if (!result.maxcapacity) {
|
||||
result.maxcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL', '='), 10) / 1000.0;
|
||||
result.designcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL_DESIGN', '='), 10) / 1000.0 | result.maxcapacity;
|
||||
@ -130,11 +130,11 @@ module.exports = function (callback) {
|
||||
if (stdout) {
|
||||
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
|
||||
result.cyclecount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10);
|
||||
result.capacityUnit = 'mWh';
|
||||
result.voltage = parseInt('0' + util.getValue(lines, 'voltage', '='), 10) / 1000.0;
|
||||
result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'maxcapacity', '='), 10) * (result.voltage || 1) * 100) / 100;
|
||||
result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'currentcapacity', '='), 10) * (result.voltage || 1) * 100) / 100;
|
||||
result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1) * 100) / 100;
|
||||
result.capacityUnit = result.voltage ? 'mWh' : 'mAh';
|
||||
result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'maxcapacity', '='), 10) * (result.voltage || 1));
|
||||
result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'currentcapacity', '='), 10) * (result.voltage || 1));
|
||||
result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1));
|
||||
result.manufacturer = 'Apple';
|
||||
result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
|
||||
let percent = -1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user