File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ This makes it easier to use LEDs with Swift.
55
66Here is a small example that will turn on an LED that is connected to GPIO pin 17 on a Raspberry Pi 3.
77```
8+ let led = LED(gpioPin: .P17)
9+ led.value = 1
10+ ```
11+
12+ Here is a more verbose example, that is equivalent to the first example:
13+ ```
814let gpios = SwiftyGPIO.GPIOs(for:.RaspberryPi3)
915let led = LED(gpioPin: .P17, swiftyGPIOs: gpios)
1016led.value = 1
Original file line number Diff line number Diff line change @@ -26,11 +26,26 @@ public class LED {
2626 }
2727 }
2828
29- public convenience init ( gpioPin: GPIOName , forBoard board: SupportedBoard ) {
29+
30+ /**
31+ Initializes a LED, the easy way.
32+
33+ - Parameters:
34+ - gpioPin: The pin that LED is connected to. Use a GPIOName type. Ex: .P17 for GPIO pin 17.
35+ - board: The board that is supported. By default, it is a .RaspberryPi3.
36+ */
37+ public convenience init ( gpioPin: GPIOName , forBoard board: SupportedBoard = . RaspberryPi3) {
3038 let swiftyGPIOs = SwiftyGPIO . GPIOs ( for: board)
3139 self . init ( gpioPin: gpioPin, swiftyGPIOs: swiftyGPIOs)
3240 }
33-
41+
42+ /**
43+ Initializes a LED.
44+
45+ - Parameters:
46+ - gpioPin: The pin that LED is connected to. Use a GPIOName type. Ex: .P17 for GPIO pin 17.
47+ - swiftyGPIOs: A dictionary created by SwiftyGPIO.GPIOs(for: .SupportedBoard).
48+ */
3449 public init ( gpioPin: GPIOName , swiftyGPIOs: [ GPIOName : GPIO ] ) {
3550 self . gpioPin = gpioPin
3651
Original file line number Diff line number Diff line change @@ -57,6 +57,15 @@ class LEDTests: XCTestCase {
5757 func testSimplerConstructor( ) {
5858 let led = LED ( gpioPin: . P17, forBoard: . RaspberryPi3)
5959 XCTAssertTrue ( led. isOff ( ) )
60+ XCTAssertEqual ( . P17, led. gpioPin)
61+ XCTAssertNotNil ( led. gpio)
62+ }
63+
64+ func testSimplerConstructorWithDefaultRaspberryPi3Pins( ) {
65+ let led = LED ( gpioPin: . P17)
66+ XCTAssertTrue ( led. isOff ( ) )
67+ XCTAssertEqual ( . P17, led. gpioPin)
68+ XCTAssertNotNil ( led. gpio)
6069 }
6170
6271 static var allTests = [
You can’t perform that action at this time.
0 commit comments