-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update structure to fit Swift 5.9 (#18)
* Update structure to fit Swift 5.9 Signed-off-by: Andy Liu <andy@madmachine.io> * Add import dependency Signed-off-by: Andy Liu <andy@madmachine.io> --------- Signed-off-by: Andy Liu <andy@madmachine.io>
- Loading branch information
Showing
243 changed files
with
1,784 additions
and
2,607 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
Examples/SwiftIOPlayground/01LED/LEDBlink/Sources/LEDBlink/LEDBlink.swift
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
Examples/SwiftIOPlayground/01LED/LEDBlink/Sources/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// First import the SwiftIO and MadBoard libraries into the project to use related functionalities. | ||
import SwiftIO | ||
import MadBoard | ||
|
||
// Initialize the specified pin used for digital output. | ||
let led = DigitalOut(Id.D18) | ||
|
||
// The code in the loop will run over and over again. | ||
while true { | ||
//Output high voltage to turn on the LED. | ||
led.write(true) | ||
// Keep the LED on for 1 second. | ||
sleep(ms: 1000) | ||
|
||
// Turn off the LED and then keep that state for 1s. | ||
led.write(false) | ||
sleep(ms: 1000) | ||
} |
11 changes: 0 additions & 11 deletions
11
Examples/SwiftIOPlayground/01LED/LEDBlink/Tests/LEDBlinkTests/LEDBlinkTests.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...iftIOPlayground/01LED/LEDBlinkWithTimer/Sources/LEDBlinkWithTimer/LEDBlinkWithTimer.swift
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
Examples/SwiftIOPlayground/01LED/LEDBlinkWithTimer/Sources/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Import the SwiftIO library to control input and output and the MadBoard to use the id of the pins. | ||
import SwiftIO | ||
import MadBoard | ||
|
||
// Initialize a digital pin for LED module. | ||
let redLed = DigitalOut(Id.D18) | ||
|
||
// Initialize the onboard blue LED. | ||
let blueLed = DigitalOut(Id.BLUE) | ||
|
||
// Initialize a timer for 1500ms. | ||
let timer = Timer(period: 1500) | ||
|
||
// Define a new function used to toggle the LED. | ||
func ToggleLEDSwitch() { | ||
redLed.toggle() | ||
} | ||
|
||
// Set an interrupt to reverse the LED state every time the interrupt occurs. | ||
timer.setInterrupt(ToggleLEDSwitch) | ||
|
||
// Blink onboard blue LED. | ||
while true { | ||
blueLed.high() | ||
sleep(ms: 500) | ||
|
||
blueLed.low() | ||
sleep(ms: 500) | ||
} |
11 changes: 0 additions & 11 deletions
11
...yground/01LED/LEDBlinkWithTimer/Tests/LEDBlinkWithTimerTests/LEDBlinkWithTimerTests.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
Examples/SwiftIOPlayground/01LED/LEDMorseCode/Sources/LEDMorseCode/LEDMorseCode.swift
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
Examples/SwiftIOPlayground/01LED/LEDMorseCode/Sources/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Import the libraries to use all their functionalities. | ||
import SwiftIO | ||
import MadBoard | ||
|
||
// Initialize the digital output pin. | ||
let led = DigitalOut(Id.D18) | ||
|
||
// Define the LED states to represent the letter s and o. | ||
let sSignal = [false, false, false] | ||
let oSignal = [true, true ,true] | ||
|
||
// Set the LED blink rate according to the values in the array. | ||
func send(_ values: [Bool], to light: DigitalOut) { | ||
// The duration of slow flash and quick flash. | ||
let long = 1000 | ||
let short = 500 | ||
|
||
// Iterate all the values in the array. | ||
// If the value is true, the LED will be on for 1s, which is a slow flash. | ||
// And if it’s false, the LED will be on for 0.5s, which is a quick flash. | ||
for value in values { | ||
light.high() | ||
if value { | ||
sleep(ms: long) | ||
} else { | ||
sleep(ms: short) | ||
} | ||
light.low() | ||
sleep(ms: short) | ||
} | ||
} | ||
|
||
// Blink the LED. | ||
// At first, the LED starts 3 fast blink to represent s, then 3 slow blink to represent o, and 3 fast blink again. | ||
// Wait 1s before repeating again. | ||
while true { | ||
send(sSignal, to: led) | ||
send(oSignal, to: led) | ||
send(sSignal, to: led) | ||
sleep(ms: 1000) | ||
} |
11 changes: 0 additions & 11 deletions
11
...ples/SwiftIOPlayground/01LED/LEDMorseCode/Tests/LEDMorseCodeTests/LEDMorseCodeTests.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
Oops, something went wrong.