Meshtastic-Apple/Meshtastic/Enums/DisplayEnums.swift

171 lines
3.7 KiB
Swift
Raw Normal View History

//
// ScreenIntervals.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 8/20/22.
//
import Foundation
2022-09-23 21:41:07 -07:00
enum ScreenUnits: Int, CaseIterable, Identifiable {
2023-03-06 10:33:18 -08:00
2022-09-23 21:41:07 -07:00
case metric = 0
case imperial = 1
2023-03-06 10:33:18 -08:00
2022-09-23 21:41:07 -07:00
var id: Int { self.rawValue }
var description: String {
2023-03-06 13:26:04 -08:00
switch self {
case .metric:
return "Metric"
case .imperial:
return "Imperial"
2022-09-23 21:41:07 -07:00
}
}
func protoEnumValue() -> Config.DisplayConfig.DisplayUnits {
2023-03-06 10:33:18 -08:00
2022-09-23 21:41:07 -07:00
switch self {
case .metric:
return Config.DisplayConfig.DisplayUnits.metric
case .imperial:
return Config.DisplayConfig.DisplayUnits.imperial
}
}
}
enum ScreenOnIntervals: Int, CaseIterable, Identifiable {
case fifteenSeconds = 15
case thirtySeconds = 30
case oneMinute = 60
case fiveMinutes = 300
2022-09-10 18:27:44 -07:00
case tenMinutes = 600
case fifteenMinutes = 900
case thirtyMinutes = 1800
case oneHour = 3600
case max = 31536000 // One Year
var id: Int { self.rawValue }
var description: String {
2023-03-06 13:26:04 -08:00
switch self {
case .fifteenSeconds:
return "interval.fifteen.seconds".localized
2023-03-06 13:26:04 -08:00
case .thirtySeconds:
return "interval.thirty.seconds".localized
2023-03-06 13:26:04 -08:00
case .oneMinute:
return "interval.one.minute".localized
2023-03-06 13:26:04 -08:00
case .fiveMinutes:
return "interval.five.minutes".localized
2023-03-06 13:26:04 -08:00
case .tenMinutes:
return "interval.ten.minutes".localized
2023-03-06 13:26:04 -08:00
case .fifteenMinutes:
return "interval.fifteen.minutes".localized
2023-03-06 13:26:04 -08:00
case .thirtyMinutes:
return "interval.thirty.minutes".localized
2023-03-06 13:26:04 -08:00
case .oneHour:
return "interval.one.hour".localized
2023-03-06 13:26:04 -08:00
case .max:
return "always.on".localized
}
}
}
// Default of 0 is off
enum ScreenCarouselIntervals: Int, CaseIterable, Identifiable {
case off = 0
case thirtySeconds = 30
case oneMinute = 60
case fiveMinutes = 300
case tenMinutes = 600
case fifteenMinutes = 900
var id: Int { self.rawValue }
var description: String {
2023-03-06 13:26:04 -08:00
switch self {
case .off:
return "off".localized
2023-03-06 13:26:04 -08:00
case .thirtySeconds:
return "interval.thirty.seconds".localized
2023-03-06 13:26:04 -08:00
case .oneMinute:
return "interval.one.minute".localized
2023-03-06 13:26:04 -08:00
case .fiveMinutes:
return "interval.five.minutes".localized
2023-03-06 13:26:04 -08:00
case .tenMinutes:
return "interval.ten.minutes".localized
2023-03-06 13:26:04 -08:00
case .fifteenMinutes:
return "interval.fifteen.minutes".localized
}
}
}
// Default of 0 is auto
enum OledTypes: Int, CaseIterable, Identifiable {
case auto = 0
case ssd1306 = 1
case sh1106 = 2
2023-01-26 18:25:16 -08:00
case sh1107 = 3
var id: Int { self.rawValue }
var description: String {
2023-03-06 13:26:04 -08:00
switch self {
case .auto:
return "automatic.detection".localized
2023-03-06 13:26:04 -08:00
case .ssd1306:
return "SSD 1306"
case .sh1106:
return "SH 1106"
case .sh1107:
return "SH 1107"
}
}
func protoEnumValue() -> Config.DisplayConfig.OledType {
2023-03-06 10:33:18 -08:00
switch self {
case .auto:
return Config.DisplayConfig.OledType.oledAuto
case .ssd1306:
return Config.DisplayConfig.OledType.oledSsd1306
case .sh1106:
return Config.DisplayConfig.OledType.oledSh1106
2023-01-26 18:25:16 -08:00
case .sh1107:
return Config.DisplayConfig.OledType.oledSh1107
}
}
}
// Default of 0 is auto
enum DisplayModes: Int, CaseIterable, Identifiable {
case defaultMode = 0
case twoColor = 1
case inverted = 2
case color = 3
var id: Int { self.rawValue }
var description: String {
2023-03-06 13:26:04 -08:00
switch self {
case .defaultMode:
return "Default 128x64 screen layout"
case .twoColor:
return "Optimized for 2 color displays"
case .inverted:
return "Inverted top bar for 2 Color display"
case .color:
return "TFT Full Color Displays"
}
}
func protoEnumValue() -> Config.DisplayConfig.DisplayMode {
2023-03-06 10:33:18 -08:00
switch self {
case .defaultMode:
return Config.DisplayConfig.DisplayMode.default
case .twoColor:
return Config.DisplayConfig.DisplayMode.twocolor
case .inverted:
return Config.DisplayConfig.DisplayMode.inverted
case .color:
return Config.DisplayConfig.DisplayMode.color
}
}
}