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 |
|
| 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.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.4 | 2020-01-24 | `mem()` prevent log messages, `memgetDefaultNetworkInterface()` catch errors |
|
||||||
| 4.19.3 | 2020-01-24 | `memLayout()` bank info fix macOS |
|
| 4.19.3 | 2020-01-24 | `memLayout()` bank info fix macOS |
|
||||||
|
|||||||
@ -143,7 +143,7 @@
|
|||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>capacity unit (mWh)</td>
|
<td>capacity unit (mWh if possible)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -225,6 +225,32 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td>battery serial</td>
|
<td>battery serial</td>
|
||||||
</tr>
|
</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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h2>Known issues</h2>
|
<h2>Known issues</h2>
|
||||||
|
|||||||
@ -83,6 +83,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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>
|
<tr>
|
||||||
<th scope="row">4.20.0</th>
|
<th scope="row">4.20.0</th>
|
||||||
<td>2020-01-25</td>
|
<td>2020-01-25</td>
|
||||||
|
|||||||
@ -168,7 +168,7 @@
|
|||||||
<img class="logo" src="assets/logo.png">
|
<img class="logo" src="assets/logo.png">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span></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>
|
<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>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
@ -206,7 +206,7 @@
|
|||||||
<div class="title">Downloads last month</div>
|
<div class="title">Downloads last month</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
<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 class="title">Dependends</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -586,6 +586,10 @@ pre {
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.example {
|
||||||
|
background-color: unset;
|
||||||
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -406,6 +406,9 @@ pre {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
.example {
|
||||||
|
background-color: unset;
|
||||||
|
}
|
||||||
footer {
|
footer {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
|
|||||||
@ -64,11 +64,11 @@ module.exports = function (callback) {
|
|||||||
result.ischarging = (util.getValue(lines, 'POWER_SUPPLY_STATUS', '=').toLowerCase() === 'charging');
|
result.ischarging = (util.getValue(lines, 'POWER_SUPPLY_STATUS', '=').toLowerCase() === 'charging');
|
||||||
result.acconnected = result.ischarging;
|
result.acconnected = result.ischarging;
|
||||||
result.voltage = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_VOLTAGE_NOW', '='), 10) / 1000000.0;
|
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.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.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) * 100) / 100| result.maxcapacity;
|
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) * 100) / 100;
|
result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10) / 1000.0 / (result.voltage || 1));
|
||||||
result.capacityUnit = 'mWh';
|
|
||||||
if (!result.maxcapacity) {
|
if (!result.maxcapacity) {
|
||||||
result.maxcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL', '='), 10) / 1000.0;
|
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;
|
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) {
|
if (stdout) {
|
||||||
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
|
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
|
||||||
result.cyclecount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10);
|
result.cyclecount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10);
|
||||||
result.capacityUnit = 'mWh';
|
|
||||||
result.voltage = parseInt('0' + util.getValue(lines, 'voltage', '='), 10) / 1000.0;
|
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.capacityUnit = result.voltage ? 'mWh' : 'mAh';
|
||||||
result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'currentcapacity', '='), 10) * (result.voltage || 1) * 100) / 100;
|
result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'maxcapacity', '='), 10) * (result.voltage || 1));
|
||||||
result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1) * 100) / 100;
|
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.manufacturer = 'Apple';
|
||||||
result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
|
result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
|
||||||
let percent = -1;
|
let percent = -1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user