-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude.inc.php
More file actions
84 lines (66 loc) · 1.98 KB
/
include.inc.php
File metadata and controls
84 lines (66 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
function getConstants($byKey = false) {
$conf = array(
'ac_coil_protect' => 40
);
if($byKey !== false)
return $conf[$byKey];
else
return $conf;
}
function getStatus() {
$status = array(
'temperature' => trim(file_get_contents(dirname(__FILE__).'/io/temperature')),
'ac_coil_temp' => trim(file_get_contents(dirname(__FILE__).'/io/ac_coil_temp')),
'fan' => trim(file_get_contents(dirname(__FILE__).'/io/gpio_fan')),
'cool' => trim(file_get_contents(dirname(__FILE__).'/io/gpio_comp')),
'heat' => trim(file_get_contents(dirname(__FILE__).'/io/gpio_heat')),
'desired' => trim(file_get_contents(dirname(__FILE__).'/state/desired_temp')),
'latency' => ( time() - intval(file_get_contents(dirname(__FILE__).'/state/last_cycle')) ) ,
'now' => time()
);
return array_merge($status, getConstants());
}
function fanOn() {
file_put_contents(dirname(__FILE__).'/state/fan_run_until', time() + 30);
file_put_contents(dirname(__FILE__).'/io/gpio_fan', '1');
}
function fanOff() {
$fanTimeout = intval(trim(file_get_contents(dirname(__FILE__).'/state/fan_run_until')));
if(time() > $fanTimeout) {
file_put_contents(dirname(__FILE__).'/state/fan_run_until', '0');
file_put_contents(dirname(__FILE__).'/io/gpio_fan', '0');
}
}
function coolOn() {
// If the coil goes under a certain temperature, turn off to avoid freeze-over
if( trim(file_get_contents(dirname(__FILE__).'/io/ac_coil_temp')) < getConstants('ac_coil_protect') )
coolOff();
else
file_put_contents(dirname(__FILE__).'/io/gpio_comp', '1');
}
function coolOff() {
file_put_contents(dirname(__FILE__).'/io/gpio_comp', '0');
}
function heatOn() {
file_put_contents(dirname(__FILE__).'/io/gpio_heat', '1');
}
function heatOff() {
file_put_contents(dirname(__FILE__).'/io/gpio_heat', '0');
}
function systemOff() {
coolOff();
heatOff();
fanOff();
}
function systemHeat() {
fanOn();
heatOn();
coolOff();
}
function systemCool() {
fanOn();
heatOff();
coolOn();
}
?>