mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #261 from meshtastic/2.0.7_Working_Changes
Format temperature using the user setting
This commit is contained in:
commit
e6861e5154
5 changed files with 26 additions and 15 deletions
|
|
@ -33,7 +33,6 @@
|
|||
DD41582628582E9B009B0E59 /* DeviceConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD41582528582E9B009B0E59 /* DeviceConfig.swift */; };
|
||||
DD415828285859C4009B0E59 /* TelemetryConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD415827285859C4009B0E59 /* TelemetryConfig.swift */; };
|
||||
DD41582A28585C32009B0E59 /* RangeTestConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD41582928585C32009B0E59 /* RangeTestConfig.swift */; };
|
||||
DD457184293C55CD000C49FB /* NordicDFU in Frameworks */ = {isa = PBXBuildFile; productRef = DD457183293C55CD000C49FB /* NordicDFU */; };
|
||||
DD457188293C7E63000C49FB /* SignalStrengthIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD457187293C7E63000C49FB /* SignalStrengthIndicator.swift */; };
|
||||
DD47E3CE26F103C600029299 /* NodeList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3CD26F103C600029299 /* NodeList.swift */; };
|
||||
DD47E3D626F17ED900029299 /* CircleText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3D526F17ED900029299 /* CircleText.swift */; };
|
||||
|
|
@ -237,7 +236,6 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C9697FA527933B8C00250207 /* SQLite in Frameworks */,
|
||||
DD457184293C55CD000C49FB /* NordicDFU in Frameworks */,
|
||||
DD5394FC276993AD00AD86B1 /* SwiftProtobuf in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
@ -572,7 +570,6 @@
|
|||
packageProductDependencies = (
|
||||
DD5394FB276993AD00AD86B1 /* SwiftProtobuf */,
|
||||
C9697FA427933B8C00250207 /* SQLite */,
|
||||
DD457183293C55CD000C49FB /* NordicDFU */,
|
||||
);
|
||||
productName = MeshtasticClient;
|
||||
productReference = DDC2E15426CE248E0042C5E4 /* Meshtastic.app */;
|
||||
|
|
@ -1186,11 +1183,6 @@
|
|||
package = C9697FA327933B8C00250207 /* XCRemoteSwiftPackageReference "SQLite.swift" */;
|
||||
productName = SQLite;
|
||||
};
|
||||
DD457183293C55CD000C49FB /* NordicDFU */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DD457182293C55CD000C49FB /* XCRemoteSwiftPackageReference "IOS-DFU-Library" */;
|
||||
productName = NordicDFU;
|
||||
};
|
||||
DD5394FB276993AD00AD86B1 /* SwiftProtobuf */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DD5394FA276993AD00AD86B1 /* XCRemoteSwiftPackageReference "swift-protobuf" */;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func TelemetryToCsvFile(telemetry: [TelemetryEntity], metricsType: Int) -> Strin
|
|||
for dm in telemetry{
|
||||
if dm.metricsType == 1 {
|
||||
csvString += "\n"
|
||||
csvString += String(dm.temperature)
|
||||
csvString += String(dm.temperature.localeTemperature())
|
||||
csvString += ", "
|
||||
csvString += String(dm.relativeHumidity)
|
||||
csvString += ", "
|
||||
|
|
|
|||
|
|
@ -531,11 +531,12 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
// Use a RunLoop to prevent the timer from running on the main UI thread
|
||||
if userSettings?.provideLocation ?? false {
|
||||
if positionTimer != nil {
|
||||
|
||||
positionTimer!.invalidate()
|
||||
}
|
||||
positionTimer = Timer.scheduledTimer(timeInterval: TimeInterval((userSettings?.provideLocationInterval ?? 900)), target: self, selector: #selector(positionTimerFired), userInfo: context, repeats: true)
|
||||
RunLoop.current.add(positionTimer!, forMode: .common)
|
||||
if positionTimer != nil {
|
||||
RunLoop.current.add(positionTimer!, forMode: .common)
|
||||
}
|
||||
}
|
||||
|
||||
if decodedInfo.configCompleteID != 0 && decodedInfo.configCompleteID == configNonce {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,25 @@ extension Date {
|
|||
}
|
||||
}
|
||||
|
||||
extension Float {
|
||||
|
||||
func formattedTemperature() -> String {
|
||||
let temperature = Measurement<UnitTemperature>(value: Double(self), unit: .celsius)
|
||||
return temperature.formatted(.measurement(width: .abbreviated, usage: .weather))
|
||||
}
|
||||
func localeTemperature() -> Double {
|
||||
let temperature = Measurement<UnitTemperature>(value: Double(self), unit: .celsius)
|
||||
let locale = NSLocale.current as NSLocale
|
||||
let localeUnit = locale.object(forKey: NSLocale.Key(rawValue: "kCFLocaleTemperatureUnitKey"))
|
||||
var format: UnitTemperature = .celsius
|
||||
|
||||
if localeUnit! as! String == "Fahrenheit" {
|
||||
format = .fahrenheit
|
||||
}
|
||||
return temperature.converted(to: format).value
|
||||
}
|
||||
}
|
||||
|
||||
extension Int {
|
||||
|
||||
func numberOfDigits() -> Int {
|
||||
|
|
|
|||
|
|
@ -17,18 +17,17 @@ struct EnvironmentMetricsLog: View {
|
|||
@State var exportString = ""
|
||||
|
||||
var node: NodeInfoEntity
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
||||
NavigationStack {
|
||||
|
||||
let tempReadingType = (!(node.telemetryConfig?.environmentDisplayFahrenheit ?? false)) ? "°C" : "°F"
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
//Add a table for mac and ipad
|
||||
Table(node.telemetries!.reversed() as! [TelemetryEntity]) {
|
||||
TableColumn("Temperature") { em in
|
||||
if em.metricsType == 1 {
|
||||
Text("\(String(format: "%.2f", em.temperature))\(tempReadingType)")
|
||||
Text(em.temperature.formattedTemperature())
|
||||
}
|
||||
}
|
||||
TableColumn("Humidity") { em in
|
||||
|
|
@ -98,7 +97,7 @@ struct EnvironmentMetricsLog: View {
|
|||
|
||||
GridRow {
|
||||
|
||||
Text("\(String(format: "%.2f", em.temperature))\(tempReadingType)")
|
||||
Text(em.temperature.formattedTemperature())
|
||||
.font(.caption)
|
||||
Text("\(String(format: "%.2f", em.relativeHumidity))")
|
||||
.font(.caption)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue