File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
3
+ ## [ master] - Unreleased
4
+
5
+ ### Changed
6
+
7
+ - Add support for ` active_low ` configuration.
8
+
3
9
## [ 0.5.1] - 2016-06-17
4
10
5
11
### Changed
148
154
- Initial version of the library with basic functionality
149
155
- Support for ` export ` /` unexport ` /` get_value ` /` set_value ` /` set_direction `
150
156
151
- [ 0.5.1 ] : https://github.com/posborne/rust-sysfs-gpio/compare/0.5.0...0.5.1`
157
+ [ master ] : https://github.com/posborne/rust-sysfs-gpio/compare/0.5.1...master
158
+ [ 0.5.1 ] : https://github.com/posborne/rust-sysfs-gpio/compare/0.5.0...0.5.1
152
159
[ 0.5.0 ] : https://github.com/posborne/rust-sysfs-gpio/compare/0.4.4...0.5.0
153
160
[ 0.4.4 ] : https://github.com/posborne/rust-sysfs-gpio/compare/0.4.3...0.4.4
154
161
[ 0.4.3 ] : https://github.com/posborne/rust-sysfs-gpio/compare/0.4.2...0.4.3
Original file line number Diff line number Diff line change @@ -407,6 +407,34 @@ impl Pin {
407
407
Ok ( ( ) )
408
408
}
409
409
410
+ /// Get polarity of the Pin (`true` is active low)
411
+ pub fn get_active_low ( & self ) -> Result < bool > {
412
+ match self . read_from_device_file ( "active_low" ) {
413
+ Ok ( s) => {
414
+ match s. trim ( ) {
415
+ "1" => Ok ( true ) ,
416
+ "0" => Ok ( false ) ,
417
+ other => Err ( Error :: Unexpected ( format ! ( "active_low file contents {}" , other) ) ) ,
418
+ }
419
+ }
420
+ Err ( e) => Err ( :: std:: convert:: From :: from ( e) ) ,
421
+ }
422
+ }
423
+
424
+ /// Set the polarity of the Pin (`true` is active low)
425
+ ///
426
+ /// This will affect "rising" and "falling" edge triggered
427
+ /// configuration.
428
+ pub fn set_active_low ( & self , active_low : bool ) -> Result < ( ) > {
429
+ self . write_to_device_file ( "active_low" ,
430
+ match active_low {
431
+ true => "1" ,
432
+ false => "0" ,
433
+ } ) ?;
434
+
435
+ Ok ( ( ) )
436
+ }
437
+
410
438
/// Get a PinPoller object for this pin
411
439
///
412
440
/// This pin poller object will register an interrupt with the
You can’t perform that action at this time.
0 commit comments