File tree Expand file tree Collapse file tree 3 files changed +82
-6
lines changed Expand file tree Collapse file tree 3 files changed +82
-6
lines changed Original file line number Diff line number Diff line change @@ -30,32 +30,32 @@ abstract class Board implements BoardInterface {
30
30
*
31
31
* Register for gpio functions
32
32
*/
33
- private $ gpio_register ;
33
+ protected $ gpio_register ;
34
34
35
35
/**
36
36
* @var Register\PWM
37
37
*/
38
- private $ pwm_register ;
38
+ protected $ pwm_register ;
39
39
40
40
/**
41
41
* @var Register\Clock
42
42
*/
43
- private $ clock_register ;
43
+ protected $ clock_register ;
44
44
45
45
/**
46
46
* @var Register\SPI
47
47
*/
48
- private $ spi_register ;
48
+ protected $ spi_register ;
49
49
50
50
/**
51
51
* @var Register\Auxiliary
52
52
*/
53
- private $ aux_register ;
53
+ protected $ aux_register ;
54
54
55
55
/**
56
56
* @var EdgeDetector\EdgeDetectorInterface
57
57
*/
58
- private $ edge_detector ;
58
+ protected $ edge_detector ;
59
59
60
60
/**
61
61
* @var Pin[]
Original file line number Diff line number Diff line change 8
8
namespace Calcinai \PHPi \Board ;
9
9
10
10
use Calcinai \PHPi \Board ;
11
+ use React \EventLoop \LoopInterface ;
12
+ use Calcinai \PHPi \Peripheral \Register ;
11
13
12
14
class Mock extends Board {
13
15
16
+ public function __construct (LoopInterface $ loop )
17
+ {
18
+ parent ::__construct ($ loop );
19
+
20
+ $ this ->gpio_register = new Register \Mock ($ this );
21
+ $ this ->spi_register = new Register \Mock ($ this );
22
+ $ this ->pwm_register = new Register \Mock ($ this );
23
+ $ this ->aux_register = new Register \Mock ($ this );
24
+ $ this ->clock_register = new Register \Mock ($ this );
25
+
26
+ }
27
+
14
28
public static function getPeripheralBaseAddress () {
15
29
return 0 ;
16
30
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * @package api
4
+ * @author Michael Calcinai <[email protected] >
5
+ */
6
+
7
+ namespace Calcinai \PHPi \Peripheral \Register ;
8
+ use Calcinai \PHPi \Board \BoardInterface ;
9
+
10
+ /**
11
+ * Register to store and return data, so testing can be done on non-pi systems
12
+ *
13
+ * Class Mock
14
+ * @package Calcinai\PHPi\Peripheral\Register
15
+ */
16
+ class Mock extends AbstractRegister
17
+ {
18
+
19
+ private $ data ;
20
+
21
+ /**
22
+ * Overload the parent constructor so nothing is actually mapped
23
+ *
24
+ * AbstractRegister constructor.
25
+ * @param BoardInterface $board
26
+ */
27
+ /** @noinspection PhpMissingParentConstructorInspection */
28
+ public function __construct (BoardInterface $ board )
29
+ {
30
+ $ this ->data = [];
31
+ }
32
+
33
+ /**
34
+ * @param mixed $offset
35
+ * @return bool
36
+ */
37
+
38
+ public function offsetExists ($ offset )
39
+ {
40
+ return isset ($ this ->data [$ offset ]);
41
+ }
42
+
43
+ public function offsetGet ($ offset )
44
+ {
45
+ return isset ($ this ->data [$ offset ]) ? $ this ->data [$ offset ] : 0 ;
46
+ }
47
+
48
+ public function offsetSet ($ offset , $ value )
49
+ {
50
+ $ this ->data [$ offset ] = $ value ;
51
+ }
52
+
53
+ public function offsetUnset ($ offset )
54
+ {
55
+
56
+ }
57
+
58
+ public static function getOffset ()
59
+ {
60
+ return 0 ;
61
+ }
62
+ }
You can’t perform that action at this time.
0 commit comments