File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
Sources/DataDecoder/Types Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,27 @@ public struct ANTToggleByte {
3030 public var pageNumber : UInt8
3131 public var toggle : Bool
3232
33+ public var uint8Value : UInt8 {
34+ var value : UInt8 = pageNumber
35+ value |= UInt8 ( toggle == true ? 1 : 0 ) << 7
36+
37+ return UInt8 ( value)
38+ }
39+
3340 public init ( _ value: UInt8 ) {
3441 self . pageNumber = ( value & 0x7F )
3542 self . toggle = ( ( value >> 7 ) & 0x7F ) . boolValue
3643 }
44+
45+ public init ( pageNumber: UInt8 , toggled: Bool ) {
46+ self . pageNumber = pageNumber
47+ self . toggle = toggled
48+ }
3749}
3850
3951
4052internal extension UInt8 {
53+
4154 var boolValue : Bool {
4255 switch self {
4356 case 0x01 :
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ extension Nibble: Equatable {
5151 }
5252}
5353
54+ extension Nibble : Hashable {
55+
56+ public var hashValue : Int {
57+ return uint8Value. hashValue
58+ }
59+ }
60+
5461
5562///MARK: - UInt8 Extension
5663public extension UInt8 {
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ class DataDecoderTests: XCTestCase {
9797 ( " testUInt24 " , testUInt24) ,
9898 ( " testUInt48 " , testUInt48) ,
9999 ( " testIPAddress " , testIPAddress) ,
100- ( " testMACADdress " , testMACADdress ) ,
100+ ( " testMACADdress " , testMACAddress ) ,
101101 ]
102102 }
103103}
You can’t perform that action at this time.
0 commit comments