-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from combustion-inc/develop
Release v0.8.1
- Loading branch information
Showing
8 changed files
with
164 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// ProbeColor.swift | ||
|
||
/*-- | ||
MIT License | ||
|
||
Copyright (c) 2021 Combustion Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--*/ | ||
|
||
import Foundation | ||
|
||
public enum ProbeColor: UInt8, CaseIterable { | ||
case COLOR1 = 0x00 | ||
case COLOR2 = 0x01 | ||
case COLOR3 = 0x02 | ||
case COLOR4 = 0x03 | ||
case COLOR5 = 0x04 | ||
case COLOR6 = 0x05 | ||
case COLOR7 = 0x06 | ||
case COLOR8 = 0x07 | ||
|
||
private enum Constants { | ||
static let PRODE_COLOR_MASK: UInt8 = 0x7 | ||
static let PRODE_COLOR_SHIFT: UInt8 = 2 | ||
} | ||
|
||
static func fromRawData(data: Data) -> ProbeColor { | ||
let modeIdColorBytes = [UInt8](data) | ||
|
||
let rawProbeColor = (modeIdColorBytes[0] & (Constants.PRODE_COLOR_MASK << Constants.PRODE_COLOR_SHIFT)) >> Constants.PRODE_COLOR_SHIFT | ||
return ProbeColor(rawValue: rawProbeColor) ?? .COLOR1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// ProbeID.swift | ||
|
||
/*-- | ||
MIT License | ||
|
||
Copyright (c) 2021 Combustion Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--*/ | ||
|
||
import Foundation | ||
|
||
public enum ProbeID: UInt8, CaseIterable { | ||
case ID1 = 0x00 | ||
case ID2 = 0x01 | ||
case ID3 = 0x02 | ||
case ID4 = 0x03 | ||
case ID5 = 0x04 | ||
case ID6 = 0x05 | ||
case ID7 = 0x06 | ||
case ID8 = 0x07 | ||
|
||
private enum Constants { | ||
static let PRODE_ID_MASK: UInt8 = 0x7 | ||
static let PRODE_ID_SHIFT: UInt8 = 5 | ||
} | ||
|
||
static func fromRawData(data: Data) -> ProbeID { | ||
let modeIdColorBytes = [UInt8](data) | ||
|
||
let rawProbeID = (modeIdColorBytes[0] & (Constants.PRODE_ID_MASK << Constants.PRODE_ID_SHIFT)) >> Constants.PRODE_ID_SHIFT | ||
return ProbeID(rawValue: rawProbeID) ?? .ID1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// ProbeMode.swift | ||
|
||
/*-- | ||
MIT License | ||
|
||
Copyright (c) 2021 Combustion Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--*/ | ||
|
||
import Foundation | ||
|
||
public enum ProbeMode: UInt8, CaseIterable { | ||
case Normal = 0x00 | ||
case InstantRead = 0x01 | ||
case Reserved = 0x02 | ||
case Error = 0x03 | ||
|
||
private enum Constants { | ||
static let PRODE_MODE_MASK: UInt8 = 0x3 | ||
} | ||
|
||
static func fromRawData(data: Data) -> ProbeMode { | ||
let modeIdColorBytes = [UInt8](data) | ||
|
||
let rawProbeID = modeIdColorBytes[0] & (Constants.PRODE_MODE_MASK) | ||
return ProbeMode(rawValue: rawProbeID) ?? .Normal | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters