From dcf5e351c609b2cbc47f3e95d5724828b77b660f Mon Sep 17 00:00:00 2001 From: Ines Zhou <72301128+Ines333@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:27:43 +0800 Subject: [PATCH] Fix typo (#67) --- Sources/ADT7410/ADT7410.swift | 50 ++++++++++++++--------------- Sources/ADT7410/Configuration.swift | 12 +++---- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Sources/ADT7410/ADT7410.swift b/Sources/ADT7410/ADT7410.swift index 860d6d7..b879e9a 100644 --- a/Sources/ADT7410/ADT7410.swift +++ b/Sources/ADT7410/ADT7410.swift @@ -38,11 +38,11 @@ public class ADT7410{ let operationMode = configuration.operationMode if(operationMode == .ONE_SHOT || operationMode == .SHUTDOWN){ - set0perationMode(.ONE_SHOT) + setOperationMode(.ONE_SHOT) sleep(ms: 240) } - return Self.toTemp(configuration.resulution,read(.TEMP_MSB,2)) + return Self.toTemp(configuration.resolution,read(.TEMP_MSB,2)) } /// Read the status. @@ -51,21 +51,21 @@ public class ADT7410{ Status(read(.STATUS)) } - /// Read the temparture range. + /// Read the temperature range. /// /// If the temperature falls below the min value or rises above the max value, the INT pin is triggered. Default temperature range is 10°C to 64°C. /// - Returns: Temperture range of the INT Pin. public func readIntTemperatureRange() -> (minTemp: Double,maxTemp: Double) { - ( Self.toTemp(configuration.resulution, read(.SETPOINT_TEMP_LOW_MSB,2)), - Self.toTemp(configuration.resulution, read(.SETPOINT_TEMP_HIGH_MSB,2))) + ( Self.toTemp(configuration.resolution, read(.SETPOINT_TEMP_LOW_MSB,2)), + Self.toTemp(configuration.resolution, read(.SETPOINT_TEMP_HIGH_MSB,2))) } - /// Read the critical temparture. + /// Read the critical temperature. /// - /// If the temperature rises above the value, the CT pin is triggered. Default critical temparture is 147°C. - /// - Returns: Critical temparture for the CT pin. + /// If the temperature rises above the value, the CT pin is triggered. Default critical temperature is 147°C. + /// - Returns: Critical temperature for the CT pin. public func readCTCriticalTemperature() -> Double{ - Self.toTemp(configuration.resulution,read(.SETPOINT_TEMP_CRIT_MSB,2)) + Self.toTemp(configuration.resolution,read(.SETPOINT_TEMP_CRIT_MSB,2)) } /// Read the temperature hysteresis value for the THIGH, TLOW, and TCRIT temperature limits. @@ -93,7 +93,7 @@ public class ADT7410{ /// Set the operation mode. /// - Parameter mode: Operation mode - public func set0perationMode(_ mode: OperationMode){ + public func setOperationMode(_ mode: OperationMode){ configuration.operationMode = mode write([configuration.getByte()], to: .CONFIG) } @@ -126,31 +126,31 @@ public class ADT7410{ write([configuration.getByte()],to: .CONFIG) } - /// Set the temparture range. + /// Set the temperature range. /// /// If the temperature falls below the min value or rises above the max value, the INT pin is triggered. Default temperature range is 10°C to 64°C. /// - Parameters: /// - minTemp: Lower limit of the temperature range. /// - maxTemp: Upper limit of the temperature range. public func setIntTemperatureRange(min minTemp: Double, max maxTemp: Double ){ - write(Self.toData(configuration.resulution, minTemp), to: .SETPOINT_TEMP_LOW_MSB) - write(Self.toData(configuration.resulution, maxTemp), to: .SETPOINT_TEMP_HIGH_MSB) + write(Self.toData(configuration.resolution, minTemp), to: .SETPOINT_TEMP_LOW_MSB) + write(Self.toData(configuration.resolution, maxTemp), to: .SETPOINT_TEMP_HIGH_MSB) } - /// Set the critical temparture. + /// Set the critical temperature. /// - /// If the temperature rises above the value, the CT pin is triggered. Default critical temparture is 147°C. - /// - Parameter tempature: Critical temparture for the CT pin. - public func setCTCriticalTemperature(tempature: Double){ - write(Self.toData(configuration.resulution,tempature), to: .SETPOINT_TEMP_CRIT_MSB) + /// If the temperature rises above the value, the CT pin is triggered. Default critical temperature is 147°C. + /// - Parameter temperature: Critical temperature for the CT pin. + public func setCTCriticalTemperature(temperature: Double){ + write(Self.toData(configuration.resolution,temperature), to: .SETPOINT_TEMP_CRIT_MSB) } /// Set the temperature hysteresis value for the THIGH, TLOW, and TCRIT temperature limits. /// /// The value is subtracted from the THIGH and TCRIT values and added to the TLOW value to implement hysteresis. allowed values are from 0°C-15°C and default temperature hyst is 5°C. - /// - Parameter tempature: Temperature hysteresis value. - public func setHyst(tempature: UInt8){ - write([tempature], to: .SETPOINT_TEMP_HYST) + /// - Parameter temperature: Temperature hysteresis value. + public func setHyst(temperature: UInt8){ + write([temperature], to: .SETPOINT_TEMP_HYST) } /// Set the configuration. @@ -185,22 +185,22 @@ extension ADT7410 { i2c.write([registerAddresse.rawValue]+data, to: serialBusAddress.rawValue) } - static func toTemp(_ resulution: ADT7410.Resulution, _ data: [UInt8]) -> Double{ + static func toTemp(_ resolution: ADT7410.Resolution, _ data: [UInt8]) -> Double{ let dataInt16 = (Int16(data[0]) << 8) | Int16(data[1]) let isPositiveTemp = dataInt16 >= 0 - switch(resulution, isPositiveTemp){ + switch(resolution, isPositiveTemp){ case (.r_13Bit,true): return Double(dataInt16 >> 3) / 16 case (.r_13Bit,false): return Double(dataInt16 >> 3 | 0b1 << 15) / 16 case (.r_16Bit,_ ): return Double(dataInt16) / 128 } } - static func toData(_ resulution: ADT7410.Resulution, _ temp: Double) -> [UInt8]{ + static func toData(_ resolution: ADT7410.Resolution, _ temp: Double) -> [UInt8]{ let isPositiveTemp = temp >= 0 var data:Int16 = 0 - switch(resulution, isPositiveTemp){ + switch(resolution, isPositiveTemp){ case (.r_13Bit,true): data = Int16(temp * 16) << 3 case (.r_13Bit,false): data = (Int16(temp * 16) << 3) | 0b1 << 15 case (.r_16Bit,_): data = Int16(temp * 128.0) diff --git a/Sources/ADT7410/Configuration.swift b/Sources/ADT7410/Configuration.swift index 4bb30ac..7bec14f 100644 --- a/Sources/ADT7410/Configuration.swift +++ b/Sources/ADT7410/Configuration.swift @@ -35,8 +35,8 @@ public extension ADT7410 { public var temperatureDetectionMode: TemperatureDetectionMode = .COMPARATOR_MODE /// The operation mode describes in which cycle the temperature is measured by the chip. public var operationMode: OperationMode = .CONTINUOS - /// The sensor store the temperature in 13 bit or 16 bit resulution. - public var resulution: Resulution = .r_13Bit + /// The sensor store the temperature in 13 bit or 16 bit resolution. + public var resolution: Resolution = .r_13Bit /// Initialize default configuration of a ADT7410. public init(){} @@ -51,7 +51,7 @@ public extension ADT7410 { intOutputPolarity = .init(rawValue: configByte & 0b1000)! temperatureDetectionMode = .init(rawValue: configByte & 0b10000)! operationMode = .init(rawValue: configByte & 0b1100000)! - resulution = .init(rawValue: configByte & 0b10000000)! + resolution = .init(rawValue: configByte & 0b10000000)! } func getByte() -> UInt8{ @@ -60,7 +60,7 @@ public extension ADT7410 { intOutputPolarity.rawValue | temperatureDetectionMode.rawValue | operationMode.rawValue | - resulution.rawValue ) + resolution.rawValue ) } } @@ -110,8 +110,8 @@ public extension ADT7410 { case SHUTDOWN = 0b1100000 } - /// The sensor store the temperature in 13 bit or 16 bit resulution. - enum Resulution: UInt8{ + /// The sensor store the temperature in 13 bit or 16 bit resolution. + enum Resolution: UInt8{ /// Sign bit + 12 bits gives a temperature resolution of 0.0625°C. case r_13Bit = 0b0