diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index ea0af322..14e3fff6 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -222,6 +222,7 @@ DDC2E1A626CEB3400042C5E4 /* LocationHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationHelper.swift; sourceTree = ""; }; DDC3B273283F411B00AC321C /* LastHeardText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LastHeardText.swift; sourceTree = ""; }; DDC4D567275499A500A4208E /* Persistence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = ""; }; + DDCDC69A29467643004C1DDA /* MeshtasticDataModelV3.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV3.xcdatamodel; sourceTree = ""; }; DDCE4E2B2869F92900BE9F8F /* UserConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserConfig.swift; sourceTree = ""; }; DDCFF600285453A7005FA625 /* localonly.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = localonly.pb.swift; sourceTree = ""; }; DDD3BBD4292D763200D609B3 /* MeshtasticTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeshtasticTests.swift; sourceTree = ""; }; @@ -1201,10 +1202,11 @@ DD3CC6BA28E366DF00FA9159 /* Meshtastic.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + DDCDC69A29467643004C1DDA /* MeshtasticDataModelV3.xcdatamodel */, DD5D0A9A2931AD6B00F7EA61 /* MeshtasticDataModelV2.xcdatamodel */, DD3CC6BB28E366DF00FA9159 /* MeshtasticDataModel.xcdatamodel */, ); - currentVersion = DD5D0A9A2931AD6B00F7EA61 /* MeshtasticDataModelV2.xcdatamodel */; + currentVersion = DDCDC69A29467643004C1DDA /* MeshtasticDataModelV3.xcdatamodel */; name = Meshtastic.xcdatamodeld; path = Meshtastic/Meshtastic.xcdatamodeld; sourceTree = ""; diff --git a/Meshtastic/Enums/DisplayEnums.swift b/Meshtastic/Enums/DisplayEnums.swift index c9c30bd0..a1a6103b 100644 --- a/Meshtastic/Enums/DisplayEnums.swift +++ b/Meshtastic/Enums/DisplayEnums.swift @@ -26,7 +26,6 @@ enum ScreenUnits: Int, CaseIterable, Identifiable { func protoEnumValue() -> Config.DisplayConfig.DisplayUnits { switch self { - case .metric: return Config.DisplayConfig.DisplayUnits.metric case .imperial: @@ -67,7 +66,6 @@ enum ScreenOnIntervals: Int, CaseIterable, Identifiable { } } } - // Default of 0 is off enum ScreenCarouselIntervals: Int, CaseIterable, Identifiable { @@ -97,4 +95,37 @@ enum ScreenCarouselIntervals: Int, CaseIterable, Identifiable { } } } + +} +// Default of 0 is auto +enum OledTypes: Int, CaseIterable, Identifiable { + + case auto = 0 + case ssd1306 = 1 + case sh1106 = 2 + + var id: Int { self.rawValue } + var description: String { + get { + switch self { + case .auto: + return "Automatic Detection" + case .ssd1306: + return "SSD 1306" + case .sh1106: + return "SH 1106" + } + } + } + func protoEnumValue() -> Config.DisplayConfig.OledType { + + switch self { + case .auto: + return Config.DisplayConfig.OledType.oledAuto + case .ssd1306: + return Config.DisplayConfig.OledType.oledSsd1306 + case .sh1106: + return Config.DisplayConfig.OledType.oledSh1106 + } + } } diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index ae21e97e..67eb547f 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -123,6 +123,7 @@ func localConfig (config: Config, context:NSManagedObjectContext, nodeNum: Int64 newDisplayConfig.screenCarouselInterval = Int32(config.display.autoScreenCarouselSecs) newDisplayConfig.compassNorthTop = config.display.compassNorthTop newDisplayConfig.flipScreen = config.display.flipScreen + newDisplayConfig.oledType = Int32(config.display.oled.rawValue) fetchedNode[0].displayConfig = newDisplayConfig } else { @@ -132,6 +133,7 @@ func localConfig (config: Config, context:NSManagedObjectContext, nodeNum: Int64 fetchedNode[0].displayConfig?.screenCarouselInterval = Int32(config.display.autoScreenCarouselSecs) fetchedNode[0].displayConfig?.compassNorthTop = config.display.compassNorthTop fetchedNode[0].displayConfig?.flipScreen = config.display.flipScreen + fetchedNode[0].displayConfig?.oledType = Int32(config.display.oled.rawValue) } do { diff --git a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion index 3bba9dce..d57dfe2f 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion +++ b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - MeshtasticDataModelV2.xcdatamodel + MeshtasticDataModelV3.xcdatamodel diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV3.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV3.xcdatamodel/contents new file mode 100644 index 00000000..f6e38028 --- /dev/null +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV3.xcdatamodel/contents @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meshtastic/Views/Settings/Config/DisplayConfig.swift b/Meshtastic/Views/Settings/Config/DisplayConfig.swift index 61b420c2..318bb111 100644 --- a/Meshtastic/Views/Settings/Config/DisplayConfig.swift +++ b/Meshtastic/Views/Settings/Config/DisplayConfig.swift @@ -23,6 +23,7 @@ struct DisplayConfig: View { @State var gpsFormat = 0 @State var compassNorthTop = false @State var flipScreen = false + @State var oledType = 0 var body: some View { @@ -65,6 +66,14 @@ struct DisplayConfig: View { .toggleStyle(SwitchToggleStyle(tint: .accentColor)) Text("Flip screen vertically") .font(.caption) + Picker("OLED Type", selection: $oledType ) { + ForEach(OledTypes.allCases) { ot in + Text(ot.description) + } + } + .pickerStyle(DefaultPickerStyle()) + Text("Override automatic OLED screen detection.") + .font(.caption) } Section(header: Text("Format")) { @@ -108,6 +117,7 @@ struct DisplayConfig: View { dc.autoScreenCarouselSecs = UInt32(screenCarouselInterval) dc.compassNorthTop = compassNorthTop dc.flipScreen = flipScreen + dc.oled = OledTypes(rawValue: oledType)!.protoEnumValue() let adminMessageId = bleManager.saveDisplayConfig(config: dc, fromUser: node!.user!, toUser: node!.user!) @@ -133,6 +143,7 @@ struct DisplayConfig: View { self.screenCarouselInterval = Int(node?.displayConfig?.screenCarouselInterval ?? 0) self.compassNorthTop = node?.displayConfig?.compassNorthTop ?? false self.flipScreen = node?.displayConfig?.flipScreen ?? false + self.oledType = Int(node?.displayConfig?.oledType ?? 0) self.hasChanges = false } .onChange(of: screenOnSeconds) { newScreenSecs in @@ -160,5 +171,10 @@ struct DisplayConfig: View { if newFlipScreen != node!.displayConfig!.flipScreen { hasChanges = true } } } + .onChange(of: oledType) { newOledType in + if node != nil && node!.displayConfig != nil { + if newOledType != node!.displayConfig!.oledType { hasChanges = true } + } + } } } diff --git a/Meshtastic/Views/Settings/ShareChannels.swift b/Meshtastic/Views/Settings/ShareChannels.swift index d2f1328c..75240770 100644 --- a/Meshtastic/Views/Settings/ShareChannels.swift +++ b/Meshtastic/Views/Settings/ShareChannels.swift @@ -244,7 +244,7 @@ struct ShareChannels: View { #if targetEnvironment(macCatalyst) Button { - dismiss() + isPresentingHelp = false } label: { Label("Close", systemImage: "xmark") }