Move config all around, add mockups for modules

This commit is contained in:
Garth Vander Houwen 2022-06-22 15:52:51 -07:00
parent 6f164a18e2
commit 388ff9bdd1
11 changed files with 328 additions and 51 deletions

View file

@ -36,6 +36,7 @@
DD539502276DAA6A00AD86B1 /* MapLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD539501276DAA6A00AD86B1 /* MapLocation.swift */; };
DD6193752862F6E600E59241 /* ExternalNotificationConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6193742862F6E600E59241 /* ExternalNotificationConfig.swift */; };
DD6193772862F90F00E59241 /* CannedMessagesConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6193762862F90F00E59241 /* CannedMessagesConfig.swift */; };
DD6193792863875F00E59241 /* SerialConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6193782863875F00E59241 /* SerialConfig.swift */; };
DD6B85A828009258000ACD6B /* ShareChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6B85A728009258000ACD6B /* ShareChannel.swift */; };
DD8169F9271F1A6100F4AB02 /* MeshLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8169F8271F1A6100F4AB02 /* MeshLogger.swift */; };
DD8169FB271F1F3A00F4AB02 /* MeshLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD8169FA271F1F3A00F4AB02 /* MeshLog.swift */; };
@ -121,6 +122,7 @@
DD619373285CC7D600E59241 /* MeshtasticDataModel v 4.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModel v 4.xcdatamodel"; sourceTree = "<group>"; };
DD6193742862F6E600E59241 /* ExternalNotificationConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalNotificationConfig.swift; sourceTree = "<group>"; };
DD6193762862F90F00E59241 /* CannedMessagesConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CannedMessagesConfig.swift; sourceTree = "<group>"; };
DD6193782863875F00E59241 /* SerialConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SerialConfig.swift; sourceTree = "<group>"; };
DD6B85A728009258000ACD6B /* ShareChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareChannel.swift; sourceTree = "<group>"; };
DD8169F8271F1A6100F4AB02 /* MeshLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshLogger.swift; sourceTree = "<group>"; };
DD8169FA271F1F3A00F4AB02 /* MeshLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshLog.swift; sourceTree = "<group>"; };
@ -239,16 +241,33 @@
DD8169FA271F1F3A00F4AB02 /* MeshLog.swift */,
DD8169FE272476C700F4AB02 /* LogDocument.swift */,
DD6B85A728009258000ACD6B /* ShareChannel.swift */,
DD61937A2863876A00E59241 /* Config */,
);
path = Settings;
sourceTree = "<group>";
};
DD61937A2863876A00E59241 /* Config */ = {
isa = PBXGroup;
children = (
DD41582528582E9B009B0E59 /* DeviceConfig.swift */,
DD8EBF42285058FA00426DCA /* DisplayConfig.swift */,
DD2553562855B02500E55709 /* LoRaConfig.swift */,
DD2553582855B52700E55709 /* PositionConfig.swift */,
DD61937B2863877A00E59241 /* Module */,
);
path = Config;
sourceTree = "<group>";
};
DD61937B2863877A00E59241 /* Module */ = {
isa = PBXGroup;
children = (
DD6193762862F90F00E59241 /* CannedMessagesConfig.swift */,
DD6193742862F6E600E59241 /* ExternalNotificationConfig.swift */,
DD41582928585C32009B0E59 /* RangeTestConfig.swift */,
DD6193782863875F00E59241 /* SerialConfig.swift */,
DD415827285859C4009B0E59 /* TelemetryConfig.swift */,
DD6193762862F90F00E59241 /* CannedMessagesConfig.swift */,
);
path = Settings;
path = Module;
sourceTree = "<group>";
};
DD8EDE9226F97A2B00A5A10B /* Frameworks */ = {
@ -597,6 +616,7 @@
DDC4D568275499A500A4208E /* Persistence.swift in Sources */,
DD90860E26F69BAE00DC5189 /* NodeMap.swift in Sources */,
DD8169FF272476C700F4AB02 /* LogDocument.swift in Sources */,
DD6193792863875F00E59241 /* SerialConfig.swift in Sources */,
DDAF8C6926ED0D070058C060 /* deviceonly.pb.swift in Sources */,
DD90860C26F684AF00DC5189 /* BatteryIcon.swift in Sources */,
DD4A911E2708C65400501B7E /* AppSettings.swift in Sources */,

View file

@ -75,7 +75,7 @@ struct DeviceConfig: View {
Text(dr.description)
}
}
.pickerStyle(InlinePickerStyle())
.pickerStyle(DefaultPickerStyle())
.padding(.top, 10)
.padding(.bottom, 10)
}

View file

@ -175,7 +175,7 @@ struct DisplayConfig: View {
}
.pickerStyle(DefaultPickerStyle())
Text("The format used to display GPS coordinates on the screen.")
Text("The format used to display GPS coordinates on the device screen.")
.font(.caption)
.listRowSeparator(.visible)
}

View file

@ -30,7 +30,7 @@ struct ExternalNotificationConfig: View {
Toggle(isOn: $enabled) {
Label("Module Enabled", systemImage: "megaphone")
Label("Enabled", systemImage: "megaphone")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
@ -45,8 +45,6 @@ struct ExternalNotificationConfig: View {
Label("Alert when receiving a message", systemImage: "message")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}
Section(header: Text("GPIO")) {
@ -61,16 +59,22 @@ struct ExternalNotificationConfig: View {
.listRowSeparator(.visible)
Picker("GPIO to monitor", selection: $output) {
ForEach(0..<25) {
ForEach(0..<40) {
Text("\($0)")
if $0 == 0 {
Text("Unset")
} else {
Text("Pin \($0)")
}
}
}
.pickerStyle(DefaultPickerStyle())
Text("Specifies the GPIO that your external circuit is attached to on the device.")
.font(.caption)
.listRowSeparator(.visible)
}
}
.navigationTitle("External Notification Config")

View file

@ -25,30 +25,27 @@ struct RangeTestConfig: View {
Toggle(isOn: $enabled) {
Label("Module Enabled", systemImage: "figure.walk")
Label("Enabled", systemImage: "figure.walk")
}
.toggleStyle(DefaultToggleStyle())
.listRowSeparator(.visible)
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle(isOn: $sender) {
Label("Sender", systemImage: "paperplane")
}
.toggleStyle(DefaultToggleStyle())
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Text("This device will send out range test messages.")
.font(.caption)
.listRowSeparator(.visible)
Toggle(isOn: $save) {
Label("Save", systemImage: "square.and.arrow.down.fill")
}
.toggleStyle(DefaultToggleStyle())
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Text("Saves a CSV with the range test message details, only available on ESP32 devices with a web server.")
.font(.caption)
.listRowSeparator(.visible)
}
}
.navigationTitle("Range Test Config")
.navigationBarItems(trailing:

View file

@ -0,0 +1,226 @@
//
// SerialConfig.swift
// Meshtastic Apple
//
// Copyright (c) Garth Vander Houwen 6/22/22.
//
import SwiftUI
enum SerialBaudRates: Int, CaseIterable, Identifiable {
case baudDefault = 0
case baud110 = 1
case baud300 = 2
case baud600 = 3
case baud1200 = 4
case baud2400 = 5
case baud4800 = 6
case baud9600 = 7
case baud19200 = 8
case baud38400 = 9
case baud57600 = 10
case baud115200 = 11
case baud230400 = 12
case baud460800 = 13
case baud576000 = 14
case baud921600 = 15
var id: Int { self.rawValue }
var description: String {
get {
switch self {
case .baudDefault:
return "Unset"
case .baud110:
return "110 Baud"
case .baud300:
return "300 Baud"
case .baud600:
return "600 Baud"
case .baud1200:
return "1200 Baud"
case .baud2400:
return "2400 Baud"
case .baud4800:
return "4800 Baud"
case .baud9600:
return "9600 Baud"
case .baud19200:
return "19200 Baud"
case .baud38400:
return "38400 Baud"
case .baud57600:
return "57600 Baud"
case .baud115200:
return "115200 Baud"
case .baud230400:
return "230400 Baud"
case .baud460800:
return "460800 Baud"
case .baud576000:
return "576000 Baud"
case .baud921600:
return "921600 Baud"
}
}
}
}
enum SerialModeTypes: Int, CaseIterable, Identifiable {
case modeDefault = 0
case modeSimple = 1
case modeProto = 2
var id: Int { self.rawValue }
var description: String {
get {
switch self {
case .modeDefault:
return "Default"
case .modeSimple:
return "Simple"
case .modeProto:
return "Protobufs"
}
}
}
}
enum SerialTimeoutIntervals: Int, CaseIterable, Identifiable {
case unset = 0
case fiveSeconds = 5
case tenSeconds = 10
case fifteenSeconds = 15
case thirtySeconds = 30
case oneMinute = 60
case fiveMinutes = 300
var id: Int { self.rawValue }
var description: String {
get {
switch self {
case .unset:
return "Unset"
case .fiveSeconds:
return "Five Seconds"
case .tenSeconds:
return "Ten Seconds"
case .fifteenSeconds:
return "Fifteen Seconds"
case .thirtySeconds:
return "Thirty Seconds"
case .oneMinute:
return "One Minute"
case .fiveMinutes:
return "Five Minutes"
}
}
}
}
struct SerialConfig: View {
@Environment(\.managedObjectContext) var context
@EnvironmentObject var bleManager: BLEManager
@State var enabled = false
@State var echo = false
@State var rxd = 0
@State var txd = 0
@State var baudRate = 0
@State var timeout = 0
@State var mode = 0
var body: some View {
VStack {
Form {
Section(header: Text("Options")) {
Toggle(isOn: $enabled) {
Label("Enabled", systemImage: "terminal")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle(isOn: $echo) {
Label("Echo", systemImage: "repeat")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Picker("Baud Rate", selection: $baudRate ) {
ForEach(SerialBaudRates.allCases) { sbr in
Text(sbr.description)
}
}
.pickerStyle(DefaultPickerStyle())
Picker("Timeout", selection: $timeout ) {
ForEach(SerialTimeoutIntervals.allCases) { sti in
Text(sti.description)
}
}
.pickerStyle(DefaultPickerStyle())
Picker("Mode", selection: $mode ) {
ForEach(SerialModeTypes.allCases) { smt in
Text(smt.description)
}
}
.pickerStyle(DefaultPickerStyle())
}
Section(header: Text("GPIO")) {
Picker("Receive data (rxd) GPIO pin", selection: $rxd) {
ForEach(0..<40) {
if $0 == 0 {
Text("Unset")
} else {
Text("Pin \($0)")
}
}
}
.pickerStyle(DefaultPickerStyle())
Picker("Transmit data (txd) GPIO pin", selection: $txd) {
ForEach(0..<40) {
if $0 == 0 {
Text("Unset")
} else {
Text("Pin \($0)")
}
}
}
.pickerStyle(DefaultPickerStyle())
}
}
.navigationTitle("Serial Config")
.navigationBarItems(trailing:
ZStack {
ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?????")
})
.onAppear {
self.bleManager.context = context
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
}

View file

@ -52,27 +52,27 @@ enum SensorTypes: Int, CaseIterable, Identifiable {
case .notSet:
return "Not Set"
case .dht11:
return "DHT11 temperature"
return "DHT11 - Temperature"
case .ds18B20:
return "DS18B20 temperature"
return "DS18B20 - Temperature"
case .dht12:
return "DHT12 temp and humidity"
return "DHT12 - Temperature & humidity"
case .dht21:
return "DHT21 temp and humidity"
return "DHT21 - Temperature & humidity"
case .dht22:
return "DHT22 temp and humidity"
return "DHT22 - Temperature & humidity"
case .bme280:
return "BME280 temp pressure and humidity"
return "BME280 - Temp, pressure & humidity"
case .bme680:
return "BME680 temp pressure humidity & air resistance"
return "BME680 - Temp, pressure, humidity & air resistance"
case .mcp9808:
return "MCP9808 high accuracy temperature"
return "MCP9808 - Temperature"
case .shtc3:
return "SHTC3 temp and humidity"
return "SHTC3 - Temperature & humidity"
case .ina260:
return "INA260 current and voltage"
return "INA260 - Current & voltage"
case .ina219:
return "INA219 current and voltage"
return "INA219 - Current & voltage"
}
}
}
@ -96,7 +96,7 @@ enum ErrorRecoveryIntervals: Int, CaseIterable, Identifiable {
get {
switch self {
case .off:
return "Off"
return "Unset"
case .fifteenSeconds:
return "Fifteen Seconds"
case .thirtySeconds:
@ -120,22 +120,27 @@ enum ErrorRecoveryIntervals: Int, CaseIterable, Identifiable {
enum UpdateIntervals: Int, CaseIterable, Identifiable {
case off = 0
case fifteenSeconds = 15
case thirtySeconds = 30
case oneMinute = 60
case fiveMinutes = 300
case tenMinutes = 600
case fifteenMinutes = 900
case fifteenMinutes = 0
case thirtyMinutes = 1800
case oneHour = 3600
case twoHours = 7200
case threeHours = 10800
case fourHours = 14400
case fiveHours = 18000
case sixHours = 21600
case twelveHours = 43200
case eighteenHours = 64800
case twentyFourHours = 86400
var id: Int { self.rawValue }
var description: String {
get {
switch self {
case .off:
return "Off"
case .fifteenSeconds:
return "Fifteen Seconds"
case .thirtySeconds:
@ -152,6 +157,22 @@ enum UpdateIntervals: Int, CaseIterable, Identifiable {
return "Thirty Minutes"
case .oneHour:
return "One Hour"
case .twoHours:
return "Two Hours"
case .threeHours:
return "Three Hours"
case .fourHours:
return "Four Hours"
case .fiveHours:
return "Five Hours"
case .sixHours:
return "Six Hours"
case .twelveHours:
return "Twelve Hours"
case .eighteenHours:
return "Eighteen Hours"
case .twentyFourHours:
return "Twenty Four Hours"
}
}
}
@ -187,6 +208,8 @@ struct TelemetryConfig: View {
}
}
.pickerStyle(DefaultPickerStyle())
Text("How often device metrics are sent out over the mesh. Default is 15 minutes.")
.font(.caption)
Picker("Sensor Metrics", selection: $environmentUpdateInterval ) {
ForEach(UpdateIntervals.allCases) { ui in
@ -194,9 +217,8 @@ struct TelemetryConfig: View {
}
}
.pickerStyle(DefaultPickerStyle())
//var deviceUpdateInterval: UInt32 = 0
//var environmentUpdateInterval: UInt32 = 0
Text("How often sensor metrics are sent out over the mesh. Default is 15 minutes.")
.font(.caption)
}
Section(header: Text("Sensor Options")) {
@ -205,8 +227,7 @@ struct TelemetryConfig: View {
Label("Enabled", systemImage: "chart.xyaxis.line")
}
.toggleStyle(DefaultToggleStyle())
.listRowSeparator(.visible)
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Picker("Sensor", selection: $environmentSensorType ) {
ForEach(SensorTypes.allCases) { st in
@ -219,24 +240,24 @@ struct TelemetryConfig: View {
Label("Show on device screen", systemImage: "display")
}
.toggleStyle(DefaultToggleStyle())
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle(isOn: $environmentDisplayFahrenheit) {
Label("Display Fahrenheit", systemImage: "thermometer")
}
.toggleStyle(DefaultToggleStyle())
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Picker("GPIO Pin for sensor readings", selection: $environmentSensorPin) {
ForEach(0..<26) {
ForEach(0..<40) {
if $0 == 0 {
Text("Off")
Text("Unset")
} else {
Text("\($0)")
Text("Pin \($0)")
}
}
}
@ -250,7 +271,7 @@ struct TelemetryConfig: View {
if $0 == 0 {
Text("Off")
Text("Unset")
} else if $0 % 5 == 0 {
@ -261,7 +282,6 @@ struct TelemetryConfig: View {
.pickerStyle(DefaultPickerStyle())
Text("Sometimes sensor reads can fail. If this happens, we will retry a configurable number of attempts, each attempt will be delayed by the minimum required refresh rate for that sensor")
.font(.caption)
.listRowSeparator(.visible)
Picker("Error Recovery Interval", selection: $environmentRecoveryInterval ) {
ForEach(ErrorRecoveryIntervals.allCases) { eri in
@ -272,10 +292,6 @@ struct TelemetryConfig: View {
Text("Sometimes we can end up with more failures than our error count threshold. In this case, we will stop trying to read from the sensor for a while. Wait this long until trying to read from the sensor again")
.font(.caption)
.listRowSeparator(.visible)
}
}
.navigationTitle("Telemetry Config")

View file

@ -94,6 +94,10 @@ struct Settings: View {
Text("Position")
}
.disabled(bleManager.connectedPeripheral == nil)
Text("Default settings values are prefered whenever possible as they consume no bandwidth when sent over the mesh.")
.font(.caption2)
.fixedSize(horizontal: false, vertical: true)
}
Section("Module Configuration - Non Functional interaction preview.") {
@ -128,6 +132,17 @@ struct Settings: View {
}
//.disabled(!(nodes.first(where: { $0.num == connectedNodeNum })?.myInfo?.hasWifi ?? true) || bleManager.connectedPeripheral == nil)
NavigationLink {
SerialConfig()
} label: {
Image(systemName: "terminal")
.symbolRenderingMode(.hierarchical)
Text("Serial")
}
.disabled(false)
NavigationLink {
TelemetryConfig()
} label: {
@ -140,7 +155,6 @@ struct Settings: View {
.disabled(false)
}
// Not Implemented:
// Serial Config - Not sure what the point is
// Store Forward Config - Not Working
// WiFi Config - Would break connection to device
// MQTT Config - Part of WiFi