Skip to content

Commit cff8217

Browse files
authored
Merge pull request #5 from madmachineio/correct-errors
Modify IS31FL3731 and VEML6040
2 parents 3b6cd0e + da0e369 commit cff8217

File tree

26 files changed

+640
-106
lines changed

26 files changed

+640
-106
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
DerivedData/
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This is a MadMachine project file in TOML format
2+
# This file holds those parameters that could not be managed by SwiftPM
3+
# Edit this file would change the behavior of the building/downloading procedure
4+
# Those project files in the dependent libraries would be IGNORED
5+
6+
# Specify the board name below
7+
# There are "SwiftIOBoard" and "SwiftIOFeather" now
8+
board = "SwiftIOFeather"
9+
10+
# Specifiy the target triple below
11+
# There are "thumbv7em-unknown-none-eabi" and "thumbv7em-unknown-none-eabihf" now
12+
# If your code use significant floating-point calculation,
13+
# plz set it to "thumbv7em-unknown-none-eabihf"
14+
triple = "thumbv7em-unknown-none-eabi"
15+
16+
# Reserved for future use
17+
version = 1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// swift-tools-version:5.3
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
import PackageDescription
4+
let package = Package(
5+
name: "BreathingLED",
6+
dependencies: [
7+
// Dependencies declare other packages that this package depends on.
8+
.package(url: "https://github.com/madmachineio/SwiftIO.git", .upToNextMajor(from: "0.0.1")),
9+
.package(url: "https://github.com/madmachineio/MadBoards.git", .upToNextMajor(from: "0.0.1")),
10+
.package(url: "https://github.com/madmachineio/MadDrivers.git", .upToNextMajor(from: "0.0.1")),
11+
],
12+
targets: [
13+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
14+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
15+
.target(
16+
name: "BreathingLED",
17+
dependencies: [
18+
"SwiftIO",
19+
"MadBoards",
20+
// use specific library would speed up the compile procedure
21+
.product(name: "IS31FL3731", package: "MadDrivers")
22+
]),
23+
.testTarget(
24+
name: "BreathingLEDTests",
25+
dependencies: ["BreathingLED"]),
26+
]
27+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# BreathingLED
2+
3+
A description of this package.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import SwiftIO
2+
import MadBoard
3+
import IS31FL3731
4+
5+
let i2c = I2C(Id.I2C0)
6+
let led = IS31FL3731(i2c: i2c)
7+
8+
// Set the brightness of all LEDs to 50.
9+
led.fill(50)
10+
led.startBreath()
11+
// Display the breathing effect endlessly.
12+
led.setAutoPlay(1)
13+
14+
while true {
15+
sleep(ms: 1000)
16+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import XCTest
2+
import class Foundation.Bundle
3+
4+
final class BreathingLEDTests: XCTestCase {
5+
func testExample() throws {
6+
// This is an example of a functional test case.
7+
// Use XCTAssert and related functions to verify your tests produce the correct
8+
// results.
9+
10+
// Some of the APIs that we use below are available in macOS 10.13 and above.
11+
guard #available(macOS 10.13, *) else {
12+
return
13+
}
14+
15+
// Mac Catalyst won't have `Process`, but it is supported for executables.
16+
#if !targetEnvironment(macCatalyst)
17+
18+
let fooBinary = productsDirectory.appendingPathComponent("BreathingLED")
19+
20+
let process = Process()
21+
process.executableURL = fooBinary
22+
23+
let pipe = Pipe()
24+
process.standardOutput = pipe
25+
26+
try process.run()
27+
process.waitUntilExit()
28+
29+
let data = pipe.fileHandleForReading.readDataToEndOfFile()
30+
let output = String(data: data, encoding: .utf8)
31+
32+
XCTAssertEqual(output, "Hello, world!\n")
33+
#endif
34+
}
35+
36+
/// Returns path to the built products directory.
37+
var productsDirectory: URL {
38+
#if os(macOS)
39+
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
40+
return bundle.bundleURL.deletingLastPathComponent()
41+
}
42+
fatalError("couldn't find the products directory")
43+
#else
44+
return Bundle.main.bundleURL
45+
#endif
46+
}
47+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
DerivedData/
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This is a MadMachine project file in TOML format
2+
# This file holds those parameters that could not be managed by SwiftPM
3+
# Edit this file would change the behavior of the building/downloading procedure
4+
# Those project files in the dependent libraries would be IGNORED
5+
6+
# Specify the board name below
7+
# There are "SwiftIOBoard" and "SwiftIOFeather" now
8+
board = "SwiftIOFeather"
9+
10+
# Specifiy the target triple below
11+
# There are "thumbv7em-unknown-none-eabi" and "thumbv7em-unknown-none-eabihf" now
12+
# If your code use significant floating-point calculation,
13+
# plz set it to "thumbv7em-unknown-none-eabihf"
14+
triple = "thumbv7em-unknown-none-eabi"
15+
16+
# Reserved for future use
17+
version = 1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// swift-tools-version:5.3
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
import PackageDescription
4+
let package = Package(
5+
name: "DrawPixels",
6+
dependencies: [
7+
// Dependencies declare other packages that this package depends on.
8+
.package(url: "https://github.com/madmachineio/SwiftIO.git", .upToNextMajor(from: "0.0.1")),
9+
.package(url: "https://github.com/madmachineio/MadBoards.git", .upToNextMajor(from: "0.0.1")),
10+
.package(url: "https://github.com/madmachineio/MadDrivers.git", .upToNextMajor(from: "0.0.1")),
11+
],
12+
targets: [
13+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
14+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
15+
.target(
16+
name: "DrawPixels",
17+
dependencies: [
18+
"SwiftIO",
19+
"MadBoards",
20+
// use specific library would speed up the compile procedure
21+
.product(name: "IS31FL3731", package: "MadDrivers")
22+
]),
23+
.testTarget(
24+
name: "DrawPixelsTests",
25+
dependencies: ["DrawPixels"]),
26+
]
27+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# DrawPixels
2+
3+
A description of this package.

0 commit comments

Comments
 (0)