From cbd6b2c242d889d922c73c029fe1a14e5e67a09b Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 13 Jun 2022 14:39:21 -0700 Subject: [PATCH 1/4] Size updates for larger short name --- MeshtasticApple/Views/Helpers/CircleText.swift | 2 +- MeshtasticApple/Views/Messages/Contacts.swift | 2 +- MeshtasticApple/Views/Messages/UserMessageList.swift | 4 ++-- MeshtasticApple/Views/Settings/PowerConfig.swift | 12 +++++++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/MeshtasticApple/Views/Helpers/CircleText.swift b/MeshtasticApple/Views/Helpers/CircleText.swift index 4ada7061..88a39f4c 100644 --- a/MeshtasticApple/Views/Helpers/CircleText.swift +++ b/MeshtasticApple/Views/Helpers/CircleText.swift @@ -8,7 +8,7 @@ import SwiftUI struct CircleText: View { var text: String var color: Color - var circleSize: CGFloat? = 50 + var circleSize: CGFloat? = 60 var fontSize: CGFloat? = 22 var body: some View { diff --git a/MeshtasticApple/Views/Messages/Contacts.swift b/MeshtasticApple/Views/Messages/Contacts.swift index 007dd6ad..f4f2b0e7 100644 --- a/MeshtasticApple/Views/Messages/Contacts.swift +++ b/MeshtasticApple/Views/Messages/Contacts.swift @@ -100,7 +100,7 @@ struct Contacts: View { VStack { - CircleText(text: user.shortName ?? "???", color: Color.blue) + CircleText(text: user.shortName ?? "????", color: Color.blue) } .padding(.trailing) diff --git a/MeshtasticApple/Views/Messages/UserMessageList.swift b/MeshtasticApple/Views/Messages/UserMessageList.swift index f651f8cf..d410c43f 100644 --- a/MeshtasticApple/Views/Messages/UserMessageList.swift +++ b/MeshtasticApple/Views/Messages/UserMessageList.swift @@ -74,7 +74,7 @@ struct UserMessageList: View { if currentUser { Spacer(minLength:50) } if !currentUser { - CircleText(text: message.fromUser?.shortName ?? "????", color: currentUser ? .accentColor : Color(.darkGray), circleSize: 36, fontSize: 16).padding(.all, 5) + CircleText(text: message.fromUser?.shortName ?? "????", color: currentUser ? .accentColor : Color(.darkGray), circleSize: 46, fontSize: 16).padding(.all, 5) } VStack(alignment: currentUser ? .trailing : .leading) { @@ -444,7 +444,7 @@ struct UserMessageList: View { HStack { - CircleText(text: user.shortName ?? "???", color: .blue, circleSize: 42, fontSize: 20).fixedSize() + CircleText(text: user.shortName ?? "???", color: .blue, circleSize: 42, fontSize: 16).fixedSize() Text(user.longName ?? "Unknown").font(.headline).fixedSize() } } diff --git a/MeshtasticApple/Views/Settings/PowerConfig.swift b/MeshtasticApple/Views/Settings/PowerConfig.swift index d47461a6..809eb091 100644 --- a/MeshtasticApple/Views/Settings/PowerConfig.swift +++ b/MeshtasticApple/Views/Settings/PowerConfig.swift @@ -21,7 +21,13 @@ struct PowerConfig: View { VStack { Form { - + + Section(header: Text("Warning")) { + + Text("These power settings are designed for and and are only useful in very specific mostly solar use cases and should not be enabled by the majority of users, expecially if you are using your device as a messaging handset paired with a phone.") + .font(.callout) + .listRowSeparator(.visible) + } Section(header: Text("States")) { Toggle(isOn: $isPowerSaving) { @@ -30,7 +36,7 @@ struct PowerConfig: View { } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) .disabled(isAlwaysPowered) - Text("If set, we are powered from a low-current source (i.e. solar), so even if it looks like we have power flowing in we should try to minimize power consumption as much as possible.") + Text("If set, we are powered from a low-current source (i.e. solar) and do not intend on using a client to connect via BLE, WiFi or Serial. This setting is assumed and unnessary if you have turned on Router mode.") .font(.caption) .listRowSeparator(.visible) @@ -40,7 +46,7 @@ struct PowerConfig: View { } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) .disabled(isPowerSaving) - Text("Circumvents the logic block for determining whether the device is powered or not. Useful for devices with finicky ADC issues on the battery sense pins, or no battery pin at all.") + Text("Circumvents the logic block for determining whether the device is powered or not. Useful for devices with finicky ADC issues on the battery sense pins, or no battery pin at all. This mode increases battery use substantially") .font(.caption) .listRowSeparator(.visible) From d49daa0f5726ddc6663775363d8e4dfbcc258a14 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 13 Jun 2022 18:54:16 -0700 Subject: [PATCH 2/4] Update circle text to support 4 letter codes --- MeshtasticApple/Views/Helpers/CircleText.swift | 2 +- MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MeshtasticApple/Views/Helpers/CircleText.swift b/MeshtasticApple/Views/Helpers/CircleText.swift index 88a39f4c..88bb78f4 100644 --- a/MeshtasticApple/Views/Helpers/CircleText.swift +++ b/MeshtasticApple/Views/Helpers/CircleText.swift @@ -9,7 +9,7 @@ struct CircleText: View { var text: String var color: Color var circleSize: CGFloat? = 60 - var fontSize: CGFloat? = 22 + var fontSize: CGFloat? = 20 var body: some View { diff --git a/MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift b/MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift index d9744158..4500052a 100644 --- a/MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift +++ b/MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift @@ -25,7 +25,7 @@ class PositionAnnotation: NSObject, MKAnnotation { class PositionAnnotationView: MKAnnotationView { - private let annotationFrame = CGRect(x: 0, y: 0, width: 32, height: 32) + private let annotationFrame = CGRect(x: 0, y: 0, width: 40, height: 40cen) private let label: UILabel override init(annotation: MKAnnotation?, reuseIdentifier: String?) { @@ -52,7 +52,7 @@ class PositionAnnotationView: MKAnnotationView { override func draw(_ rect: CGRect) { guard let context = UIGraphicsGetCurrentContext() else { return } - let circleRect = CGRect(x: 1, y: 1, width: 30, height: 30) + let circleRect = CGRect(x: 1, y: 1, width: 38, height: 38) context.setFillColor(CGColor(red: 0, green: 0.5, blue: 1.0, alpha: 1.0)) From fbddbe341cd1938214eeb47bf766a6abf9b5d19a Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 13 Jun 2022 20:43:51 -0700 Subject: [PATCH 3/4] Live mockup of device config --- Meshtastic Apple.xcodeproj/project.pbxproj | 4 + .../Map/Custom/PositionAnnotationView.swift | 2 +- MeshtasticApple/Views/Nodes/NodeDetail.swift | 12 ++- .../Views/Settings/DeviceConfig.swift | 91 +++++++++++++++++++ .../Views/Settings/PositionConfig.swift | 4 +- .../Views/Settings/PowerConfig.swift | 2 +- MeshtasticApple/Views/Settings/Settings.swift | 8 ++ 7 files changed, 114 insertions(+), 9 deletions(-) create mode 100644 MeshtasticApple/Views/Settings/DeviceConfig.swift diff --git a/Meshtastic Apple.xcodeproj/project.pbxproj b/Meshtastic Apple.xcodeproj/project.pbxproj index 9a440c6e..9f4cc380 100644 --- a/Meshtastic Apple.xcodeproj/project.pbxproj +++ b/Meshtastic Apple.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ DD2E65262767A01F00E45FC5 /* NodeDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD2E65252767A01F00E45FC5 /* NodeDetail.swift */; }; DD3501892852FC3B000FC853 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD3501882852FC3B000FC853 /* Settings.swift */; }; DD35018B2852FC79000FC853 /* UserSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD35018A2852FC79000FC853 /* UserSettings.swift */; }; + DD41582628582E9B009B0E59 /* DeviceConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD41582528582E9B009B0E59 /* DeviceConfig.swift */; }; DD47E3CE26F103C600029299 /* NodeList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3CD26F103C600029299 /* NodeList.swift */; }; DD47E3D626F17ED900029299 /* CircleText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3D526F17ED900029299 /* CircleText.swift */; }; DD47E3D926F3093800029299 /* MessageBubble.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3D826F3093800029299 /* MessageBubble.swift */; }; @@ -103,6 +104,7 @@ DD2E65252767A01F00E45FC5 /* NodeDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeDetail.swift; sourceTree = ""; }; DD3501882852FC3B000FC853 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = ""; }; DD35018A2852FC79000FC853 /* UserSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSettings.swift; sourceTree = ""; }; + DD41582528582E9B009B0E59 /* DeviceConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceConfig.swift; sourceTree = ""; }; DD45C77427BD4EF80011784F /* MeshtasticDataModel v2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModel v2.xcdatamodel"; sourceTree = ""; }; DD47E3CD26F103C600029299 /* NodeList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeList.swift; sourceTree = ""; }; DD47E3D526F17ED900029299 /* CircleText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleText.swift; sourceTree = ""; }; @@ -230,6 +232,7 @@ DD3501882852FC3B000FC853 /* Settings.swift */, DD4A911D2708C65400501B7E /* AppSettings.swift */, DD6B85A728009258000ACD6B /* ShareChannel.swift */, + DD41582528582E9B009B0E59 /* DeviceConfig.swift */, DD8EBF42285058FA00426DCA /* DisplayConfig.swift */, DD2553562855B02500E55709 /* LoRaConfig.swift */, DD2553582855B52700E55709 /* PositionConfig.swift */, @@ -596,6 +599,7 @@ DDAF8C5D26ED09490058C060 /* portnums.pb.swift in Sources */, DD9D8F2F2764403B00080993 /* Meshtastic.xcdatamodeld in Sources */, DD25535D285666C700E55709 /* PowerConfig.swift in Sources */, + DD41582628582E9B009B0E59 /* DeviceConfig.swift in Sources */, DD1BF2F92776FE2E008C8D2F /* UserMessageList.swift in Sources */, DDB2CC6E27F3EB47009C5FCC /* telemetry.pb.swift in Sources */, DD23A50F26FD1B4400D9B90C /* PeripheralModel.swift in Sources */, diff --git a/MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift b/MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift index 4500052a..47c20197 100644 --- a/MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift +++ b/MeshtasticApple/Views/Map/Custom/PositionAnnotationView.swift @@ -25,7 +25,7 @@ class PositionAnnotation: NSObject, MKAnnotation { class PositionAnnotationView: MKAnnotationView { - private let annotationFrame = CGRect(x: 0, y: 0, width: 40, height: 40cen) + private let annotationFrame = CGRect(x: 0, y: 0, width: 40, height: 40) private let label: UILabel override init(annotation: MKAnnotation?, reuseIdentifier: String?) { diff --git a/MeshtasticApple/Views/Nodes/NodeDetail.swift b/MeshtasticApple/Views/Nodes/NodeDetail.swift index a1008e74..aa69dd53 100644 --- a/MeshtasticApple/Views/Nodes/NodeDetail.swift +++ b/MeshtasticApple/Views/Nodes/NodeDetail.swift @@ -219,11 +219,13 @@ struct NodeDetail: View { .foregroundColor(.gray) .fixedSize() } - - Text(String(format: "%.2f", mostRecent.voltage) + " V") - .font(.title3) - .foregroundColor(.gray) - .fixedSize() + if mostRecent.voltage > 0 { + + Text(String(format: "%.2f", mostRecent.voltage) + " V") + .font(.title3) + .foregroundColor(.gray) + .fixedSize() + } } .padding(5) } diff --git a/MeshtasticApple/Views/Settings/DeviceConfig.swift b/MeshtasticApple/Views/Settings/DeviceConfig.swift new file mode 100644 index 00000000..ae734c68 --- /dev/null +++ b/MeshtasticApple/Views/Settings/DeviceConfig.swift @@ -0,0 +1,91 @@ +// +// DeviceConfig.swift +// Meshtastic Apple +// +// Copyright (c) Garth Vander Houwen 6/13/22. +// +import SwiftUI + +// Default of 0 is One Minute +enum DeviceRoles: Int, CaseIterable, Identifiable { + + case client = 0 + case clientMute = 1 + case router = 2 + case routerClient = 3 + + var id: Int { self.rawValue } + var description: String { + get { + switch self { + + case .client: + return "Client (default)" + case .clientMute: + return "Client Mute - Packets will not hop over this node, does not contribute to routing packets for mesh." + case .router: + return "Router - Mesh packets will prefer to be routed over this node. This node will not be used by client apps. The wifi/ble radios and the oled screen will be put to sleep." + case .routerClient: + return "Router Client - Mesh packets will prefer to be routed over this node. The Router Client can be used as both a Router and an app connected Client." + } + } + } +} + +struct DeviceConfig: View { + + @Environment(\.managedObjectContext) var context + @EnvironmentObject var bleManager: BLEManager + + @State var deviceRole = 0 + @State var serialEnabled = true + @State var debugLogEnabled = false + + var body: some View { + + VStack { + + Form { + + Section(header: Text("Options")) { + + Picker("Device Role", selection: $deviceRole ) { + ForEach(DeviceRoles.allCases) { dr in + Text(dr.description) + } + } + .pickerStyle(InlinePickerStyle()) + .padding(.top, 10) + .padding(.bottom, 10) + } + + Section(header: Text("Debug")) { + + Toggle(isOn: $serialEnabled) { + + Label("Serial Console", systemImage: "terminal") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + + Toggle(isOn: $debugLogEnabled) { + + Label("Debug Log", systemImage: "ant.fill") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + } + } + .navigationTitle("Device Config") + .navigationBarItems(trailing: + + ZStack { + + ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.lastFourCode : "????") + }) + .onAppear { + + self.bleManager.context = context + } + .navigationViewStyle(StackNavigationViewStyle()) + } + } +} diff --git a/MeshtasticApple/Views/Settings/PositionConfig.swift b/MeshtasticApple/Views/Settings/PositionConfig.swift index e511c7b1..9b9d55a0 100644 --- a/MeshtasticApple/Views/Settings/PositionConfig.swift +++ b/MeshtasticApple/Views/Settings/PositionConfig.swift @@ -124,7 +124,7 @@ struct PositionConfig: View { Form { - Section(header: Text("Device GPS Options")) { + Section(header: Text("Device GPS")) { Toggle(isOn: $deviceGpsEnabled) { @@ -172,7 +172,7 @@ struct PositionConfig: View { } } - Section(header: Text("Position Packet Options")) { + Section(header: Text("Position Packet")) { Toggle(isOn: $smartPositionEnabled) { diff --git a/MeshtasticApple/Views/Settings/PowerConfig.swift b/MeshtasticApple/Views/Settings/PowerConfig.swift index 809eb091..ea4d909a 100644 --- a/MeshtasticApple/Views/Settings/PowerConfig.swift +++ b/MeshtasticApple/Views/Settings/PowerConfig.swift @@ -24,7 +24,7 @@ struct PowerConfig: View { Section(header: Text("Warning")) { - Text("These power settings are designed for and and are only useful in very specific mostly solar use cases and should not be enabled by the majority of users, expecially if you are using your device as a messaging handset paired with a phone.") + Text("These power settings are designed for and and are only useful mostly for solar use cases. Do not use these settings if you are planning on using your device for messaging paired with a phone.") .font(.callout) .listRowSeparator(.visible) } diff --git a/MeshtasticApple/Views/Settings/Settings.swift b/MeshtasticApple/Views/Settings/Settings.swift index cbedcebd..7d2d78cb 100644 --- a/MeshtasticApple/Views/Settings/Settings.swift +++ b/MeshtasticApple/Views/Settings/Settings.swift @@ -37,6 +37,14 @@ struct Settings: View { Section("Radio Configuration (Non-Functional Interaction Previews)") { + NavigationLink { + DeviceConfig() + } label: { + + Image(systemName: "flipphone") + .symbolRenderingMode(.hierarchical) + Text("Device") + } NavigationLink { DisplayConfig() } label: { From 24642e8c45ee65ef59d7bb182af738ad82be2486 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 13 Jun 2022 21:37:39 -0700 Subject: [PATCH 4/4] Simplify labels --- MeshtasticApple/Views/Settings/PositionConfig.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MeshtasticApple/Views/Settings/PositionConfig.swift b/MeshtasticApple/Views/Settings/PositionConfig.swift index 9b9d55a0..c0144bef 100644 --- a/MeshtasticApple/Views/Settings/PositionConfig.swift +++ b/MeshtasticApple/Views/Settings/PositionConfig.swift @@ -133,7 +133,7 @@ struct PositionConfig: View { .toggleStyle(SwitchToggleStyle(tint: .accentColor)) if deviceGpsEnabled { - Picker("GPS Update Interval", selection: $gpsUpdateInterval) { + Picker("Update Interval", selection: $gpsUpdateInterval) { ForEach(GpsUpdateIntervals.allCases) { ui in Text(ui.description) } @@ -144,7 +144,7 @@ struct PositionConfig: View { .font(.caption) .listRowSeparator(.visible) - Picker("GPS Attempt Time", selection: $gpsAttemptTime) { + Picker("Attempt Time", selection: $gpsAttemptTime) { ForEach(GpsAttemptTimes.allCases) { at in Text(at.description) }