Show all points for day
This commit is contained in:
@ -56,12 +56,16 @@ final class TemperatureDataTransfer {
|
||||
|
||||
func add(data: Data, offset: Int, count: Int) {
|
||||
guard currentByteIndex == offset else {
|
||||
log.warning("Discarding \(data.count) bytes at offset \(offset), expected \(currentByteIndex)")
|
||||
log.warning("Transfer: Discarding \(data.count) bytes at offset \(offset), expected \(currentByteIndex)")
|
||||
return
|
||||
}
|
||||
if data.count != count {
|
||||
log.warning("Transfer: Expected \(count) bytes, received only \(data.count)")
|
||||
}
|
||||
dataBuffer.append(data)
|
||||
currentByteIndex += data.count
|
||||
processBytes()
|
||||
log.info("Transfer: \(currentByteIndex) bytes (added \(data.count)), \(measurements.count) points")
|
||||
}
|
||||
|
||||
private func processBytes() {
|
||||
@ -83,6 +87,10 @@ final class TemperatureDataTransfer {
|
||||
|
||||
func completeTransfer() {
|
||||
processBytes()
|
||||
if !dataBuffer.isEmpty {
|
||||
log.warning("\(dataBuffer.count) bytes remaining in transfer buffer")
|
||||
}
|
||||
log.info("Transfer: \(currentByteIndex) bytes, \(measurements.count) points")
|
||||
}
|
||||
|
||||
private func addRelative(byte: UInt8) {
|
||||
|
@ -27,7 +27,7 @@ struct TemperatureMeasurement: Identifiable {
|
||||
return sensor1.optionalValue
|
||||
}
|
||||
guard let s1 = sensor1.optionalValue else {
|
||||
return nil
|
||||
return s0
|
||||
}
|
||||
return max(s0, s1)
|
||||
}
|
||||
@ -37,10 +37,27 @@ struct TemperatureMeasurement: Identifiable {
|
||||
return sensor1.optionalValue
|
||||
}
|
||||
guard let s1 = sensor1.optionalValue else {
|
||||
return nil
|
||||
return s0
|
||||
}
|
||||
return min(s0, s1)
|
||||
}
|
||||
|
||||
var averageValue: Double? {
|
||||
guard let s0 = sensor0.optionalValue else {
|
||||
return sensor1.optionalValue
|
||||
}
|
||||
guard let s1 = sensor1.optionalValue else {
|
||||
return s0
|
||||
}
|
||||
return (s0 + s1) / 2
|
||||
}
|
||||
|
||||
var displayText: String {
|
||||
guard let averageValue else {
|
||||
return "-"
|
||||
}
|
||||
return String(format: "%.1f °C", averageValue)
|
||||
}
|
||||
}
|
||||
|
||||
extension TemperatureMeasurement {
|
||||
|
Reference in New Issue
Block a user