@@ -153,6 +153,13 @@ class Meter : NSObject, ObservableObject, Identifiable {
|
||
| 153 | 153 |
capabilities.chargerTypeDescription(for: chargerTypeIndex) |
| 154 | 154 |
} |
| 155 | 155 |
|
| 156 |
+ var currentScreenDescription: String {
|
|
| 157 |
+ if let label = capabilities.screenDescription(for: currentScreen) {
|
|
| 158 |
+ return "Screen \(currentScreen): \(label)" |
|
| 159 |
+ } |
|
| 160 |
+ return "Screen \(currentScreen)" |
|
| 161 |
+ } |
|
| 162 |
+ |
|
| 156 | 163 |
var deviceModelSummary: String {
|
| 157 | 164 |
let baseName = reportedModelName.isEmpty ? modelString : reportedModelName |
| 158 | 165 |
if modelNumber != 0 {
|
@@ -161,6 +168,18 @@ class Meter : NSObject, ObservableObject, Identifiable {
|
||
| 161 | 168 |
return baseName |
| 162 | 169 |
} |
| 163 | 170 |
|
| 171 |
+ var recordingDurationDescription: String {
|
|
| 172 |
+ let totalSeconds = Int(recordingDuration) |
|
| 173 |
+ let hours = totalSeconds / 3600 |
|
| 174 |
+ let minutes = (totalSeconds % 3600) / 60 |
|
| 175 |
+ let seconds = totalSeconds % 60 |
|
| 176 |
+ |
|
| 177 |
+ if hours > 0 {
|
|
| 178 |
+ return String(format: "%d:%02d:%02d", hours, minutes, seconds) |
|
| 179 |
+ } |
|
| 180 |
+ return String(format: "%02d:%02d", minutes, seconds) |
|
| 181 |
+ } |
|
| 182 |
+ |
|
| 164 | 183 |
@Published var btSerial: BluetoothSerial |
| 165 | 184 |
|
| 166 | 185 |
@Published var measurements = Measurements() |
@@ -15,6 +15,7 @@ struct MeterCapabilities {
|
||
| 15 | 15 |
let supportsFahrenheit: Bool |
| 16 | 16 |
let supportsChargerDetection: Bool |
| 17 | 17 |
let chargerTypeDescriptions: [UInt16: String] |
| 18 |
+ let screenDescriptions: [UInt16: String] |
|
| 18 | 19 |
|
| 19 | 20 |
func chargerTypeDescription(for index: UInt16) -> String {
|
| 20 | 21 |
guard supportsChargerDetection else { return "-" }
|
@@ -23,6 +24,10 @@ struct MeterCapabilities {
|
||
| 23 | 24 |
} |
| 24 | 25 |
return index == 0 ? "Unknown" : "Unknown (\(index))" |
| 25 | 26 |
} |
| 27 |
+ |
|
| 28 |
+ func screenDescription(for index: UInt16) -> String? {
|
|
| 29 |
+ screenDescriptions[index] |
|
| 30 |
+ } |
|
| 26 | 31 |
} |
| 27 | 32 |
|
| 28 | 33 |
extension MeterCapabilities {
|
@@ -42,6 +47,14 @@ extension MeterCapabilities {
|
||
| 42 | 47 |
6: "Apple 0.5A", |
| 43 | 48 |
7: "DCP 1.5A", |
| 44 | 49 |
8: "Samsung" |
| 50 |
+ ], |
|
| 51 |
+ screenDescriptions: [ |
|
| 52 |
+ 0: "Main Measurement", |
|
| 53 |
+ 1: "Quick Charge", |
|
| 54 |
+ 2: "Charging Record", |
|
| 55 |
+ 3: "Cable Impedance", |
|
| 56 |
+ 4: "Graphing", |
|
| 57 |
+ 5: "System Settings" |
|
| 45 | 58 |
] |
| 46 | 59 |
) |
| 47 | 60 |
|
@@ -52,7 +65,8 @@ extension MeterCapabilities {
|
||
| 52 | 65 |
supportsRecordingThreshold: false, |
| 53 | 66 |
supportsFahrenheit: false, |
| 54 | 67 |
supportsChargerDetection: false, |
| 55 |
- chargerTypeDescriptions: [:] |
|
| 68 |
+ chargerTypeDescriptions: [:], |
|
| 69 |
+ screenDescriptions: [:] |
|
| 56 | 70 |
) |
| 57 | 71 |
} |
| 58 | 72 |
|
@@ -20,7 +20,7 @@ struct ControlView: View {
|
||
| 20 | 20 |
} |
| 21 | 21 |
HStack {
|
| 22 | 22 |
Button(action: { self.meter.previousScreen() }, label: { Image(systemName: "arrowtriangle.left") })
|
| 23 |
- Text("Current Screen: \(meter.currentScreen)")
|
|
| 23 |
+ Text(meter.currentScreenDescription) |
|
| 24 | 24 |
Button(action: { self.meter.nextScreen() }, label: { Image(systemName: "arrowtriangle.right") })
|
| 25 | 25 |
} |
| 26 | 26 |
} |
@@ -51,7 +51,7 @@ struct MeterView: View {
|
||
| 51 | 51 |
DataGroupsView(visibility: self.$dataGroupsViewVisibility) |
| 52 | 52 |
.environmentObject(self.meter) |
| 53 | 53 |
} |
| 54 |
- Text("ceva")
|
|
| 54 |
+ Text("Data Groups")
|
|
| 55 | 55 |
} |
| 56 | 56 |
} |
| 57 | 57 |
Button(action: {self.measurementsViewVisibility.toggle()}) {
|
@@ -61,7 +61,7 @@ struct MeterView: View {
|
||
| 61 | 61 |
MeasurementsView(visibility: self.$measurementsViewVisibility) |
| 62 | 62 |
.environmentObject(self.meter.measurements) |
| 63 | 63 |
} |
| 64 |
- Text("altceva")
|
|
| 64 |
+ Text("History")
|
|
| 65 | 65 |
} |
| 66 | 66 |
} |
| 67 | 67 |
} |
@@ -22,12 +22,12 @@ struct RecordingView: View {
|
||
| 22 | 22 |
Text ("Capacity")
|
| 23 | 23 |
Text ("Energy")
|
| 24 | 24 |
Text ("Duration")
|
| 25 |
- Text ("Treshold")
|
|
| 25 |
+ Text ("Threshold")
|
|
| 26 | 26 |
} |
| 27 | 27 |
VStack {
|
| 28 | 28 |
Text("\(usbMeter.recordedAH.format(decimalDigits: 3)) Ah")
|
| 29 | 29 |
Text("\(usbMeter.recordedWH.format(decimalDigits: 3)) Wh")
|
| 30 |
- Text("\(usbMeter.recordingDuration) Sec")
|
|
| 30 |
+ Text(usbMeter.recordingDurationDescription) |
|
| 31 | 31 |
if usbMeter.supportsRecordingThreshold {
|
| 32 | 32 |
HStack {
|
| 33 | 33 |
Slider(value: $usbMeter.recordingTreshold, in: 0...0.30, step: 0.01) |