mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-07-30 05:21:44 +08:00
feat: 完善 ATX 功能逻辑与控件样式
This commit is contained in:
@@ -1,27 +1,61 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
pub use crate::atx::{ActiveLevel, AtxDriverType, AtxKeyConfig, AtxLedConfig};
|
||||
pub use crate::atx::{ActiveLevel, AtxDriverType, AtxInputBinding, AtxOutputBinding};
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
#[derive(Default)]
|
||||
pub struct AtxConfig {
|
||||
pub enabled: bool,
|
||||
pub power: AtxKeyConfig,
|
||||
pub reset: AtxKeyConfig,
|
||||
pub led: AtxLedConfig,
|
||||
pub driver: AtxDriverType,
|
||||
pub device: String,
|
||||
pub baud_rate: u32,
|
||||
pub power: AtxOutputBinding,
|
||||
pub reset: AtxOutputBinding,
|
||||
pub led: AtxInputBinding,
|
||||
pub hdd: AtxInputBinding,
|
||||
pub wol_interface: String,
|
||||
}
|
||||
|
||||
impl AtxConfig {
|
||||
pub fn to_controller_config(&self) -> crate::atx::AtxControllerConfig {
|
||||
crate::atx::AtxControllerConfig {
|
||||
enabled: self.enabled,
|
||||
power: self.power.clone(),
|
||||
reset: self.reset.clone(),
|
||||
led: self.led.clone(),
|
||||
impl Default for AtxConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
driver: AtxDriverType::None,
|
||||
device: String::new(),
|
||||
baud_rate: 9600,
|
||||
power: AtxOutputBinding::default(),
|
||||
reset: AtxOutputBinding::default(),
|
||||
led: AtxInputBinding::default(),
|
||||
hdd: AtxInputBinding::default(),
|
||||
wol_interface: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AtxConfig {
|
||||
pub fn normalize(&mut self) {
|
||||
if self.driver == AtxDriverType::None {
|
||||
self.enabled = false;
|
||||
}
|
||||
|
||||
if self.driver != AtxDriverType::Gpio {
|
||||
self.led.enabled = false;
|
||||
self.hdd.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_controller_config(&self) -> crate::atx::AtxControllerConfig {
|
||||
crate::atx::AtxControllerConfig {
|
||||
enabled: self.enabled,
|
||||
driver: self.driver,
|
||||
device: self.device.clone(),
|
||||
baud_rate: self.baud_rate,
|
||||
power: self.power.clone(),
|
||||
reset: self.reset.clone(),
|
||||
led: self.led.clone(),
|
||||
hdd: self.hdd.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ impl AppConfig {
|
||||
if self.hid.backend != HidBackend::Otg {
|
||||
self.msd.enabled = false;
|
||||
}
|
||||
self.atx.normalize();
|
||||
}
|
||||
|
||||
pub fn apply_platform_defaults(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user