mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Add speed and heading to location manager
This commit is contained in:
parent
7a75a3199a
commit
277d210532
5 changed files with 45 additions and 14 deletions
|
|
@ -688,6 +688,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
positionPacket.longitudeI = Int32(LocationHelper.currentLocation.longitude * 1e7)
|
||||
positionPacket.time = UInt32(LocationHelper.currentTimestamp.timeIntervalSince1970)
|
||||
positionPacket.altitude = Int32(LocationHelper.currentAltitude)
|
||||
|
||||
|
||||
var meshPacket = MeshPacket()
|
||||
meshPacket.to = UInt32(destNum)
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ class LocationHelper: NSObject, ObservableObject {
|
|||
static let DefaultLocation = CLLocationCoordinate2D(latitude: 37.3346, longitude: -122.0090)
|
||||
|
||||
static let DefaultAltitude = CLLocationDistance(integerLiteral: 0)
|
||||
static let DefaultSpeed = CLLocationSpeed(integerLiteral: 0)
|
||||
static let DefaultHeading = CLLocationDirection(integerLiteral: 0)
|
||||
|
||||
static var currentLocation: CLLocationCoordinate2D {
|
||||
|
||||
guard let location = shared.locationManager.location else {
|
||||
guard let location = shared.locationManager.location else {
|
||||
return DefaultLocation
|
||||
}
|
||||
return location.coordinate
|
||||
|
|
@ -25,6 +27,22 @@ class LocationHelper: NSObject, ObservableObject {
|
|||
return altitude
|
||||
}
|
||||
|
||||
static var currentSpeed: CLLocationSpeed {
|
||||
|
||||
guard let speed = shared.locationManager.location?.speed else {
|
||||
return DefaultSpeed
|
||||
}
|
||||
return speed
|
||||
}
|
||||
|
||||
static var currentHeading: CLLocationDirection {
|
||||
|
||||
guard let speed = shared.locationManager.location?.course else {
|
||||
return DefaultHeading
|
||||
}
|
||||
return speed
|
||||
}
|
||||
|
||||
static var currentTimestamp: Date {
|
||||
|
||||
guard let timestamp = shared.locationManager.location?.timestamp else {
|
||||
|
|
|
|||
|
|
@ -189,11 +189,11 @@ struct LoRaConfig: View {
|
|||
|
||||
@State private var isPresentingSaveConfirm: Bool = false
|
||||
@State var initialLoad: Bool = true
|
||||
@State var hasChanges = false
|
||||
|
||||
@State var region = 0
|
||||
@State var modemPreset = 0
|
||||
@State var hopLimit = 0
|
||||
@State var hasChanges = false
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
|
@ -242,6 +242,7 @@ struct LoRaConfig: View {
|
|||
isPresentingSaveConfirm = true
|
||||
|
||||
} label: {
|
||||
|
||||
Label("Save", systemImage: "square.and.arrow.down")
|
||||
}
|
||||
.disabled(bleManager.connectedPeripheral == nil || !hasChanges)
|
||||
|
|
@ -250,6 +251,7 @@ struct LoRaConfig: View {
|
|||
.controlSize(.large)
|
||||
.padding()
|
||||
.confirmationDialog(
|
||||
|
||||
"Are you sure?",
|
||||
isPresented: $isPresentingSaveConfirm
|
||||
) {
|
||||
|
|
@ -314,7 +316,6 @@ struct LoRaConfig: View {
|
|||
hasChanges = true
|
||||
}
|
||||
}
|
||||
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ struct PositionConfig: View {
|
|||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
|
||||
var node: NodeInfoEntity
|
||||
|
||||
@State var smartPositionEnabled = true
|
||||
@State var deviceGpsEnabled = true
|
||||
@State var fixedPosition = false
|
||||
|
|
@ -181,6 +183,8 @@ struct PositionConfig: View {
|
|||
|
||||
}
|
||||
}
|
||||
.disabled(!(node.myInfo?.hasGps ?? true))
|
||||
|
||||
Section(header: Text("Position Packet")) {
|
||||
|
||||
Toggle(isOn: $smartPositionEnabled) {
|
||||
|
|
@ -213,44 +217,44 @@ struct PositionConfig: View {
|
|||
|
||||
Label("Altitude", systemImage: "arrow.up")
|
||||
}
|
||||
.toggleStyle(DefaultToggleStyle())
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.listRowSeparator(.visible)
|
||||
|
||||
Toggle(isOn: $includePosSatsinview) {
|
||||
|
||||
Label("Number of satellites", systemImage: "skew")
|
||||
}
|
||||
.toggleStyle(DefaultToggleStyle())
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.disabled(!(node.myInfo?.hasGps ?? true))
|
||||
.listRowSeparator(.visible)
|
||||
|
||||
Toggle(isOn: $includePosSeqNos) { //64
|
||||
|
||||
Label("Sequence number", systemImage: "number")
|
||||
}
|
||||
.toggleStyle(DefaultToggleStyle())
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.listRowSeparator(.visible)
|
||||
|
||||
Toggle(isOn: $includePosTimestamp) { //128
|
||||
|
||||
Label("Timestamp", systemImage: "clock")
|
||||
}
|
||||
.toggleStyle(DefaultToggleStyle())
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.listRowSeparator(.visible)
|
||||
|
||||
Toggle(isOn: $includePosHeading) { //128
|
||||
|
||||
Label("Vehicle heading", systemImage: "location.circle")
|
||||
}
|
||||
.toggleStyle(DefaultToggleStyle())
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.listRowSeparator(.visible)
|
||||
|
||||
Toggle(isOn: $includePosSpeed) { //128
|
||||
|
||||
Label("Vehicle speed", systemImage: "speedometer")
|
||||
}
|
||||
.toggleStyle(DefaultToggleStyle())
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.listRowSeparator(.visible)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ struct Settings: View {
|
|||
NavigationView {
|
||||
List {
|
||||
|
||||
let connectedNodeNum = bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.num : 0
|
||||
|
||||
Section("General") {
|
||||
NavigationLink {
|
||||
AppSettings()
|
||||
|
|
@ -43,7 +45,7 @@ struct Settings: View {
|
|||
}
|
||||
}
|
||||
|
||||
Section("Radio Configuration (Non-Functional Interaction Previews except for LoRa Config)") {
|
||||
Section("Radio Configuration") {
|
||||
|
||||
NavigationLink {
|
||||
DeviceConfig()
|
||||
|
|
@ -53,6 +55,8 @@ struct Settings: View {
|
|||
.symbolRenderingMode(.hierarchical)
|
||||
Text("Device")
|
||||
}
|
||||
.disabled(bleManager.connectedPeripheral == nil)
|
||||
|
||||
NavigationLink {
|
||||
DisplayConfig()
|
||||
} label: {
|
||||
|
|
@ -61,8 +65,7 @@ struct Settings: View {
|
|||
.symbolRenderingMode(.hierarchical)
|
||||
Text("Display (Device Screen)")
|
||||
}
|
||||
|
||||
let connectedNodeNum = bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.num : 0
|
||||
.disabled(bleManager.connectedPeripheral == nil)
|
||||
|
||||
NavigationLink() {
|
||||
|
||||
|
|
@ -77,7 +80,7 @@ struct Settings: View {
|
|||
.disabled(bleManager.connectedPeripheral == nil)
|
||||
|
||||
NavigationLink {
|
||||
PositionConfig()
|
||||
PositionConfig(node: nodes.first(where: { $0.num == connectedNodeNum }) ?? NodeInfoEntity())
|
||||
} label: {
|
||||
|
||||
Image(systemName: "location")
|
||||
|
|
@ -85,6 +88,7 @@ struct Settings: View {
|
|||
|
||||
Text("Position")
|
||||
}
|
||||
.disabled(bleManager.connectedPeripheral == nil)
|
||||
}
|
||||
Section("Module Configuration") {
|
||||
|
||||
|
|
@ -107,6 +111,8 @@ struct Settings: View {
|
|||
|
||||
Text("Range Test")
|
||||
}
|
||||
.disabled(!(nodes.first(where: { $0.num == connectedNodeNum })?.myInfo?.hasWifi ?? true) || bleManager.connectedPeripheral == nil)
|
||||
|
||||
NavigationLink {
|
||||
TelemetryConfig()
|
||||
} label: {
|
||||
|
|
@ -116,6 +122,7 @@ struct Settings: View {
|
|||
|
||||
Text("Telemetry (Sensors)")
|
||||
}
|
||||
.disabled(true)
|
||||
}
|
||||
// Not Implemented:
|
||||
// External Notifications - Not Working
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue