Improve temperature accuracy and layout
This commit is contained in:
parent
d1a24b581d
commit
dfa9f716d4
Binary file not shown.
@ -167,9 +167,12 @@ final class PersistentStorage: ObservableObject {
|
||||
}
|
||||
|
||||
func removeMeasurements(for dateIndex: Int) {
|
||||
defer { saveDailyCounts() }
|
||||
let fileUrl = fileUrl(for: dateIndex)
|
||||
guard fm.fileExists(atPath: fileUrl.path) else {
|
||||
log.warning("No measurements for \(fileUrl.lastPathComponent)")
|
||||
dailyMeasurementCounts = dailyMeasurementCounts.filter { $0.dateIndex != dateIndex }
|
||||
recentMeasurements = recentMeasurements.filter { $0.date.dateIndex != dateIndex }
|
||||
return
|
||||
}
|
||||
do {
|
||||
|
@ -53,10 +53,7 @@ struct TemperatureMeasurement: Identifiable {
|
||||
}
|
||||
|
||||
var displayText: String {
|
||||
guard let averageValue else {
|
||||
return "-"
|
||||
}
|
||||
return String(format: "%.1f °C", averageValue)
|
||||
"\(sensor0.text) / \(sensor1.text)"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ enum TemperatureValue {
|
||||
case .invalidMeasurement:
|
||||
return 1
|
||||
case .value(let double):
|
||||
let value = Int(double + 40) * 2
|
||||
let value = (double * 2).roundedInt + 80
|
||||
return UInt8(clamping: value)
|
||||
}
|
||||
}
|
||||
@ -45,11 +45,11 @@ enum TemperatureValue {
|
||||
var text: String {
|
||||
switch self {
|
||||
case .notFound:
|
||||
return "No sensor"
|
||||
return "-"
|
||||
case .invalidMeasurement:
|
||||
return "Invalid"
|
||||
return "?"
|
||||
case .value(let value):
|
||||
return String(format:"%.1f°C", value)
|
||||
return String(format:"%.1f°", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,13 @@ private let df: DateFormatter = {
|
||||
return df
|
||||
}()
|
||||
|
||||
private let dateFormatter: DateFormatter = {
|
||||
let df = DateFormatter()
|
||||
df.dateStyle = .medium
|
||||
df.timeStyle = .none
|
||||
return df
|
||||
}()
|
||||
|
||||
struct DayView: View {
|
||||
|
||||
let dateIndex: Int
|
||||
|
@ -47,7 +47,7 @@ struct TemperatureDayOverview: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.aspectRatio(2.6, contentMode: .fit)
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
//.chartXScale(domain: pastDateLimit...futureDateLimit)
|
||||
.chartYScale(domain: lowerTempLimit...upperTempLimit)
|
||||
.chartXAxis {
|
||||
@ -71,7 +71,6 @@ struct TemperatureDayOverview: View {
|
||||
AxisGridLine()
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user