Skip to content

Commit a44234f

Browse files
committed
Code formatting
1 parent 9200400 commit a44234f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+618
-412
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.idea/
33

44
composer.lock
5+
composer.phar
56
.DS_Store

src/PHPi/Board.php

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
use Calcinai\PHPi\Peripheral\SPI;
1616
use Calcinai\PHPi\Pin;
1717
use Calcinai\PHPi\Pin\EdgeDetector;
18-
1918
use React\EventLoop\LoopInterface;
2019

21-
abstract class Board implements BoardInterface {
20+
abstract class Board implements BoardInterface
21+
{
2222

2323
/**
2424
* @var \React\EventLoop\LibEvLoop|LoopInterface
@@ -83,25 +83,29 @@ abstract class Board implements BoardInterface {
8383
private $i2cs;
8484

8585

86-
public function __construct(LoopInterface $loop) {
86+
public function __construct(LoopInterface $loop)
87+
{
8788
$this->loop = $loop;
8889
}
8990

90-
public function __destruct() {
91+
public function __destruct()
92+
{
9193
Pin\SysFS::cleanup();
9294
}
9395

94-
public function getLoop(){
96+
public function getLoop()
97+
{
9598
return $this->loop;
9699
}
97100

98101
/**
99102
* @param $pin_number
100103
* @return Pin
101104
*/
102-
public function getPin($pin_number){
105+
public function getPin($pin_number)
106+
{
103107

104-
if(!isset($this->pins[$pin_number])){
108+
if (!isset($this->pins[$pin_number])) {
105109
$this->pins[$pin_number] = new Pin($this, $pin_number);
106110
}
107111

@@ -112,8 +116,9 @@ public function getPin($pin_number){
112116
* @param $pwm_number
113117
* @return PWM
114118
*/
115-
public function getPWM($pwm_number){
116-
if(!isset($this->pwms[$pwm_number])){
119+
public function getPWM($pwm_number)
120+
{
121+
if (!isset($this->pwms[$pwm_number])) {
117122
$this->pwms[$pwm_number] = new PWM($this, $pwm_number);
118123
}
119124

@@ -124,8 +129,9 @@ public function getPWM($pwm_number){
124129
* @param $clock_number
125130
* @return Clock
126131
*/
127-
public function getClock($clock_number){
128-
if(!isset($this->clocks[$clock_number])){
132+
public function getClock($clock_number)
133+
{
134+
if (!isset($this->clocks[$clock_number])) {
129135
$this->clocks[$clock_number] = new Clock($this, $clock_number);
130136
}
131137

@@ -136,8 +142,9 @@ public function getClock($clock_number){
136142
* @param $spi_number
137143
* @return SPI
138144
*/
139-
public function getSPI($spi_number){
140-
if(!isset($this->spis[$spi_number])){
145+
public function getSPI($spi_number)
146+
{
147+
if (!isset($this->spis[$spi_number])) {
141148
$this->spis[$spi_number] = new SPI($this, $spi_number);
142149
}
143150

@@ -148,8 +155,9 @@ public function getSPI($spi_number){
148155
* @param $i2c_number
149156
* @return SPI
150157
*/
151-
public function getI2C($i2c_number){
152-
if(!isset($this->i2cs[$i2c_number])){
158+
public function getI2C($i2c_number)
159+
{
160+
if (!isset($this->i2cs[$i2c_number])) {
153161
$this->i2cs[$i2c_number] = new I2C($this, $i2c_number);
154162
}
155163

@@ -159,8 +167,9 @@ public function getI2C($i2c_number){
159167
/**
160168
* @return Register\GPIO
161169
*/
162-
public function getGPIORegister() {
163-
if(!isset($this->gpio_register)){
170+
public function getGPIORegister()
171+
{
172+
if (!isset($this->gpio_register)) {
164173
$this->gpio_register = new Register\GPIO($this);
165174
}
166175

@@ -170,8 +179,9 @@ public function getGPIORegister() {
170179
/**
171180
* @return Register\PWM
172181
*/
173-
public function getPWMRegister() {
174-
if(!isset($this->pwm_register)){
182+
public function getPWMRegister()
183+
{
184+
if (!isset($this->pwm_register)) {
175185
$this->pwm_register = new Register\PWM($this);
176186
}
177187

@@ -181,8 +191,9 @@ public function getPWMRegister() {
181191
/**
182192
* @return Register\Clock
183193
*/
184-
public function getClockRegister() {
185-
if(!isset($this->clock_register)){
194+
public function getClockRegister()
195+
{
196+
if (!isset($this->clock_register)) {
186197
$this->clock_register = new Register\Clock($this);
187198
}
188199

@@ -192,8 +203,9 @@ public function getClockRegister() {
192203
/**
193204
* @return Register\Auxiliary
194205
*/
195-
public function getAuxRegister() {
196-
if(!isset($this->aux_register)){
206+
public function getAuxRegister()
207+
{
208+
if (!isset($this->aux_register)) {
197209
$this->aux_register = new Register\Auxiliary($this);
198210
}
199211

@@ -203,18 +215,19 @@ public function getAuxRegister() {
203215
/**
204216
* @return Register\SPI
205217
*/
206-
public function getSPIRegister() {
207-
if(!isset($this->spi_register)){
218+
public function getSPIRegister()
219+
{
220+
if (!isset($this->spi_register)) {
208221
$this->spi_register = new Register\SPI($this);
209222
}
210223

211224
return $this->spi_register;
212225
}
213226

214227

215-
216-
public function getEdgeDetector(){
217-
if(!isset($this->edge_detector)){
228+
public function getEdgeDetector()
229+
{
230+
if (!isset($this->edge_detector)) {
218231
$this->edge_detector = EdgeDetector\Factory::create($this);
219232
}
220233
return $this->edge_detector;
@@ -223,7 +236,8 @@ public function getEdgeDetector(){
223236
/**
224237
* Should be overloaded by frature trait
225238
*/
226-
public function getPhysicalPins() {
239+
public function getPhysicalPins()
240+
{
227241
return [];
228242
}
229243

@@ -233,23 +247,24 @@ public function getPhysicalPins() {
233247
*
234248
* @return \stdClass
235249
*/
236-
public static function getMeta(){
250+
public static function getMeta()
251+
{
237252

238253
$meta = new \stdClass();
239254

240255
//Get a whole lot of stuff - parsing them is the same.
241-
$info = file_get_contents('/proc/cpuinfo').`lscpu`;
256+
$info = file_get_contents('/proc/cpuinfo') . `lscpu`;
242257

243258
$meta->serial = 'unknown';
244259
$meta->speed = 0;
245260
$meta->cpu = 'unknown';
246261
$meta->num_cores = 0;
247262

248-
foreach(explode("\n", $info) as $line) {
263+
foreach (explode("\n", $info) as $line) {
249264
//null,null avoid undefined offset.
250265
list($tag, $value) = explode(':', $line, 2) + [null, null];
251266

252-
switch(strtolower(trim($tag))){
267+
switch (strtolower(trim($tag))) {
253268
case 'revision':
254269
$meta->revision = trim($value);
255270
break;

src/PHPi/Board/BoardInterface.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
use React\EventLoop\LoopInterface;
1111

12-
interface BoardInterface {
12+
interface BoardInterface
13+
{
1314
public static function getPeripheralBaseAddress();
15+
1416
public static function getPinFunctionMatrix();
17+
1518
public static function getBoardName();
1619

1720
/**

src/PHPi/Board/ComputeModule.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
* @author Michael Calcinai <[email protected]>
66
*/
77

8-
namespace Calcinai\PHPi\Board;
8+
namespace Calcinai\PHPi\Board;
99

1010
use Calcinai\PHPi\Board;
1111
use Calcinai\PHPi\Board\Feature;
1212

13-
class ComputeModule extends Board {
13+
class ComputeModule extends Board
14+
{
1415

1516
use Feature\SoC\BCM2835;
1617

17-
public static function getBoardName() {
18+
public static function getBoardName()
19+
{
1820
return 'Compute Module';
1921
}
2022
}

src/PHPi/Board/Feature/Ethernet.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Calcinai\PHPi\Board\Feature;
99

10-
trait Ethernet {
10+
trait Ethernet
11+
{
1112

1213
}

src/PHPi/Board/Feature/HDMI.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Calcinai\PHPi\Board\Feature;
99

10-
trait HDMI {
10+
trait HDMI
11+
{
1112

1213
}

src/PHPi/Board/Feature/Header/J8.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
*/
77
namespace Calcinai\PHPi\Board\Feature\Header;
88

9-
trait J8 {
9+
trait J8
10+
{
1011

11-
public function getPhysicalPins(){
12+
public function getPhysicalPins()
13+
{
1214
return [
1315
'J8' => [
1416
//Indexed from real numbers (header starts numbering at 1)

src/PHPi/Board/Feature/Header/P1.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
*/
77
namespace Calcinai\PHPi\Board\Feature\Header;
88

9-
trait P1 {
9+
trait P1
10+
{
1011

11-
public function getPhysicalPins(){
12+
public function getPhysicalPins()
13+
{
1214
return [
1315
'P1' => [
1416
//Indexed from real numbers (header starts numbering at 1)

src/PHPi/Board/Feature/Header/P5.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
*/
77
namespace Calcinai\PHPi\Board\Feature\Header;
88

9-
trait P5 {
9+
trait P5
10+
{
1011

11-
public function getPhysicalPins(){
12+
public function getPhysicalPins()
13+
{
1214
return [
1315
'P5' => [
1416
//Indexed from real numbers (header starts numbering at 1)

src/PHPi/Board/Feature/Header/PhysicalPin.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
namespace Calcinai\PHPi\Board\Feature\Header;
88

99

10-
class PhysicalPin {
10+
class PhysicalPin
11+
{
1112

1213
const SUPPLY_3V3 = '3v3';
1314
const SUPPLY_5V = '5v';
@@ -27,7 +28,8 @@ class PhysicalPin {
2728
*/
2829
public $gpio_number;
2930

30-
public function __construct($physical_number, $type, $gpio_number = null) {
31+
public function __construct($physical_number, $type, $gpio_number = null)
32+
{
3133

3234
$this->physical_number = $physical_number;
3335
$this->type = $type;

src/PHPi/Board/Feature/SoC/BCM2835.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@
66

77
namespace Calcinai\PHPi\Board\Feature\SoC;
88

9-
use Calcinai\PHPi\Pin\PinFunction AS PF;
9+
use Calcinai\PHPi\Pin\PinFunction as PF;
1010

11-
trait BCM2835 {
12-
public static function getPinFunctionMatrix(){
11+
trait BCM2835
12+
{
13+
public static function getPinFunctionMatrix()
14+
{
1315
return [
14-
0 => [PF::SDA0 => PF::ALT0],
15-
1 => [PF::SCL0 => PF::ALT0],
16-
2 => [PF::SDA1 => PF::ALT0],
17-
3 => [PF::SCL1 => PF::ALT0],
18-
4 => [PF::GPCLK0 => PF::ALT0, PF::ARM_TDI => PF::ALT5],
19-
5 => [PF::GPCLK1 => PF::ALT0, PF::ARM_TDO => PF::ALT5],
20-
6 => [PF::GPCLK2 => PF::ALT0, PF::ARM_RTCK => PF::ALT5],
21-
7 => [PF::SPI0_CE1_N => PF::ALT0],
22-
8 => [PF::SPI0_CE0_N => PF::ALT0],
23-
9 => [PF::SPI0_MISO => PF::ALT0],
16+
0 => [PF::SDA0 => PF::ALT0],
17+
1 => [PF::SCL0 => PF::ALT0],
18+
2 => [PF::SDA1 => PF::ALT0],
19+
3 => [PF::SCL1 => PF::ALT0],
20+
4 => [PF::GPCLK0 => PF::ALT0, PF::ARM_TDI => PF::ALT5],
21+
5 => [PF::GPCLK1 => PF::ALT0, PF::ARM_TDO => PF::ALT5],
22+
6 => [PF::GPCLK2 => PF::ALT0, PF::ARM_RTCK => PF::ALT5],
23+
7 => [PF::SPI0_CE1_N => PF::ALT0],
24+
8 => [PF::SPI0_CE0_N => PF::ALT0],
25+
9 => [PF::SPI0_MISO => PF::ALT0],
2426
10 => [PF::SPI0_MOSI => PF::ALT0],
2527
11 => [PF::SPI0_SCLK => PF::ALT0],
2628
12 => [PF::PWM0 => PF::ALT0, PF::ARM_TMS => PF::ALT5],
@@ -68,7 +70,8 @@ public static function getPinFunctionMatrix(){
6870
];
6971
}
7072

71-
public static function getPeripheralBaseAddress(){
73+
public static function getPeripheralBaseAddress()
74+
{
7275
return 0x20000000;
7376
}
7477
}

src/PHPi/Board/Feature/SoC/BCM2836.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
namespace Calcinai\PHPi\Board\Feature\SoC;
88

9-
trait BCM2836 {
9+
trait BCM2836
10+
{
1011
//From what I understand there's not a lot of difference between the SoC except the CPU
1112
use BCM2835;
1213
}

0 commit comments

Comments
 (0)