Skip to content

Commit

Permalink
Moved Controller to AR
Browse files Browse the repository at this point in the history
  • Loading branch information
doHernandezM committed Sep 16, 2021
1 parent 99a1600 commit f1a5158
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 68 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
# SwiftyPi

## OUT OF DATE 9/15/21

This package is heavily based on and would not be possible without [SwiftyGPIO](https://github.com/uraimo/SwiftyGPIO). This is not meant to be a replacement, more like an extra layer to make using Swift with rPi devices such as buttons, relays, LEDs, UART and LCDs easier. Support is currently limited as this is a hobby. Since SwiftyPi is made to work in conjunction with [ApusRupus](https://github.com/doHernandezM/ApusRubus) I have decided against implementing a delegate. You will have to actively poll each device in a loop for state. I may change this to implement the timer better.

## Funtionality options:
## See SwiftyPi.DocC / In source comments


## ~~Funtionality options:
I recommend visiting SwiftyGPIO and getting familiar with this API first. However, the goal to eventually be able to call many devices, so eventually SwiftyDevice is all you need to worry about.

Do this:
~~Do this:
```swift
.package(url: "https://github.com/doHernandezM/SwiftyPi.git", ._exactItem("0.1.30")),
```

### GPIO
* Use this to create a GPIO pin using the SwiftyGPIO pin naming convention, i.e. "P4" for pin 4.
### ~~GPIO
* ~~Use this to create a GPIO pin using the SwiftyGPIO pin naming convention, i.e. "P4" for pin 4.
```swift
public init(gpioPinName: String, theType: SwiftyPiType)
```

### Device actions
* Each device has an action that can be run at a certain time depending on type and protocol. This is a simple block that returns nothing, of the type:
### ~~Device actions
* ~~Each device has an action that can be run at a certain time depending on type and protocol. This is a simple block that returns nothing, of the type:
```swift
public typealias CompletionHandler = () -> Void
```
* To set this action assign a block( () -> Void ) to a device's handler. This block will be called during the device's "action" event.
* ~~To set this action assign a block( () -> Void ) to a device's handler. This block will be called during the device's "action" event.
```swift
public var handler: CompletionHandler? = nil
```
* To set or get a device's state, or pin value, use:
* ~~To set or get a device's state, or pin value, use:
```swift
public var bool: Bool
public var int: Int
Expand Down
57 changes: 0 additions & 57 deletions Sources/SwiftyPi/DeviceController.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/SwiftyPi/Pin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct PinState: DeviceState, Codable {
}
}

//MARK:GPIO
//MARK:Pin
///This is our basic "pin" device.
///
///The best way to use this is to get the ``int``/``bool``/``mode``.
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftyPi/SwiftyPiDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import SwiftyGPIO
public enum DeviceProtocol: String {
case GPIO, PWM, MC3008, PCA9685, UART, I2C, SPI
}

public enum Device: String {
case DigitalPin,AnalogPin, PWMPin
}
Expand Down

0 comments on commit f1a5158

Please sign in to comment.