Initial commit of migrated code from noccylabs/acpi-thermal

This commit is contained in:
2015-01-23 19:15:07 +01:00
parent fa5788791a
commit 5b46f454c2
17 changed files with 946 additions and 0 deletions

15
examples/allzones.php Normal file
View File

@ -0,0 +1,15 @@
<?php
require_once __DIR__."/../vendor/autoload.php";
use NoccyLabs\Linux\Thermal;
$zones = Thermal\Zone::getAllZones();
foreach ($zones as $zone) {
printf("%s = %.1fºC\n",
$zone->getName(),
$zone->getTemp()
);
}

33
examples/temp-logger.php Normal file
View File

@ -0,0 +1,33 @@
<?php
require_once __DIR__."/../vendor/autoload.php";
use NoccyLabs\Linux\Thermal;
define("BUFFER_SIZE", 5);
$zones = Thermal\Zone::getAllZones();
$buff = array();
$vals = null; $c=0;
while(true) {
$vals = array();
foreach ($zones as $zone) {
$vals[] = sprintf("%.1f",$zone->getTemp());
}
$buff[] = $vals;
$last = $vals;
if (count($buff)>BUFFER_SIZE) { array_shift($buff); }
$buffs = count($buff);
foreach($vals as $i=>$vcur) {
$avg = array_sum(array_column($buff, $i))/$buffs;
$vals[$i] = sprintf("%.1f", $avg);
}
$vals = array_merge($last, $vals);
array_unshift($vals, $c++);
fputcsv(STDOUT, $vals, ';');
sleep(5);
}