Skip to content

Commit

Permalink
Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinichiro Oba committed Sep 10, 2018
1 parent 7eed2ef commit e9e5537
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
14 changes: 7 additions & 7 deletions Sources/BoostBLEKit/IOType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ extension IOType {
case .piezoSpeaker:
return nil
case .rgbLight:
return 0
return 0 // Not working on Boost and Powered Up
case .tiltSensor:
return 1
return 1 // 0: Tilt (x,y), 1: 2D Orientation, 2: Impact Count?? (3 bytes) 3: Tilt (x,y,z)
case .motionSensor:
return 0
return 0 // 0: Distance, 1: Count, 2: ?? (6 bytes)
case .colorAndDistanceSensor:
return 8
return 8 // 8: Color, Distance, and Ambient Light Level
case .interactiveMotor:
return 2
return 2 // 0: ??, 1: Speed, 2: Position
case .builtInMotor:
return 2
return 2 // 0: ??, 1: Speed, 2: Position
case .builtInTiltSensor:
return 1
return 2 // 0: Tilt (x,y), 1: 2D Orientation, 2: 3D Orientation, 3: Impact Count, 4: Tilt (x,y,z)
}
}
}
Expand Down
15 changes: 11 additions & 4 deletions Sources/BoostBLEKit/Notification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,19 @@ extension Notification: CustomStringConvertible {
public var description: String {
switch self {
case .connected(let portId, let ioType):
return "Connected \(ioType) into \(portId)"
return "Connected \(ioType) into Port \(portId.hexString)"
case .disconnected(let portId):
return "Disconnected an I/O from \(portId)"
return "Disconnected an I/O from Port \(portId.hexString)"
case .sensorValue(let portId, let value):
let hex = value.map { String(format: "%02x", $0) }.joined(separator: " ")
return "Sensor value \(hex) from \(portId)"
let hex = value.map { $0.hexString }.joined(separator: " ")
return "Sensor value [\(hex)] from Port \(portId.hexString)"
}
}
}

private extension UInt8 {

var hexString: String {
return String(format: "%02x", self)
}
}

0 comments on commit e9e5537

Please sign in to comment.