Skip to content

Commit 456fef6

Browse files
committed
Improved raw transition speed
1 parent 706ef8c commit 456fef6

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ $board->getLoop()->run();
7575

7676
GPIO (input) is the default mode of the pin objects. Alternate functions can be accessed by using the ```->setFunction(PinFunction::x)``` method. It is
7777
recommended to use the function names as opposed to `ALT0..5` unless you know exactly what you're doing, as quite a lot are reserved.
78-
A few useful classes are also included for digital interaction. With the default python-mmap, you can expect a raw transition speed of ~15kHz, with the
79-
native extension, it's more like 50kHz on a Pi 3.
78+
A few useful classes are also included for digital interaction. With the default python-mmap, you can expect a raw transition speed of ~20kHz, with the
79+
native extension, it's more like 80kHz on a Pi 3.
8080

8181

8282
### PWM

src/PHPi/Pin.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,28 +209,40 @@ public function assertFunction(array $valid_functions){
209209
}
210210

211211

212+
/**
213+
* Raw pin transition with fast mode, fast mode ignores all checks and event emitters
214+
*
215+
* @param bool $fast_mode
216+
* @return $this
217+
* @throws InvalidPinFunctionException
218+
*/
212219
public function high($fast_mode = false){
213220

214221
if(!$fast_mode){
215222
$this->assertFunction([PinFunction::OUTPUT]);
223+
$this->setInternalLevel(self::LEVEL_HIGH);
216224
}
217225

218-
$this->setInternalLevel(self::LEVEL_HIGH);
219-
220226
list($bank, $mask) = $this->getAddressMask();
221227
$this->gpio_register[Register\GPIO::$GPSET[$bank]] = $mask;
222228

223229
return $this;
224230
}
225231

232+
/**
233+
* Raw pin transition with fast mode, fast mode ignores all checks and event emitters
234+
*
235+
* @param bool $fast_mode
236+
* @return $this
237+
* @throws InvalidPinFunctionException
238+
*/
226239
public function low($fast_mode = false){
227240

228241
if(!$fast_mode){
229242
$this->assertFunction([PinFunction::OUTPUT]);
243+
$this->setInternalLevel(self::LEVEL_LOW);
230244
}
231245

232-
$this->setInternalLevel(self::LEVEL_LOW);
233-
234246
list($bank, $mask) = $this->getAddressMask();
235247
$this->gpio_register[Register\GPIO::$GPCLR[$bank]] = $mask;
236248

0 commit comments

Comments
 (0)