-
-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
232 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Array.swift | ||
// eul | ||
// | ||
// Created by Gao Sun on 2020/12/2. | ||
// Copyright © 2020 Gao Sun. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Array { | ||
func appending(_ newElement: Element, condition: Bool = true) -> [Element] { | ||
condition ? self + [newElement] : self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// FanData.swift | ||
// eul | ||
// | ||
// Created by Gao Sun on 2020/12/1. | ||
// Copyright © 2020 Gao Sun. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SharedLibrary | ||
import SwiftyJSON | ||
|
||
class FanData: Identifiable { | ||
let fan: Fan | ||
var speed: Int | ||
|
||
var id: Int { | ||
fan.id | ||
} | ||
|
||
var percentage: Double { | ||
Double(speed) / Double(fan.maxSpeed) * 100 | ||
} | ||
|
||
init(fan: Fan, speed: Int = 0) { | ||
self.fan = fan | ||
self.speed = speed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// TemperatureData.swift | ||
// eul | ||
// | ||
// Created by Gao Sun on 2020/12/1. | ||
// Copyright © 2020 Gao Sun. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SharedLibrary | ||
|
||
class TemperatureData { | ||
let sensor: TemperatureSensor | ||
var temp: Double | ||
|
||
init(sensor: TemperatureSensor, temp: Double = 0) { | ||
self.sensor = sensor | ||
self.temp = temp | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// FanTextComponent.swift | ||
// eul | ||
// | ||
// Created by Gao Sun on 2020/12/1. | ||
// Copyright © 2020 Gao Sun. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftyJSON | ||
|
||
struct FanTextComponent: Hashable { | ||
var id: Int | ||
|
||
var isAverage: Bool { | ||
id == -1 | ||
} | ||
} | ||
|
||
extension FanTextComponent: CaseIterable { | ||
static var allCases: [Self] | ||
= defaultComponents + [FanTextComponent(id: -1)] | ||
|
||
static var defaultComponents: [Self] { | ||
SmcControl.shared.fans.map { FanTextComponent(id: $0.id) } | ||
} | ||
} | ||
|
||
extension FanTextComponent: JSONCodabble { | ||
init?(json: JSON) { | ||
guard let id = json["id"].int else { | ||
return nil | ||
} | ||
self.id = id | ||
} | ||
|
||
var json: JSON { | ||
JSON([ | ||
"id": id, | ||
]) | ||
} | ||
} | ||
|
||
extension FanTextComponent: LocalizedStringConvertible { | ||
var localizedDescription: String { | ||
id == -1 ? "text_component.average".localized() : "fan".localized() + " \(id + 1)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.