mirror of
https://github.com/lachlanbell/PineTool.git
synced 2025-07-23 17:00:34 +02:00
Initial commit
This commit is contained in:
118
.gitignore
vendored
Normal file
118
.gitignore
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||
build/
|
||||
DerivedData/
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
|
||||
## App packaging
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# Swift Package Manager
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||
# Packages/
|
||||
# Package.pins
|
||||
# Package.resolved
|
||||
# *.xcodeproj
|
||||
#
|
||||
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
|
||||
# hence it is not needed unless you have added a package configuration file to your project
|
||||
# .swiftpm
|
||||
|
||||
.build/
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# Pods/
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from the Xcode workspace
|
||||
# *.xcworkspace
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build/
|
||||
|
||||
# Accio dependency management
|
||||
Dependencies/
|
||||
.accio/
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo.
|
||||
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://docs.fastlane.tools/best-practices/source-control/#source-control
|
||||
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots/**/*.png
|
||||
fastlane/test_output
|
||||
|
||||
# Code Injection
|
||||
#
|
||||
# After new code Injection tools there's a generated folder /iOSInjectionProject
|
||||
# https://github.com/johnno1962/injectionforxcode
|
||||
|
||||
iOSInjectionProject/
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
355
LICENSE.md
Normal file
355
LICENSE.md
Normal file
@@ -0,0 +1,355 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
### 1. Definitions
|
||||
|
||||
**1.1. “Contributor”**
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
**1.2. “Contributor Version”**
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
**1.3. “Contribution”**
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
**1.4. “Covered Software”**
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
**1.5. “Incompatible With Secondary Licenses”**
|
||||
means
|
||||
|
||||
* **(a)** that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
* **(b)** that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
**1.6. “Executable Form”**
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
**1.7. “Larger Work”**
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
**1.8. “License”**
|
||||
means this document.
|
||||
|
||||
**1.9. “Licensable”**
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
**1.10. “Modifications”**
|
||||
means any of the following:
|
||||
|
||||
* **(a)** any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
* **(b)** any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
**1.11. “Patent Claims” of a Contributor**
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
**1.12. “Secondary License”**
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
**1.13. “Source Code Form”**
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
**1.14. “You” (or “Your”)**
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, “You” includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, “control” means **(a)** the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or **(b)** ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
|
||||
### 2. License Grants and Conditions
|
||||
|
||||
#### 2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
* **(a)** under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
* **(b)** under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
#### 2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
#### 2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
* **(a)** for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
* **(b)** for infringements caused by: **(i)** Your and any other third party's
|
||||
modifications of Covered Software, or **(ii)** the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
* **(c)** under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
#### 2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
#### 2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
#### 2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
#### 2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
|
||||
### 3. Responsibilities
|
||||
|
||||
#### 3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
#### 3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
* **(a)** such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
* **(b)** You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
#### 3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
#### 3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
#### 3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
|
||||
### 4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: **(a)** comply with
|
||||
the terms of this License to the maximum extent possible; and **(b)**
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
|
||||
### 5. Termination
|
||||
|
||||
**5.1.** The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated **(a)** provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and **(b)** on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
**5.2.** If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
**5.3.** In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
|
||||
### 6. Disclaimer of Warranty
|
||||
|
||||
> Covered Software is provided under this License on an “as is”
|
||||
> basis, without warranty of any kind, either expressed, implied, or
|
||||
> statutory, including, without limitation, warranties that the
|
||||
> Covered Software is free of defects, merchantable, fit for a
|
||||
> particular purpose or non-infringing. The entire risk as to the
|
||||
> quality and performance of the Covered Software is with You.
|
||||
> Should any Covered Software prove defective in any respect, You
|
||||
> (not any Contributor) assume the cost of any necessary servicing,
|
||||
> repair, or correction. This disclaimer of warranty constitutes an
|
||||
> essential part of this License. No use of any Covered Software is
|
||||
> authorized under this License except under this disclaimer.
|
||||
|
||||
### 7. Limitation of Liability
|
||||
|
||||
> Under no circumstances and under no legal theory, whether tort
|
||||
> (including negligence), contract, or otherwise, shall any
|
||||
> Contributor, or anyone who distributes Covered Software as
|
||||
> permitted above, be liable to You for any direct, indirect,
|
||||
> special, incidental, or consequential damages of any character
|
||||
> including, without limitation, damages for lost profits, loss of
|
||||
> goodwill, work stoppage, computer failure or malfunction, or any
|
||||
> and all other commercial damages or losses, even if such party
|
||||
> shall have been informed of the possibility of such damages. This
|
||||
> limitation of liability shall not apply to liability for death or
|
||||
> personal injury resulting from such party's negligence to the
|
||||
> extent applicable law prohibits such limitation. Some
|
||||
> jurisdictions do not allow the exclusion or limitation of
|
||||
> incidental or consequential damages, so this exclusion and
|
||||
> limitation may not apply to You.
|
||||
|
||||
|
||||
### 8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
|
||||
### 9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
|
||||
### 10. Versions of the License
|
||||
|
||||
#### 10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
#### 10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
#### 10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
#### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
## Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
## Exhibit B - “Incompatible With Secondary Licenses” Notice
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
468
PineTool.xcodeproj/project.pbxproj
Normal file
468
PineTool.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,468 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 56;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0E3B6BFC29F3A7B80093FC45 /* PineToolApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6BFB29F3A7B80093FC45 /* PineToolApp.swift */; };
|
||||
0E3B6BFE29F3A7B80093FC45 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6BFD29F3A7B80093FC45 /* ContentView.swift */; };
|
||||
0E3B6C0029F3A7B90093FC45 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0E3B6BFF29F3A7B90093FC45 /* Assets.xcassets */; };
|
||||
0E3B6C0A29F3A82B0093FC45 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6C0929F3A82B0093FC45 /* SettingsView.swift */; };
|
||||
0E3B6C0E29F3A85A0093FC45 /* PinecilManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6C0D29F3A85A0093FC45 /* PinecilManager.swift */; };
|
||||
0E3B6C1029F3C7AC0093FC45 /* TemperaturePowerChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6C0F29F3C7AC0093FC45 /* TemperaturePowerChart.swift */; };
|
||||
0E3B6C1229F4AE1F0093FC45 /* DiscoveredPeripheralsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6C1129F4AE1F0093FC45 /* DiscoveredPeripheralsList.swift */; };
|
||||
0E3B6C1429F552510093FC45 /* PinecilBulkData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6C1329F552510093FC45 /* PinecilBulkData.swift */; };
|
||||
0E3B6C1629F559900093FC45 /* PinecilStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6C1529F559900093FC45 /* PinecilStatusView.swift */; };
|
||||
0E3B6C1829F55EC70093FC45 /* PowerSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6C1729F55EC70093FC45 /* PowerSource.swift */; };
|
||||
0E3B6C1B29F688A90093FC45 /* TemperatureSetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3B6C1A29F688A90093FC45 /* TemperatureSetViewController.swift */; };
|
||||
0E3B6C1E29F68A700093FC45 /* TinyConstraints in Frameworks */ = {isa = PBXBuildFile; productRef = 0E3B6C1D29F68A700093FC45 /* TinyConstraints */; };
|
||||
0E3B6C2129F68AC70093FC45 /* KeyboardGuide in Frameworks */ = {isa = PBXBuildFile; productRef = 0E3B6C2029F68AC70093FC45 /* KeyboardGuide */; };
|
||||
0E3B6C2529F694A40093FC45 /* Introspect in Frameworks */ = {isa = PBXBuildFile; productRef = 0E3B6C2429F694A40093FC45 /* Introspect */; };
|
||||
0E3B6C2729F76E180093FC45 /* LICENSE.md in Resources */ = {isa = PBXBuildFile; fileRef = 0E3B6C2629F76E180093FC45 /* LICENSE.md */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0E3B6BF829F3A7B80093FC45 /* PineTool.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PineTool.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0E3B6BFB29F3A7B80093FC45 /* PineToolApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PineToolApp.swift; sourceTree = "<group>"; };
|
||||
0E3B6BFD29F3A7B80093FC45 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
0E3B6BFF29F3A7B90093FC45 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
0E3B6C0929F3A82B0093FC45 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
|
||||
0E3B6C0D29F3A85A0093FC45 /* PinecilManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinecilManager.swift; sourceTree = "<group>"; };
|
||||
0E3B6C0F29F3C7AC0093FC45 /* TemperaturePowerChart.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemperaturePowerChart.swift; sourceTree = "<group>"; };
|
||||
0E3B6C1129F4AE1F0093FC45 /* DiscoveredPeripheralsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveredPeripheralsList.swift; sourceTree = "<group>"; };
|
||||
0E3B6C1329F552510093FC45 /* PinecilBulkData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinecilBulkData.swift; sourceTree = "<group>"; };
|
||||
0E3B6C1529F559900093FC45 /* PinecilStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinecilStatusView.swift; sourceTree = "<group>"; };
|
||||
0E3B6C1729F55EC70093FC45 /* PowerSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PowerSource.swift; sourceTree = "<group>"; };
|
||||
0E3B6C1929F570AE0093FC45 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
0E3B6C1A29F688A90093FC45 /* TemperatureSetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemperatureSetViewController.swift; sourceTree = "<group>"; };
|
||||
0E3B6C2629F76E180093FC45 /* LICENSE.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = LICENSE.md; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
0E3B6BF529F3A7B80093FC45 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0E3B6C2129F68AC70093FC45 /* KeyboardGuide in Frameworks */,
|
||||
0E3B6C2529F694A40093FC45 /* Introspect in Frameworks */,
|
||||
0E3B6C1E29F68A700093FC45 /* TinyConstraints in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0E3B6BEF29F3A7B80093FC45 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0E3B6C2629F76E180093FC45 /* LICENSE.md */,
|
||||
0E3B6BFA29F3A7B80093FC45 /* PineTool */,
|
||||
0E3B6BF929F3A7B80093FC45 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0E3B6BF929F3A7B80093FC45 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0E3B6BF829F3A7B80093FC45 /* PineTool.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0E3B6BFA29F3A7B80093FC45 /* PineTool */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0E3B6C1929F570AE0093FC45 /* Info.plist */,
|
||||
0E3B6C0C29F3A83D0093FC45 /* Bluetooth */,
|
||||
0E3B6C0B29F3A8300093FC45 /* Views */,
|
||||
0E3B6BFB29F3A7B80093FC45 /* PineToolApp.swift */,
|
||||
0E3B6BFF29F3A7B90093FC45 /* Assets.xcassets */,
|
||||
);
|
||||
path = PineTool;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0E3B6C0B29F3A8300093FC45 /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0E3B6C2229F68C220093FC45 /* UIKit */,
|
||||
0E3B6BFD29F3A7B80093FC45 /* ContentView.swift */,
|
||||
0E3B6C0929F3A82B0093FC45 /* SettingsView.swift */,
|
||||
0E3B6C0F29F3C7AC0093FC45 /* TemperaturePowerChart.swift */,
|
||||
0E3B6C1129F4AE1F0093FC45 /* DiscoveredPeripheralsList.swift */,
|
||||
0E3B6C1529F559900093FC45 /* PinecilStatusView.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0E3B6C0C29F3A83D0093FC45 /* Bluetooth */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0E3B6C0D29F3A85A0093FC45 /* PinecilManager.swift */,
|
||||
0E3B6C1329F552510093FC45 /* PinecilBulkData.swift */,
|
||||
0E3B6C1729F55EC70093FC45 /* PowerSource.swift */,
|
||||
);
|
||||
path = Bluetooth;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0E3B6C2229F68C220093FC45 /* UIKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0E3B6C1A29F688A90093FC45 /* TemperatureSetViewController.swift */,
|
||||
);
|
||||
path = UIKit;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
0E3B6BF729F3A7B80093FC45 /* PineTool */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 0E3B6C0629F3A7B90093FC45 /* Build configuration list for PBXNativeTarget "PineTool" */;
|
||||
buildPhases = (
|
||||
0E3B6BF429F3A7B80093FC45 /* Sources */,
|
||||
0E3B6BF529F3A7B80093FC45 /* Frameworks */,
|
||||
0E3B6BF629F3A7B80093FC45 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = PineTool;
|
||||
packageProductDependencies = (
|
||||
0E3B6C1D29F68A700093FC45 /* TinyConstraints */,
|
||||
0E3B6C2029F68AC70093FC45 /* KeyboardGuide */,
|
||||
0E3B6C2429F694A40093FC45 /* Introspect */,
|
||||
);
|
||||
productName = PineTool;
|
||||
productReference = 0E3B6BF829F3A7B80093FC45 /* PineTool.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
0E3B6BF029F3A7B80093FC45 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1430;
|
||||
LastUpgradeCheck = 1430;
|
||||
ORGANIZATIONNAME = "Lachlan Bell";
|
||||
TargetAttributes = {
|
||||
0E3B6BF729F3A7B80093FC45 = {
|
||||
CreatedOnToolsVersion = 14.3;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 0E3B6BF329F3A7B80093FC45 /* Build configuration list for PBXProject "PineTool" */;
|
||||
compatibilityVersion = "Xcode 14.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 0E3B6BEF29F3A7B80093FC45;
|
||||
packageReferences = (
|
||||
0E3B6C1C29F68A700093FC45 /* XCRemoteSwiftPackageReference "TinyConstraints" */,
|
||||
0E3B6C1F29F68AC70093FC45 /* XCRemoteSwiftPackageReference "KeyboardGuide" */,
|
||||
0E3B6C2329F694A40093FC45 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */,
|
||||
);
|
||||
productRefGroup = 0E3B6BF929F3A7B80093FC45 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
0E3B6BF729F3A7B80093FC45 /* PineTool */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
0E3B6BF629F3A7B80093FC45 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0E3B6C2729F76E180093FC45 /* LICENSE.md in Resources */,
|
||||
0E3B6C0029F3A7B90093FC45 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
0E3B6BF429F3A7B80093FC45 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0E3B6C0A29F3A82B0093FC45 /* SettingsView.swift in Sources */,
|
||||
0E3B6BFE29F3A7B80093FC45 /* ContentView.swift in Sources */,
|
||||
0E3B6C1B29F688A90093FC45 /* TemperatureSetViewController.swift in Sources */,
|
||||
0E3B6C1029F3C7AC0093FC45 /* TemperaturePowerChart.swift in Sources */,
|
||||
0E3B6C1829F55EC70093FC45 /* PowerSource.swift in Sources */,
|
||||
0E3B6C1429F552510093FC45 /* PinecilBulkData.swift in Sources */,
|
||||
0E3B6C1229F4AE1F0093FC45 /* DiscoveredPeripheralsList.swift in Sources */,
|
||||
0E3B6C1629F559900093FC45 /* PinecilStatusView.swift in Sources */,
|
||||
0E3B6C0E29F3A85A0093FC45 /* PinecilManager.swift in Sources */,
|
||||
0E3B6BFC29F3A7B80093FC45 /* PineToolApp.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
0E3B6C0429F3A7B90093FC45 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
0E3B6C0529F3A7B90093FC45 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
0E3B6C0729F3A7B90093FC45 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 7VE74Y2PVW;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = PineTool/Info.plist;
|
||||
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "This app needs to use Bluetooth to communicate with your device.";
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||
INFOPLIST_KEY_UIUserInterfaceStyle = Dark;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.lachy.PineTool;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
0E3B6C0829F3A7B90093FC45 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 7VE74Y2PVW;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = PineTool/Info.plist;
|
||||
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "This app needs to use Bluetooth to communicate with your device.";
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||
INFOPLIST_KEY_UIUserInterfaceStyle = Dark;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.lachy.PineTool;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
0E3B6BF329F3A7B80093FC45 /* Build configuration list for PBXProject "PineTool" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0E3B6C0429F3A7B90093FC45 /* Debug */,
|
||||
0E3B6C0529F3A7B90093FC45 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
0E3B6C0629F3A7B90093FC45 /* Build configuration list for PBXNativeTarget "PineTool" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0E3B6C0729F3A7B90093FC45 /* Debug */,
|
||||
0E3B6C0829F3A7B90093FC45 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
0E3B6C1C29F68A700093FC45 /* XCRemoteSwiftPackageReference "TinyConstraints" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/roberthein/TinyConstraints";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 4.0.0;
|
||||
};
|
||||
};
|
||||
0E3B6C1F29F68AC70093FC45 /* XCRemoteSwiftPackageReference "KeyboardGuide" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/niw/KeyboardGuide";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 0.2.2;
|
||||
};
|
||||
};
|
||||
0E3B6C2329F694A40093FC45 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/siteline/SwiftUI-Introspect";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 0.2.3;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
0E3B6C1D29F68A700093FC45 /* TinyConstraints */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 0E3B6C1C29F68A700093FC45 /* XCRemoteSwiftPackageReference "TinyConstraints" */;
|
||||
productName = TinyConstraints;
|
||||
};
|
||||
0E3B6C2029F68AC70093FC45 /* KeyboardGuide */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 0E3B6C1F29F68AC70093FC45 /* XCRemoteSwiftPackageReference "KeyboardGuide" */;
|
||||
productName = KeyboardGuide;
|
||||
};
|
||||
0E3B6C2429F694A40093FC45 /* Introspect */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 0E3B6C2329F694A40093FC45 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
|
||||
productName = Introspect;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 0E3B6BF029F3A7B80093FC45 /* Project object */;
|
||||
}
|
7
PineTool.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
PineTool.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "keyboardguide",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/niw/KeyboardGuide",
|
||||
"state" : {
|
||||
"revision" : "f42565b897aef6652c1bd3e5b20b7f6a280a57f7",
|
||||
"version" : "0.2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swiftui-introspect",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/siteline/SwiftUI-Introspect",
|
||||
"state" : {
|
||||
"revision" : "c18951c747ab62af7c15e17a81bd37d4fd5a9979",
|
||||
"version" : "0.2.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "tinyconstraints",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/roberthein/TinyConstraints",
|
||||
"state" : {
|
||||
"revision" : "3262e5c591d4ab6272255df2087a01bbebd138dc",
|
||||
"version" : "4.0.2"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 2
|
||||
}
|
38
PineTool/Assets.xcassets/AccentColor.colorset/Contents.json
Normal file
38
PineTool/Assets.xcassets/AccentColor.colorset/Contents.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "extended-srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0.412",
|
||||
"green" : "0.588",
|
||||
"red" : "0.020"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "extended-srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0.332",
|
||||
"green" : "0.481",
|
||||
"red" : "-0.242"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
PineTool/Assets.xcassets/AppIcon.appiconset/App Store@2x.png
Normal file
BIN
PineTool/Assets.xcassets/AppIcon.appiconset/App Store@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
14
PineTool/Assets.xcassets/AppIcon.appiconset/Contents.json
Normal file
14
PineTool/Assets.xcassets/AppIcon.appiconset/Contents.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "App Store@2x.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
6
PineTool/Assets.xcassets/Contents.json
Normal file
6
PineTool/Assets.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
23
PineTool/Assets.xcassets/PolymerLink.imageset/Contents.json
vendored
Normal file
23
PineTool/Assets.xcassets/PolymerLink.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "PolymerLink.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "PolymerLink@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "PolymerLink@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
PineTool/Assets.xcassets/PolymerLink.imageset/PolymerLink.png
vendored
Normal file
BIN
PineTool/Assets.xcassets/PolymerLink.imageset/PolymerLink.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
PineTool/Assets.xcassets/PolymerLink.imageset/PolymerLink@2x.png
vendored
Normal file
BIN
PineTool/Assets.xcassets/PolymerLink.imageset/PolymerLink@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
PineTool/Assets.xcassets/PolymerLink.imageset/PolymerLink@3x.png
vendored
Normal file
BIN
PineTool/Assets.xcassets/PolymerLink.imageset/PolymerLink@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
77
PineTool/Bluetooth/PinecilBulkData.swift
Normal file
77
PineTool/Bluetooth/PinecilBulkData.swift
Normal file
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// PinecilBulkData.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// See https://github.com/Ralim/IronOS/blob/5a36b0479cef995ecfb1e75638579d11cb891feb/source/Core/BSP/Pinecilv2/ble_handlers.cpp#L151-L166
|
||||
struct PinecilBulkData {
|
||||
/// Current temp
|
||||
let tipTemperature: UInt32
|
||||
/// Setpoint
|
||||
let setpoint: UInt32
|
||||
/// Input voltage
|
||||
let inputVoltage: UInt32
|
||||
/// Handle X10 Temp in C
|
||||
let handleTemperature: UInt32
|
||||
/// Power as PWM level
|
||||
let powerPWM: UInt32
|
||||
/// Power src
|
||||
let powerSource: UInt32
|
||||
/// Tip resistance
|
||||
let tipResistance: UInt32
|
||||
/// Uptime in deciseconds
|
||||
let uptime: UInt32
|
||||
/// Last movement time (deciseconds)
|
||||
let lastMovementTime: UInt32
|
||||
/// Max temp
|
||||
let maxTemperature: UInt32
|
||||
/// Raw tip in μV
|
||||
let rawTipMicrovolts: UInt32
|
||||
/// Hall sensor
|
||||
let hallSensor: UInt32
|
||||
/// Operating mode
|
||||
let operatingMode: UInt32
|
||||
/// Estimated wattage × 10
|
||||
let estimatedWattage: UInt32
|
||||
|
||||
init?(data: Data) {
|
||||
guard data.count >= 56 else {
|
||||
assertionFailure()
|
||||
return nil
|
||||
}
|
||||
|
||||
tipTemperature = data.readUInt32(0)
|
||||
setpoint = data.readUInt32(1)
|
||||
inputVoltage = data.readUInt32(2)
|
||||
handleTemperature = data.readUInt32(3)
|
||||
powerPWM = data.readUInt32(4)
|
||||
powerSource = data.readUInt32(5)
|
||||
tipResistance = data.readUInt32(6)
|
||||
uptime = data.readUInt32(7)
|
||||
lastMovementTime = data.readUInt32(8)
|
||||
maxTemperature = data.readUInt32(9)
|
||||
rawTipMicrovolts = data.readUInt32(10)
|
||||
hallSensor = data.readUInt32(11)
|
||||
operatingMode = data.readUInt32(12)
|
||||
estimatedWattage = data.readUInt32(13)
|
||||
}
|
||||
}
|
||||
|
||||
private extension Data {
|
||||
func readUInt32(_ index: Int) -> UInt32 {
|
||||
let dataSlice = self[(index * 4)..<((index + 1) * 4)]
|
||||
|
||||
return UInt32(littleEndian: dataSlice.withUnsafeBytes({
|
||||
$0.load(as: UInt32.self)
|
||||
}))
|
||||
}
|
||||
}
|
224
PineTool/Bluetooth/PinecilManager.swift
Normal file
224
PineTool/Bluetooth/PinecilManager.swift
Normal file
@@ -0,0 +1,224 @@
|
||||
//
|
||||
// PinecilManager.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
import CoreBluetooth
|
||||
|
||||
@MainActor
|
||||
class PinecilManager: NSObject, ObservableObject {
|
||||
|
||||
enum ConnectionState: Equatable {
|
||||
case connected(CBPeripheral)
|
||||
case connecting(CBPeripheral)
|
||||
case disconnected
|
||||
case scanning
|
||||
}
|
||||
|
||||
@Published private(set) var bulkData: PinecilBulkData?
|
||||
@Published private(set) var discoveredPeripherals: [CBPeripheral] = []
|
||||
@Published private(set) var peripheralNames: [CBPeripheral: String] = [:]
|
||||
@Published private(set) var powerSamples: [Double] = []
|
||||
@Published private(set) var state: ConnectionState = .disconnected
|
||||
@Published private(set) var temperatureSamples: [Double] = []
|
||||
|
||||
private let bulkDataCharacteristicUUID = CBUUID(string: "9eae1001-9d0d-48c5-AA55-33e27f9bc533")
|
||||
private var bulkDataCharacteristic: CBCharacteristic?
|
||||
private let bulkDataServiceUUID = CBUUID(string: "9eae1000-9d0d-48c5-aa55-33e27f9bc533")
|
||||
private let settingsServiceUUID = CBUUID(string: "f6d80000-5a10-4eba-aa55-33e27f9bc533")
|
||||
private var setpointCharacteristic: CBCharacteristic?
|
||||
private var setpointCharacteristicUUID = CBUUID(string: "f6d70000-5a10-4eba-aa55-33e27f9bc533")
|
||||
|
||||
private let centralManager: CBCentralManager
|
||||
private var pollTimer: Timer?
|
||||
|
||||
override init() {
|
||||
self.centralManager = CBCentralManager()
|
||||
super.init()
|
||||
|
||||
centralManager.delegate = self
|
||||
}
|
||||
|
||||
func scan() {
|
||||
guard !centralManager.isScanning else { return }
|
||||
|
||||
self.state = .scanning
|
||||
discoveredPeripherals = []
|
||||
peripheralNames = [:]
|
||||
|
||||
centralManager.scanForPeripherals(withServices: nil)
|
||||
}
|
||||
|
||||
func stopScan() {
|
||||
centralManager.stopScan()
|
||||
|
||||
if self.state == .scanning {
|
||||
self.state = .disconnected
|
||||
}
|
||||
}
|
||||
|
||||
func connect(to peripheral: CBPeripheral) {
|
||||
guard self.state == .scanning else { return }
|
||||
|
||||
self.state = .connecting(peripheral)
|
||||
centralManager.connect(peripheral)
|
||||
}
|
||||
|
||||
func disconnect() {
|
||||
if case .connected(let peripheral) = state {
|
||||
centralManager.cancelPeripheralConnection(peripheral)
|
||||
}
|
||||
}
|
||||
|
||||
func writeSetpoint(_ setpoint: UInt32) {
|
||||
guard let setpointCharacteristic else { return }
|
||||
|
||||
if case .connected(let peripheral) = state {
|
||||
var setpointLE = UInt16(setpoint).littleEndian
|
||||
|
||||
peripheral.writeValue(
|
||||
Data(bytes: &setpointLE, count: 2),
|
||||
for: setpointCharacteristic,
|
||||
type: .withoutResponse
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func clear() {
|
||||
self.bulkData = nil
|
||||
self.powerSamples = []
|
||||
self.temperatureSamples = []
|
||||
}
|
||||
|
||||
@objc private func pollBulkData() {
|
||||
guard let bulkDataCharacteristic else { return }
|
||||
|
||||
// Polling like this is suboptimal --- update me when BLE characteristic
|
||||
// value notifications are supported in IronOS.
|
||||
if case .connected(let peripheral) = state {
|
||||
peripheral.readValue(for: bulkDataCharacteristic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CBCentralManagerDelegate
|
||||
extension PinecilManager: CBCentralManagerDelegate {
|
||||
|
||||
func centralManagerDidUpdateState(_ central: CBCentralManager) {
|
||||
if central.state != .poweredOn {
|
||||
self.state = .disconnected
|
||||
clear()
|
||||
}
|
||||
}
|
||||
|
||||
func centralManager(
|
||||
_ central: CBCentralManager,
|
||||
didDiscover peripheral: CBPeripheral,
|
||||
advertisementData: [String : Any],
|
||||
rssi RSSI: NSNumber
|
||||
) {
|
||||
guard let services = advertisementData["kCBAdvDataServiceUUIDs"] as? [CBUUID] else { return }
|
||||
|
||||
if services.contains(bulkDataServiceUUID) {
|
||||
discoveredPeripherals.append(peripheral)
|
||||
peripheral.delegate = self
|
||||
|
||||
// Advertised local names can be disambiguated
|
||||
// (e.g. `Pinecil-00ABCFF` vs `Pinecil`), and so we'll prefer to use
|
||||
// them over the peripheral's name property.
|
||||
if let localName = advertisementData["kCBAdvDataLocalName"] as? String {
|
||||
peripheralNames[peripheral] = localName
|
||||
} else {
|
||||
peripheralNames[peripheral] = peripheral.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func centralManager(
|
||||
_ central: CBCentralManager,
|
||||
didConnect peripheral: CBPeripheral
|
||||
) {
|
||||
clear()
|
||||
self.state = .connected(peripheral)
|
||||
|
||||
// Search for services
|
||||
peripheral.discoverServices([
|
||||
bulkDataServiceUUID,
|
||||
settingsServiceUUID
|
||||
])
|
||||
|
||||
// Start polling
|
||||
pollTimer?.invalidate()
|
||||
pollTimer = Timer.scheduledTimer(
|
||||
timeInterval: 0.2,
|
||||
target: self,
|
||||
selector: #selector(pollBulkData),
|
||||
userInfo: nil,
|
||||
repeats: true
|
||||
)
|
||||
}
|
||||
|
||||
func centralManager(
|
||||
_ central: CBCentralManager,
|
||||
didDisconnectPeripheral peripheral: CBPeripheral,
|
||||
error: Error?
|
||||
) {
|
||||
self.state = .disconnected
|
||||
clear()
|
||||
pollTimer?.invalidate()
|
||||
pollTimer = nil
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CBPeripheralDelegate
|
||||
extension PinecilManager: CBPeripheralDelegate {
|
||||
|
||||
func peripheral(
|
||||
_ peripheral: CBPeripheral,
|
||||
didDiscoverServices error: Error?
|
||||
) {
|
||||
peripheral.services?.forEach {
|
||||
peripheral.discoverCharacteristics(nil, for: $0)
|
||||
}
|
||||
}
|
||||
|
||||
func peripheral(
|
||||
_ peripheral: CBPeripheral,
|
||||
didUpdateValueFor characteristic: CBCharacteristic,
|
||||
error: Error?
|
||||
) {
|
||||
guard let rawData = characteristic.value else { return }
|
||||
|
||||
if let bulkData = PinecilBulkData(data: rawData) {
|
||||
self.bulkData = bulkData
|
||||
|
||||
self.powerSamples.append(Double(bulkData.estimatedWattage) / 10.0)
|
||||
self.temperatureSamples.append(Double(bulkData.tipTemperature))
|
||||
}
|
||||
}
|
||||
|
||||
func peripheral(
|
||||
_ peripheral: CBPeripheral,
|
||||
didDiscoverCharacteristicsFor service: CBService,
|
||||
error: Error?
|
||||
) {
|
||||
service.characteristics?.forEach { characteristic in
|
||||
if characteristic.uuid == bulkDataCharacteristicUUID {
|
||||
self.bulkDataCharacteristic = characteristic
|
||||
}
|
||||
|
||||
if characteristic.uuid == setpointCharacteristicUUID {
|
||||
self.setpointCharacteristic = characteristic
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
PineTool/Bluetooth/PowerSource.swift
Normal file
29
PineTool/Bluetooth/PowerSource.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// PowerSource.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum PowerSource: UInt32, CustomStringConvertible {
|
||||
case dc = 0
|
||||
case usb = 1
|
||||
case pdVBUS = 2
|
||||
case pd = 3
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .dc: return "DC"
|
||||
case .usb: return "USB"
|
||||
case .pdVBUS: return "USB-PD (VBUS)"
|
||||
case .pd: return "USB-PD"
|
||||
}
|
||||
}
|
||||
}
|
5
PineTool/Info.plist
Normal file
5
PineTool/Info.plist
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict/>
|
||||
</plist>
|
31
PineTool/PineToolApp.swift
Normal file
31
PineTool/PineToolApp.swift
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// PineToolApp.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct PineToolApp: App {
|
||||
@AppStorage("keep-awake") var keepAwake = true
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environmentObject(PinecilManager())
|
||||
.onAppear {
|
||||
UIApplication.shared.isIdleTimerDisabled = keepAwake
|
||||
}
|
||||
.onChange(of: keepAwake) {
|
||||
UIApplication.shared.isIdleTimerDisabled = $0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
180
PineTool/Views/ContentView.swift
Normal file
180
PineTool/Views/ContentView.swift
Normal file
@@ -0,0 +1,180 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Introspect
|
||||
|
||||
struct ContentView: View {
|
||||
|
||||
@EnvironmentObject private var pinecilManager: PinecilManager
|
||||
|
||||
@State private var presentingPeripheralList = false
|
||||
@State private var presentingSettings = false
|
||||
@State private var viewController: UIViewController?
|
||||
|
||||
@ViewBuilder
|
||||
var connectButton: some View {
|
||||
Button {
|
||||
pinecilManager.scan()
|
||||
presentingPeripheralList = true
|
||||
} label: {
|
||||
Text("\(Image(systemName: "antenna.radiowaves.left.and.right")) Connect")
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color.accentColor.opacity(0.3))
|
||||
.clipShape(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var largeStats: some View {
|
||||
HStack(spacing: 0) {
|
||||
VStack(alignment: .center) {
|
||||
Text("\(pinecilManager.bulkData?.tipTemperature ?? 0) ℃")
|
||||
.font(.title2).monospacedDigit()
|
||||
.bold()
|
||||
|
||||
Text("Temperature")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Divider()
|
||||
|
||||
VStack(alignment: .center) {
|
||||
Text("\(Double(pinecilManager.bulkData?.estimatedWattage ?? 0) / 10.0, specifier: "%.1f") W")
|
||||
.font(.title2).monospacedDigit()
|
||||
.bold()
|
||||
|
||||
Text("Power")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.padding(.vertical)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color(.tertiarySystemGroupedBackground))
|
||||
.clipShape(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var setPoint: some View {
|
||||
HStack(alignment: .center) {
|
||||
Text("Setpoint")
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
viewController?.present(
|
||||
TemperatureSetViewController(
|
||||
temperature: pinecilManager.bulkData?.setpoint,
|
||||
setCallback: {
|
||||
pinecilManager.writeSetpoint($0)
|
||||
},
|
||||
validateCallback: { value in
|
||||
guard let maxTemp = pinecilManager.bulkData?.maxTemperature else {
|
||||
return false
|
||||
}
|
||||
guard value >= 50 else { return false }
|
||||
return value <= maxTemp
|
||||
}
|
||||
),
|
||||
animated: true
|
||||
)
|
||||
} label: {
|
||||
Text("\(pinecilManager.bulkData?.setpoint ?? 0) ℃")
|
||||
.font(Font.system(size: 18, weight: .medium, design: .default).monospacedDigit())
|
||||
.frame(width: 80, height: 36, alignment: .center)
|
||||
.foregroundColor(Color(UIColor.label.withAlphaComponent(0.6)))
|
||||
.background(
|
||||
Color(
|
||||
UIColor
|
||||
.tertiarySystemFill
|
||||
.multiplyAlpha(by: pinecilManager.bulkData?.setpoint == nil ? 0.6 : 1)
|
||||
)
|
||||
)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
|
||||
}
|
||||
.padding(-8)
|
||||
.disabled(pinecilManager.bulkData?.setpoint == nil)
|
||||
}
|
||||
.padding()
|
||||
.background(Color(.tertiarySystemGroupedBackground))
|
||||
.clipShape(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
VStack(spacing: 16) {
|
||||
if pinecilManager.state == .disconnected || pinecilManager.state == .scanning {
|
||||
connectButton
|
||||
} else {
|
||||
PinecilStatusView()
|
||||
}
|
||||
|
||||
largeStats
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
||||
TemperaturePowerChart()
|
||||
|
||||
setPoint
|
||||
}
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.navigationTitle("PineTool")
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
presentingSettings = true
|
||||
} label: {
|
||||
Image(systemName: "gear")
|
||||
}
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $presentingPeripheralList) {
|
||||
DiscoveredPeripheralsList()
|
||||
}
|
||||
.sheet(isPresented: $presentingSettings) {
|
||||
SettingsView()
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.introspectViewController { viewController in
|
||||
// Introspecting and storing the host view controller like this
|
||||
// is hacky, but unfortunately SwiftUI doesn't have the
|
||||
// capability to present a `UIViewControllerRepresentable` with
|
||||
// a custom transition.
|
||||
self.viewController = viewController
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension UIColor {
|
||||
/// Multiply the alpha component of an already-translucent colour
|
||||
func multiplyAlpha(by alpha: CGFloat) -> UIColor {
|
||||
var (red, green, blue, oldAlpha) = (CGFloat.zero, CGFloat.zero, CGFloat.zero, CGFloat.zero)
|
||||
self.getRed(&red, green: &green, blue: &blue, alpha: &oldAlpha)
|
||||
|
||||
return UIColor(red: red, green: green, blue: blue, alpha: alpha * oldAlpha)
|
||||
}
|
||||
}
|
95
PineTool/Views/DiscoveredPeripheralsList.swift
Normal file
95
PineTool/Views/DiscoveredPeripheralsList.swift
Normal file
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// DiscoveredPeripheralsList.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CoreBluetooth
|
||||
|
||||
struct DiscoveredPeripheralsList: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@EnvironmentObject var pinecilManager: PinecilManager
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ZStack {
|
||||
List {
|
||||
if !pinecilManager.discoveredPeripherals.isEmpty {
|
||||
Section("Discovered Devices") {
|
||||
ForEach(pinecilManager.discoveredPeripherals) { peripheral in
|
||||
Button {
|
||||
pinecilManager.connect(to: peripheral)
|
||||
} label: {
|
||||
HStack(alignment: .center) {
|
||||
VStack(alignment: .leading) {
|
||||
Text(pinecilManager.peripheralNames[peripheral] ?? "Unknown")
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if case let .connecting(connectingPeripheral) = pinecilManager.state,
|
||||
connectingPeripheral == peripheral {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if pinecilManager.discoveredPeripherals.isEmpty {
|
||||
VStack(alignment: .center) {
|
||||
Spacer()
|
||||
|
||||
VStack(alignment: .center, spacing: 16) {
|
||||
ProgressView()
|
||||
Text("Scanning for devices…")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Link(
|
||||
"\(Image(systemName: "questionmark.circle.fill")) Can’t find your device?",
|
||||
destination: URL(string: "https://lachy.io/pinetool/help")!
|
||||
)
|
||||
.padding(.bottom)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Connect")
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Text("Cancel")
|
||||
.bold()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
pinecilManager.stopScan()
|
||||
}
|
||||
.onReceive(pinecilManager.$state) { state in
|
||||
if case .connected = state {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension CBPeripheral: Identifiable {
|
||||
public var id: UUID { self.identifier }
|
||||
}
|
89
PineTool/Views/PinecilStatusView.swift
Normal file
89
PineTool/Views/PinecilStatusView.swift
Normal file
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// PinecilStatusView.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PinecilStatusView: View {
|
||||
@EnvironmentObject var pinecilManager: PinecilManager
|
||||
|
||||
@ViewBuilder
|
||||
var statStack: some View {
|
||||
VStack(spacing: 4) {
|
||||
PinecilStat(
|
||||
title: "Input Voltage",
|
||||
value: "\(Double(pinecilManager.bulkData?.inputVoltage ?? 0) / 10.0) V"
|
||||
)
|
||||
|
||||
PinecilStat(
|
||||
title: "Handle Temperature",
|
||||
value: "\(Double(pinecilManager.bulkData?.handleTemperature ?? 0) / 10.0) ℃"
|
||||
)
|
||||
|
||||
PinecilStat(
|
||||
title: "Uptime",
|
||||
value: "\(Int(Double(pinecilManager.bulkData?.uptime ?? 0) / 10.0)) sec"
|
||||
)
|
||||
|
||||
PinecilStat(
|
||||
title: "Power Source",
|
||||
value: PowerSource(rawValue: pinecilManager.bulkData?.powerSource ?? .max)?.description ?? "Unknown"
|
||||
)
|
||||
}
|
||||
.padding()
|
||||
.background(Color(.tertiarySystemGroupedBackground))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var disconnectButton: some View {
|
||||
Button {
|
||||
pinecilManager.disconnect()
|
||||
} label: {
|
||||
Text("\(Image(systemName: "antenna.radiowaves.left.and.right.slash")) Disconnect")
|
||||
.foregroundColor(.red)
|
||||
.padding(12)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color.red.opacity(0.3))
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
statStack
|
||||
|
||||
Divider()
|
||||
|
||||
disconnectButton
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.clipShape(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
)
|
||||
}
|
||||
|
||||
private struct PinecilStat: View {
|
||||
let title: LocalizedStringKey
|
||||
let value: String
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text(title)
|
||||
.foregroundColor(.secondary)
|
||||
.font(.caption)
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(value)
|
||||
.font(.caption).monospacedDigit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
82
PineTool/Views/SettingsView.swift
Normal file
82
PineTool/Views/SettingsView.swift
Normal file
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// SettingsView.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsView: View {
|
||||
@AppStorage("keep-awake") var keepAwake = true
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List {
|
||||
Section {
|
||||
Toggle("Keep Display Awake", isOn: $keepAwake)
|
||||
.tint(.accentColor)
|
||||
}
|
||||
|
||||
Section {
|
||||
Link(
|
||||
"Twitter",
|
||||
destination: URL(string: "https://twitter.com/lachyio")!
|
||||
)
|
||||
|
||||
Link(
|
||||
"Source Code",
|
||||
destination: URL(string: "https://github.com/lachlanbell/PineTool")!
|
||||
)
|
||||
|
||||
Link(
|
||||
"Troubleshooting",
|
||||
destination: URL(string: "https://lachy.io/pinetool/help")!
|
||||
)
|
||||
|
||||
Link(
|
||||
"Privacy Policy",
|
||||
destination: URL(string: "https://lachy.io/pinetool/privacy")!
|
||||
)
|
||||
}
|
||||
.tint(.primary)
|
||||
|
||||
Section("My Other Apps") {
|
||||
Link(destination: URL(string: "https://apps.apple.com/app/apple-store/id1260531874?pt=118741246&ct=pt&mt=8")!) {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
Image("PolymerLink")
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("Polymer for OctoPrint")
|
||||
.font(.subheadline)
|
||||
.bold()
|
||||
|
||||
Text("The nicest way to 3D print 😁")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.tint(.primary)
|
||||
}
|
||||
.navigationTitle("Settings")
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Text("Done")
|
||||
.bold()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
89
PineTool/Views/TemperaturePowerChart.swift
Normal file
89
PineTool/Views/TemperaturePowerChart.swift
Normal file
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// TemperaturePowerChart.swift
|
||||
// PineTool
|
||||
//
|
||||
// Created by Lachlan Bell on 22/4/2023.
|
||||
// Copyright © 2023 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Charts
|
||||
|
||||
struct TemperaturePowerChart: View {
|
||||
@EnvironmentObject var pinecilManager: PinecilManager
|
||||
|
||||
private let maxSamples = 60
|
||||
|
||||
private struct DataPoint {
|
||||
let index: Int
|
||||
let power: Double
|
||||
let temperature: Double
|
||||
}
|
||||
|
||||
private var data: [DataPoint] {
|
||||
let powerData = Array(pinecilManager.powerSamples.suffix(maxSamples))
|
||||
let temperatureData = Array(pinecilManager.temperatureSamples.suffix(maxSamples))
|
||||
|
||||
let sampleCount = min(powerData.count, temperatureData.count)
|
||||
|
||||
return Array(0..<sampleCount).map { index in
|
||||
return DataPoint(
|
||||
index: index,
|
||||
power: powerData[index],
|
||||
temperature: temperatureData[index]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Chart {
|
||||
ForEach(data, id: \.index) { dataPoint in
|
||||
LineMark(
|
||||
x: .value("", dataPoint.index),
|
||||
y: .value("Temperature", dataPoint.temperature / 450.0)
|
||||
)
|
||||
.foregroundStyle(by: .value("Value", "Temperature"))
|
||||
|
||||
LineMark(
|
||||
x: .value("", dataPoint.index),
|
||||
y: .value("Power", dataPoint.power / 90.0)
|
||||
)
|
||||
.foregroundStyle(by: .value("Value", "Power"))
|
||||
}
|
||||
.interpolationMethod(.catmullRom)
|
||||
}
|
||||
.chartForegroundStyleScale([
|
||||
"Temperature": .red,
|
||||
"Power": .blue
|
||||
])
|
||||
.chartYScale(domain: 0...1)
|
||||
.chartXAxis(.hidden)
|
||||
.chartYAxis {
|
||||
let defaultStride = Array(stride(from: 0, to: 1, by: 1.0/9.0))
|
||||
|
||||
let powerStride = Array(stride(from: 0, to: 90, by: 10))
|
||||
AxisMarks(position: .trailing, values: defaultStride) { axis in
|
||||
AxisGridLine()
|
||||
let value = powerStride[axis.index]
|
||||
AxisValueLabel("\(value) W", centered: false)
|
||||
}
|
||||
|
||||
let temperatureStride = Array(stride(from: 0, to: 450, by: 50))
|
||||
AxisMarks(position: .leading, values: defaultStride) { axis in
|
||||
AxisGridLine()
|
||||
let value = temperatureStride[axis.index]
|
||||
AxisValueLabel("\(value) ℃", centered: false)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity, idealHeight: 300)
|
||||
.background(Color(.tertiarySystemGroupedBackground))
|
||||
.clipShape(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
)
|
||||
}
|
||||
}
|
337
PineTool/Views/UIKit/TemperatureSetViewController.swift
Normal file
337
PineTool/Views/UIKit/TemperatureSetViewController.swift
Normal file
@@ -0,0 +1,337 @@
|
||||
//
|
||||
// TemperatureSetViewController.swift
|
||||
// Polymer
|
||||
//
|
||||
// Created by Lachlan Bell on 17/12/20.
|
||||
// Copyright © 2020 Lachlan Bell. All rights reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
// This Source Code Form is “Incompatible With Secondary Licenses”,
|
||||
// as defined by the Mozilla Public License, v. 2.0.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
import TinyConstraints
|
||||
import KeyboardGuide
|
||||
|
||||
// MARK: - UIKit Implementation
|
||||
class TemperatureSetViewController: UIViewController {
|
||||
|
||||
private let prevTemperature: UInt32?
|
||||
private let setCallback: (UInt32) -> Void
|
||||
private let validateCallback: ((UInt32) -> Bool)?
|
||||
|
||||
// MARK: - UI Elements
|
||||
lazy private var degreeLabel = UILabel()
|
||||
lazy private var dimmingView = UIView()
|
||||
lazy private var inputContainer = UIView()
|
||||
lazy private var textField = UITextField()
|
||||
|
||||
private var inputToolbar: UIToolbar!
|
||||
|
||||
init(
|
||||
temperature: UInt32?,
|
||||
setCallback: @escaping (UInt32) -> Void,
|
||||
validateCallback: ((UInt32) -> (Bool))? = nil
|
||||
) {
|
||||
self.prevTemperature = temperature
|
||||
self.setCallback = setCallback
|
||||
self.validateCallback = validateCallback
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
self.modalPresentationStyle = .overFullScreen
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
// MARK: - View Setup
|
||||
override func viewDidLoad() {
|
||||
self.transitioningDelegate = self
|
||||
|
||||
// Setup dimming view
|
||||
dimmingView.backgroundColor = .black
|
||||
self.view.addSubview(dimmingView)
|
||||
dimmingView.edgesToSuperview(usingSafeArea: false)
|
||||
|
||||
// Add dismiss gesture recogniser to background view
|
||||
let backgroundGestureRecognizer = UITapGestureRecognizer(
|
||||
target: self,
|
||||
action: #selector(closeTapped)
|
||||
)
|
||||
dimmingView.addGestureRecognizer(backgroundGestureRecognizer)
|
||||
|
||||
// Add container
|
||||
inputContainer.layer.cornerCurve = .continuous
|
||||
inputContainer.layer.cornerRadius = 12
|
||||
|
||||
inputContainer.layer.applyShadow(
|
||||
color: .black,
|
||||
alpha: 0.3,
|
||||
x: 0,
|
||||
y: 3,
|
||||
blur: 45,
|
||||
spread: 0
|
||||
)
|
||||
|
||||
inputContainer.backgroundColor = .secondarySystemBackground
|
||||
self.view.addSubview(inputContainer)
|
||||
inputContainer.centerXToSuperview()
|
||||
inputContainer.centerYToSuperview(offset: -30, priority: .defaultLow)
|
||||
|
||||
inputContainer.bottom(
|
||||
to: view.keyboardSafeArea.layoutGuide,
|
||||
offset: -30,
|
||||
relation: .equalOrLess,
|
||||
priority: .required
|
||||
)
|
||||
|
||||
inputContainer.width(170)
|
||||
inputContainer.height(55)
|
||||
|
||||
// Add background text view
|
||||
self.inputContainer.addSubview(textField)
|
||||
textField.delegate = self
|
||||
textField.tintColor = UIColor(named: "AccentColor")
|
||||
textField.centerYToSuperview()
|
||||
textField.left(to: inputContainer, offset: 15)
|
||||
textField.right(to: inputContainer, offset: -40)
|
||||
textField.backgroundColor = .clear
|
||||
textField.font = .systemFont(ofSize: 20, weight: .semibold)
|
||||
textField.keyboardType = .numberPad
|
||||
textField.addTarget(
|
||||
self,
|
||||
action: #selector(textFieldDidChange(_:)),
|
||||
for: .editingChanged
|
||||
)
|
||||
|
||||
if let prevTemperature {
|
||||
textField.placeholder = "\(prevTemperature)"
|
||||
}
|
||||
|
||||
// Add accessory toolbar
|
||||
// Toolbar needs an explicit frame with h >= 12 to avoid layout errors
|
||||
inputToolbar = UIToolbar(
|
||||
frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 35)
|
||||
)
|
||||
inputToolbar.setItems([
|
||||
UIBarButtonItem(
|
||||
barButtonSystemItem: .close,
|
||||
target: self,
|
||||
action: #selector(closeTapped)
|
||||
),
|
||||
UIBarButtonItem(
|
||||
barButtonSystemItem: .flexibleSpace,
|
||||
target: nil,
|
||||
action: nil
|
||||
),
|
||||
UIBarButtonItem(
|
||||
title: NSLocalizedString("Set", comment: "Set temperature"),
|
||||
style: .done,
|
||||
target: self,
|
||||
action: #selector(setTapped)
|
||||
)
|
||||
], animated: false)
|
||||
inputToolbar.sizeToFit()
|
||||
inputToolbar.items?.last?.isEnabled = false
|
||||
textField.inputAccessoryView = inputToolbar
|
||||
|
||||
// Add degrees label
|
||||
self.inputContainer.addSubview(degreeLabel)
|
||||
degreeLabel.text = "℃"
|
||||
degreeLabel.textColor = .secondaryLabel
|
||||
degreeLabel.font = .systemFont(ofSize: 20, weight: .semibold)
|
||||
degreeLabel.centerYToSuperview()
|
||||
degreeLabel.right(to: inputContainer, offset: -15)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
// Select text field
|
||||
textField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
@objc func closeTapped() {
|
||||
dismissView()
|
||||
}
|
||||
|
||||
func dismissView() {
|
||||
textField.resignFirstResponder()
|
||||
self.dismiss(animated: true)
|
||||
}
|
||||
|
||||
// MARK: - Input Handling
|
||||
@objc func textFieldDidChange(_ textField: UITextField) {
|
||||
// Change 'Set' button enabled state if text is valid
|
||||
inputToolbar.items?.last?.isEnabled = inputValid
|
||||
}
|
||||
|
||||
override func pressesBegan(
|
||||
_ presses: Set<UIPress>,
|
||||
with event: UIPressesEvent?
|
||||
) {
|
||||
super.pressesBegan(presses, with: event)
|
||||
|
||||
guard let key = presses.first?.key else { return }
|
||||
|
||||
// Dismiss on escape keypress
|
||||
if key.keyCode == .keyboardEscape {
|
||||
dismissView()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func setTapped() {
|
||||
guard inputValid else { return }
|
||||
|
||||
// Set temperature
|
||||
if let temperature = UInt32(textField.text ?? "") {
|
||||
setCallback(temperature)
|
||||
}
|
||||
|
||||
dismissView()
|
||||
}
|
||||
|
||||
var inputValid: Bool {
|
||||
guard let validateCallback = validateCallback else { return true }
|
||||
guard let value = UInt32(textField.text ?? "") else { return false }
|
||||
return validateCallback(value)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UITextFieldDelegate methods
|
||||
extension TemperatureSetViewController: UITextFieldDelegate {
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
if inputValid {
|
||||
setTapped()
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UIViewControllerTransitioningDelegate
|
||||
extension TemperatureSetViewController: UIViewControllerTransitioningDelegate {
|
||||
func animationController(
|
||||
forPresented presented: UIViewController,
|
||||
presenting: UIViewController,
|
||||
source: UIViewController
|
||||
) -> UIViewControllerAnimatedTransitioning? {
|
||||
return TemperatureSetAnimatedTransitioning(
|
||||
inputContainer: inputContainer,
|
||||
dimmingView: dimmingView,
|
||||
isReverse: false
|
||||
)
|
||||
}
|
||||
|
||||
func animationController(
|
||||
forDismissed dismissed: UIViewController
|
||||
) -> UIViewControllerAnimatedTransitioning? {
|
||||
return TemperatureSetAnimatedTransitioning(
|
||||
inputContainer: inputContainer,
|
||||
dimmingView: dimmingView,
|
||||
isReverse: true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UIViewControllerAnimatedTransitioning
|
||||
private class TemperatureSetAnimatedTransitioning: NSObject {
|
||||
|
||||
weak var inputContainer: UIView?
|
||||
weak var dimmingView: UIView?
|
||||
private let isReverse: Bool
|
||||
|
||||
init(inputContainer: UIView, dimmingView: UIView, isReverse: Bool) {
|
||||
self.inputContainer = inputContainer
|
||||
self.dimmingView = dimmingView
|
||||
self.isReverse = isReverse
|
||||
}
|
||||
}
|
||||
|
||||
extension TemperatureSetAnimatedTransitioning: UIViewControllerAnimatedTransitioning {
|
||||
|
||||
func transitionDuration(
|
||||
using transitionContext: UIViewControllerContextTransitioning?
|
||||
) -> TimeInterval {
|
||||
return isReverse ? 0.1 : 0.25
|
||||
}
|
||||
|
||||
func animateTransition(
|
||||
using transitionContext: UIViewControllerContextTransitioning
|
||||
) {
|
||||
let duration = self.transitionDuration(using: transitionContext)
|
||||
|
||||
guard let view = transitionContext.view(
|
||||
forKey: isReverse ? .from : .to
|
||||
) else { return }
|
||||
transitionContext.containerView.addSubview(view)
|
||||
|
||||
if isReverse {
|
||||
// Animate out
|
||||
UIView.animate(
|
||||
withDuration: duration,
|
||||
delay: 0,
|
||||
options: .curveEaseInOut,
|
||||
animations: {
|
||||
self.dimmingView?.alpha = 0
|
||||
self.inputContainer?.alpha = 0
|
||||
self.inputContainer?.transform = CGAffineTransform(scaleX: 0.85, y: 0.85)
|
||||
},
|
||||
completion: { _ in
|
||||
transitionContext.completeTransition(true)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
// Prepare UI for transition
|
||||
inputContainer?.alpha = 0.0
|
||||
inputContainer?.transform = CGAffineTransform(scaleX: 0.85, y: 0.85)
|
||||
dimmingView?.alpha = 0.0
|
||||
|
||||
// Animate in
|
||||
UIView.animate(
|
||||
withDuration: duration,
|
||||
delay: 0,
|
||||
options: .curveEaseInOut,
|
||||
animations: {
|
||||
self.dimmingView?.alpha = 0.6
|
||||
self.inputContainer?.alpha = 1
|
||||
self.inputContainer?.transform = .identity
|
||||
},
|
||||
completion: { _ in
|
||||
transitionContext.completeTransition(true)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CALayer+applyShadow extension
|
||||
extension CALayer {
|
||||
/// Apply a Sketch-style shadow to a CALayer
|
||||
func applyShadow(
|
||||
color: UIColor = .black,
|
||||
alpha: Float = 0.25,
|
||||
x: CGFloat = 0,
|
||||
y: CGFloat = 2,
|
||||
blur: CGFloat = 8,
|
||||
spread: CGFloat = 0
|
||||
) {
|
||||
shadowColor = color.cgColor
|
||||
shadowOpacity = alpha
|
||||
shadowOffset = CGSize(width: x, height: y)
|
||||
shadowRadius = blur / 2.0
|
||||
if spread == 0 {
|
||||
shadowPath = nil
|
||||
} else {
|
||||
let dx = -spread
|
||||
let rect = bounds.insetBy(dx: dx, dy: dx)
|
||||
shadowPath = UIBezierPath(rect: rect).cgPath
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user