2770 |
rexy |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* pitemp sensor class
|
|
|
4 |
*
|
|
|
5 |
* PHP version 5
|
|
|
6 |
*
|
|
|
7 |
* @category PHP
|
|
|
8 |
* @package PSI_Sensor
|
|
|
9 |
* @author Marc Hillesheim <hawkeyexp@gmail.com>
|
|
|
10 |
* @copyright 2012 phpSysInfo
|
|
|
11 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
|
|
|
12 |
* @version Release: 3.0
|
|
|
13 |
* @link http://phpsysinfo.sourceforge.net
|
|
|
14 |
*/
|
|
|
15 |
class PiTemp extends Sensors
|
|
|
16 |
{
|
|
|
17 |
private function _temperature()
|
|
|
18 |
{
|
|
|
19 |
$temp = null;
|
|
|
20 |
$temp_max = null;
|
|
|
21 |
if (!CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input', $temp, 1, 4096, false)) { // Not Banana Pi
|
|
|
22 |
CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/temp', $temp, 1);
|
|
|
23 |
CommonFunctions::rfts('/sys/class/thermal/thermal_zone0/trip_point_0_temp', $temp_max, 1, 4096, PSI_DEBUG);
|
|
|
24 |
}
|
3037 |
rexy |
25 |
if (($temp !== null) && (($temp = trim($temp)) != "")) {
|
2770 |
rexy |
26 |
$dev = new SensorDevice();
|
|
|
27 |
$dev->setName("CPU 1");
|
|
|
28 |
$dev->setValue($temp / 1000);
|
3037 |
rexy |
29 |
if (($temp_max !== null) && (($temp_max = trim($temp_max)) != "") && ($temp_max > 0)) {
|
2770 |
rexy |
30 |
$dev->setMax($temp_max / 1000);
|
|
|
31 |
}
|
|
|
32 |
$this->mbinfo->setMbTemp($dev);
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
private function _voltage()
|
|
|
37 |
{
|
|
|
38 |
$volt = null;
|
3037 |
rexy |
39 |
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now', $volt, 1, 4096, false) && ($volt !== null) && (($volt = trim($volt)) != "")) { // Banana Pi
|
2770 |
rexy |
40 |
$dev = new SensorDevice();
|
|
|
41 |
$dev->setName("Voltage 1");
|
|
|
42 |
$dev->setValue($volt / 1000000);
|
|
|
43 |
$this->mbinfo->setMbVolt($dev);
|
|
|
44 |
}
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
private function _current()
|
|
|
48 |
{
|
|
|
49 |
$current = null;
|
3037 |
rexy |
50 |
if (CommonFunctions::rfts('/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now', $current, 1, 4096, false) && ($current !== null) && (($current = trim($current)) != "")) { // Banana Pi
|
2770 |
rexy |
51 |
$dev = new SensorDevice();
|
|
|
52 |
$dev->setName("Current 1");
|
|
|
53 |
$dev->setValue($current / 1000000);
|
|
|
54 |
$this->mbinfo->setMbCurrent($dev);
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
public function build()
|
|
|
59 |
{
|
2976 |
rexy |
60 |
if ((PSI_OS == 'Linux') && !defined('PSI_EMU_HOSTNAME')) {
|
|
|
61 |
$this->_temperature();
|
|
|
62 |
$this->_voltage();
|
|
|
63 |
$this->_current();
|
|
|
64 |
}
|
2770 |
rexy |
65 |
}
|
|
|
66 |
}
|