diff --git a/Sources/HTU21D/HTU21D.swift b/Sources/HTU21D/HTU21D.swift index aae5a5b..fa15c0b 100644 --- a/Sources/HTU21D/HTU21D.swift +++ b/Sources/HTU21D/HTU21D.swift @@ -165,9 +165,10 @@ extension HTU21D { } - -public enum HTU21DError: Error { - case readError - case writeError - case crcError -} +public extension HTU21D { + enum HTU21DError: Error { + case readError + case writeError + case crcError + } +} \ No newline at end of file diff --git a/Sources/SGP30/SGP30.swift b/Sources/SGP30/SGP30.swift index 2e5a2a9..e097257 100644 --- a/Sources/SGP30/SGP30.swift +++ b/Sources/SGP30/SGP30.swift @@ -269,12 +269,12 @@ extension SGP30 { } -@_extern(c, "exp2f") -func exp2f(_: Float) -> Float +@_extern(c, "expf") +func expf(_: Float) -> Float extension Float { @_transparent static func exp(_ x: Float) -> Float { - exp2f(x) + expf(x) } } \ No newline at end of file diff --git a/Sources/TCS34725/TCS34725.swift b/Sources/TCS34725/TCS34725.swift index b35394b..e0d5c49 100644 --- a/Sources/TCS34725/TCS34725.swift +++ b/Sources/TCS34725/TCS34725.swift @@ -351,11 +351,13 @@ extension TCS34725 { @_extern(c, "pow") func powf(_: Float, _ : Float) -> Float -extension Float { +private extension Float { @_transparent static func pow(_ x: Float, _ y: Float) -> Float { guard x >= 0 else { return .nan } if x == 0 && y == 0 { return .nan } + let result = powf(x, y) + print("powf(\(x), \(y)) result = \(result)") return powf(x, y) } } \ No newline at end of file diff --git a/Tests/ADT7410Tests/ADT7410Tests.swift b/Tests/ADT7410Tests/ADT7410Tests.swift index a86792a..84e8d67 100644 --- a/Tests/ADT7410Tests/ADT7410Tests.swift +++ b/Tests/ADT7410Tests/ADT7410Tests.swift @@ -6,31 +6,31 @@ import SwiftIO final class ADT7410Tests: XCTestCase { func testToTemp13Bit(){ - let resulution = ADT7410.Resulution.r_13Bit - XCTAssertEqual(-55,ADT7410.toTemp(resulution,[0b1110_0100,0b1000_0000])) - XCTAssertEqual(-50,ADT7410.toTemp(resulution, [0b1110_0111,0b0000_0000])) - XCTAssertEqual(-25,ADT7410.toTemp(resulution, [0b1111_0011,0b1000_0000])) - XCTAssertEqual(-0.0625,ADT7410.toTemp(resulution, [0b1111_1111,0b1111_1000])) - XCTAssertEqual(0,ADT7410.toTemp(resulution, [0b0000_0000,0b0000_0000])) - XCTAssertEqual(0.0625,ADT7410.toTemp(resulution, [0b0000_0000,0b0000_1000])) - XCTAssertEqual(25,ADT7410.toTemp(resulution, [0b0000_1100,0b1000_0000])) - XCTAssertEqual(50,ADT7410.toTemp(resulution, [0b0001_1001,0b0000_0000])) - XCTAssertEqual(125,ADT7410.toTemp(resulution, [0b0011_1110,0b1000_0000])) - XCTAssertEqual(150,ADT7410.toTemp(resulution, [0b0100_1011,0b0000_0000])) + let resolution = ADT7410.Resolution.r_13Bit + XCTAssertEqual(-55,ADT7410.toTemp(resolution,[0b1110_0100,0b1000_0000])) + XCTAssertEqual(-50,ADT7410.toTemp(resolution, [0b1110_0111,0b0000_0000])) + XCTAssertEqual(-25,ADT7410.toTemp(resolution, [0b1111_0011,0b1000_0000])) + XCTAssertEqual(-0.0625,ADT7410.toTemp(resolution, [0b1111_1111,0b1111_1000])) + XCTAssertEqual(0,ADT7410.toTemp(resolution, [0b0000_0000,0b0000_0000])) + XCTAssertEqual(0.0625,ADT7410.toTemp(resolution, [0b0000_0000,0b0000_1000])) + XCTAssertEqual(25,ADT7410.toTemp(resolution, [0b0000_1100,0b1000_0000])) + XCTAssertEqual(50,ADT7410.toTemp(resolution, [0b0001_1001,0b0000_0000])) + XCTAssertEqual(125,ADT7410.toTemp(resolution, [0b0011_1110,0b1000_0000])) + XCTAssertEqual(150,ADT7410.toTemp(resolution, [0b0100_1011,0b0000_0000])) } func testToData13Bit(){ - let resulution = ADT7410.Resulution.r_13Bit - XCTAssertEqual([0b1110_0100,0b1000_0000],ADT7410.toData(resulution,-55)) - XCTAssertEqual([0b1110_0111,0b0000_0000],ADT7410.toData(resulution,-50)) - XCTAssertEqual([0b1111_0011,0b1000_0000],ADT7410.toData(resulution,-25)) - XCTAssertEqual([0b1111_1111,0b1111_1000],ADT7410.toData(resulution,-0.0625)) - XCTAssertEqual([0b0000_0000,0b0000_0000],ADT7410.toData(resulution,0)) - XCTAssertEqual([0b0000_0000,0b0000_1000],ADT7410.toData(resulution,0.0625)) - XCTAssertEqual([0b0000_1100,0b1000_0000],ADT7410.toData(resulution,25)) - XCTAssertEqual([0b0001_1001,0b0000_0000],ADT7410.toData(resulution,50)) - XCTAssertEqual([0b0011_1110,0b1000_0000],ADT7410.toData(resulution,125)) - XCTAssertEqual([0b0100_1011,0b0000_0000],ADT7410.toData(resulution,150)) + let resolution = ADT7410.Resolution.r_13Bit + XCTAssertEqual([0b1110_0100,0b1000_0000],ADT7410.toData(resolution,-55)) + XCTAssertEqual([0b1110_0111,0b0000_0000],ADT7410.toData(resolution,-50)) + XCTAssertEqual([0b1111_0011,0b1000_0000],ADT7410.toData(resolution,-25)) + XCTAssertEqual([0b1111_1111,0b1111_1000],ADT7410.toData(resolution,-0.0625)) + XCTAssertEqual([0b0000_0000,0b0000_0000],ADT7410.toData(resolution,0)) + XCTAssertEqual([0b0000_0000,0b0000_1000],ADT7410.toData(resolution,0.0625)) + XCTAssertEqual([0b0000_1100,0b1000_0000],ADT7410.toData(resolution,25)) + XCTAssertEqual([0b0001_1001,0b0000_0000],ADT7410.toData(resolution,50)) + XCTAssertEqual([0b0011_1110,0b1000_0000],ADT7410.toData(resolution,125)) + XCTAssertEqual([0b0100_1011,0b0000_0000],ADT7410.toData(resolution,150)) } func testDefaultConfiguration(){ @@ -117,11 +117,11 @@ final class ADT7410Tests: XCTestCase { func testConfigurationResolution(){ var config = ADT7410.Configuration() - config.resulution = .r_13Bit + config.resolution = .r_13Bit XCTAssertEqual(0b0, config.getByte()) XCTAssertEqual(config, ADT7410.Configuration(config.getByte())) - config.resulution = .r_16Bit + config.resolution = .r_16Bit XCTAssertEqual(0b1 << 7, config.getByte()) XCTAssertEqual(config, ADT7410.Configuration(config.getByte())) }