-
Notifications
You must be signed in to change notification settings - Fork 1
/
WiringPi.php
106 lines (78 loc) · 1.9 KB
/
WiringPi.php
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
class WiringPi {
const OUTPUT = 1;
const INPUT = 0;
const HIGH = 1;
const LOW = 0;
static function wiringPiSetup() {
return wiringPiSetup();
}
static function wiringPiSetupSys() {
return wiringPiSetupSys();
}
static function wiringPiSetupGpio() {
return wiringPiSetupGpio();
}
static function pullUpDnControl($pin,$pud) {
pullUpDnControl($pin,$pud);
}
static function pinMode($pin,$mode) {
pinMode($pin,$mode);
}
static function digitalWrite($pin,$value) {
digitalWrite($pin,$value);
}
static function pwmWrite($pin,$value) {
pwmWrite($pin,$value);
}
static function digitalRead($pin) {
return digitalRead($pin);
}
static function shiftOut($dPin,$cPin,$order,$val) {
shiftOut($dPin,$cPin,$order,$val);
}
static function shiftIn($dPin,$cPin,$order) {
return shiftIn($dPin,$cPin,$order);
}
static function delay($howLong) {
delay($howLong);
}
static function delayMicroseconds($howLong) {
delayMicroseconds($howLong);
}
static function millis() {
return millis();
}
static function serialOpen($device,$baud) {
return serialOpen($device,$baud);
}
static function serialClose($fd) {
serialClose($fd);
}
static function serialPutchar($fd,$c_) {
serialPutchar($fd,$c_);
}
static function serialPuts($fd,$s) {
serialPuts($fd,$s);
}
static function serialDataAvail($fd) {
return serialDataAvail($fd);
}
static function serialGetchar($fd) {
return serialGetchar($fd);
}
static function serialPrintf($fd,$message) {
serialPrintf($fd,$message);
}
}
class WiringPiExec extends WiringPi {
const GPIO_command = "/usr/local/bin/gpio";
static function wiringPiSetup(){
}
static function pinMode($pin,$mode) {
exec(self::GPIO_command.' mode '.intval($pin).' '.($mode==self::OUTPUT?'out':'in'));
}
static function digitalWrite($pin,$value) {
exec(self::GPIO_command.' write '.intval($pin).' '.($value==self::HIGH?'1':'0'));
}
}