diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 6bb33b13..c1f5c1b8 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -320,6 +320,7 @@ func upsertDeviceConfigPacket(config: Meshtastic.Config.DeviceConfig, nodeNum: I newDeviceConfig.buzzerGpio = Int32(config.buzzerGpio) newDeviceConfig.rebroadcastMode = Int32(config.rebroadcastMode.rawValue) newDeviceConfig.nodeInfoBroadcastSecs = Int32(config.nodeInfoBroadcastSecs) + newDeviceConfig.doubleTapAsButtonPress = config.doubleTapAsButtonPress fetchedNode[0].deviceConfig = newDeviceConfig } else { fetchedNode[0].deviceConfig?.role = Int32(config.role.rawValue) @@ -328,6 +329,7 @@ func upsertDeviceConfigPacket(config: Meshtastic.Config.DeviceConfig, nodeNum: I fetchedNode[0].deviceConfig?.buttonGpio = Int32(config.buttonGpio) fetchedNode[0].deviceConfig?.buzzerGpio = Int32(config.buzzerGpio) fetchedNode[0].deviceConfig?.rebroadcastMode = Int32(config.rebroadcastMode.rawValue) + fetchedNode[0].deviceConfig?.doubleTapAsButtonPress = config.doubleTapAsButtonPress fetchedNode[0].deviceConfig?.nodeInfoBroadcastSecs = Int32(config.nodeInfoBroadcastSecs) } do { diff --git a/Meshtastic/Views/Settings/Config/DeviceConfig.swift b/Meshtastic/Views/Settings/Config/DeviceConfig.swift index e9e5406c..79398ec3 100644 --- a/Meshtastic/Views/Settings/Config/DeviceConfig.swift +++ b/Meshtastic/Views/Settings/Config/DeviceConfig.swift @@ -25,6 +25,7 @@ struct DeviceConfig: View { @State var serialEnabled = true @State var debugLogEnabled = false @State var rebroadcastMode = 0 + @State var doubleTapAsButtonPress = false var body: some View { @@ -80,6 +81,13 @@ struct DeviceConfig: View { Text(RebroadcastModes(rawValue: rebroadcastMode)?.description ?? "") .foregroundColor(.gray) .font(.caption) + + Toggle(isOn: $doubleTapAsButtonPress) { + Label("Double Tap as Button", systemImage: "hand.tap") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + Text("Treat double tap on supported accelerometers as a user button press.") + .font(.caption) } Section(header: Text("Debug")) { @@ -208,6 +216,7 @@ struct DeviceConfig: View { dc.buttonGpio = UInt32(buttonGPIO) dc.buzzerGpio = UInt32(buzzerGPIO) dc.rebroadcastMode = RebroadcastModes(rawValue: rebroadcastMode)?.protoEnumValue() ?? RebroadcastModes.all.protoEnumValue() + dc.doubleTapAsButtonPress = doubleTapAsButtonPress let adminMessageId = bleManager.saveDeviceConfig(config: dc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0) if adminMessageId > 0 { @@ -285,6 +294,13 @@ struct DeviceConfig: View { if newRebroadcastMode != node!.deviceConfig!.rebroadcastMode { hasChanges = true } } } + .onChange(of: doubleTapAsButtonPress) { newDoubleTapAsButtonPress in + + if node != nil && node!.deviceConfig != nil { + + if newDoubleTapAsButtonPress != node!.deviceConfig!.doubleTapAsButtonPress { hasChanges = true } + } + } } func setDeviceValues() { self.deviceRole = Int(node?.deviceConfig?.role ?? 0) @@ -293,6 +309,7 @@ struct DeviceConfig: View { self.buttonGPIO = Int(node?.deviceConfig?.buttonGpio ?? 0) self.buzzerGPIO = Int(node?.deviceConfig?.buzzerGpio ?? 0) self.rebroadcastMode = Int(node?.deviceConfig?.rebroadcastMode ?? 0) + self.doubleTapAsButtonPress = node!.deviceConfig?.doubleTapAsButtonPress ?? false self.hasChanges = false } }