cpuTemperature() apple silicon support

This commit is contained in:
Sebastian Hildebrandt 2022-07-14 08:33:08 +02:00
parent ff91141a8a
commit 58cef5c046
6 changed files with 17 additions and 5 deletions

View File

@ -66,7 +66,7 @@ We had to make **several interface changes** to keep systeminformation as consis
- `uuid()`: better value support - `uuid()`: better value support
- `uuid()`: added MACs - `uuid()`: added MACs
- `uuid()`: better Raspberry Pi hardware ID - `uuid()`: better Raspberry Pi hardware ID
- `Apple M1 Silicon extended support (now everything supported except of cpu temperature) - `Apple M1 Silicon extended support
- `updated TypeScript definitions - `updated TypeScript definitions
#### Test Full Version 5 Functionality #### Test Full Version 5 Functionality

View File

@ -904,7 +904,7 @@ To be able to measure temperature on macOS I created a little additional package
in NPM with `optionalDependencies` I unfortunately was getting unexpected warnings on other platforms. in NPM with `optionalDependencies` I unfortunately was getting unexpected warnings on other platforms.
So I decided to drop this optional dependency for macOS - so by default, you will not get correct values. So I decided to drop this optional dependency for macOS - so by default, you will not get correct values.
This additional package will unfortunately NOT work on Apple Silicon M1 machines. This additional package is now also supporting Apple Silicon M1 machines.
But if you need to detect macOS temperature just run the following additional But if you need to detect macOS temperature just run the following additional
installation command: installation command:

View File

@ -192,7 +192,7 @@
<li><span class="code">uuid()</span>: added MACs</li> <li><span class="code">uuid()</span>: added MACs</li>
<li><span class="code">uuid()</span>: better Raspberry Pi hardware ID</li> <li><span class="code">uuid()</span>: better Raspberry Pi hardware ID</li>
<li><span class="code">versions()</span>: added bash, zsh, fish, powershell, dotnet</li> <li><span class="code">versions()</span>: added bash, zsh, fish, powershell, dotnet</li>
<li><span class="code">Apple M1 Silicon</span> extended support (now everything supported except of cpu temperature)</li> <li><span class="code">Apple M1 Silicon</span> extended support</li>
<li>updated TypeScript definitions </li> <li>updated TypeScript definitions </li>
</ul> </ul>
<h4>Test Full Version 5 Functionality</h4> <h4>Test Full Version 5 Functionality</h4>

View File

@ -594,7 +594,7 @@ si.cpuTemperature().then(data => console.log(data));</code></pre class="example"
I unfortunately was getting unexpected warnings on other platforms. So I decided to drop this optional dependency for macOS - so by default, I unfortunately was getting unexpected warnings on other platforms. So I decided to drop this optional dependency for macOS - so by default,
you will not get correct values.</p> you will not get correct values.</p>
<p>This additional package will unfortunately not work on Apple Silicon M1 machines.</p> <p>This additional package is now also suppprting Apple Silicon M1 machines.</p>
<p>But if you need to detect macOS temperature just run the following additional installation command:</p> <p>But if you need to detect macOS temperature just run the following additional installation command:</p>

View File

@ -50,7 +50,7 @@
I unfortunately was getting unexpected warnings on other platforms. So I decided to drop this optional dependency for macOS - so by default, I unfortunately was getting unexpected warnings on other platforms. So I decided to drop this optional dependency for macOS - so by default,
you will not get correct values.</p> you will not get correct values.</p>
<p>This additional package will unfortunately not work on Apple Silicon M1 machines.</p> <p>This additional package is now also supporting Apple Silicon M1 machines.</p>
<p>But if you need to detect macOS temperature just run the following additional installation command:</p> <p>But if you need to detect macOS temperature just run the following additional installation command:</p>

View File

@ -1204,6 +1204,18 @@ function cpuTemperature(callback) {
} }
if (osxTemp) { if (osxTemp) {
result = osxTemp.cpuTemperature(); result = osxTemp.cpuTemperature();
// round to 2 digits
if (result.main) {
result.main = Math.round(result.main * 100) / 100;
}
if (result.max) {
result.max = Math.round(result.max * 100) / 100;
}
if (result.cores && result.cores.length) {
for (let i = 0; i < result.cores.length; i++) {
result.cores[i] = Math.round(result.cores[i] * 100) / 100;
}
}
} }
if (callback) { callback(result); } if (callback) { callback(result); }