Skip to content

Commit

Permalink
feat: 温控可关闭
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow3aaa committed Nov 10, 2024
1 parent 3fd19a9 commit 89bfb3a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 15 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,24 @@

- ### **模式(`powersave` / `balance` / `performance` / `fast`)说明:**

- **mode:**
- #### **模式切换:**

- 目前`fas-rs`还没有官方的切换模式的管理器,而是接入了[`scene`](http://vtools.omarea.com)的配置接口,如果你不用 scene 则默认使用`balance`的配置
- 如果你有在 linux 上编程的一些了解,向`/dev/fas_rs/mode`节点写入 4 模式中的任意一个即可切换到对应模式,同时读取它也可以知道现在`fas-rs`所处的模式
- **模式参数说明:**
- margin(ms): 允许的掉帧余量,越小帧率越高,越大越省电(0 <= margin < 1000)
- temp_thresh(0.001℃): fas触发温控核心温度

- #### **模式参数说明:**

- **margin:**

- 类型: `整数`
- 单位: `milliseconds`
- 允许的掉帧余量,越小帧率越高,越大越省电(0 <= margin < 1000)

- **temp_thresh:**

- 类型: `整数`或者`"disabled"`
- `整数`: 让`fas-rs`触发温控的核心温度(单位0.001℃)
- `"disabled"`: 关闭`fas-rs`内置温控

### **`games.toml`配置标准例:**

Expand All @@ -90,15 +102,19 @@ scene_game_list = true

[powersave]
margin = 3
temp_thresh = 60000

[balance]
margin = 2
temp_thresh = 75000

[performance]
margin = 1
temp_thresh = 90000

[fast]
margin = 0
temp_thresh = 95000
```

## **配置合并**
Expand Down
32 changes: 25 additions & 7 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# **fas-rs**

[![English][readme-cn-badge]][readme-cn-url]
[![简体中文][readme-cn-badge]][readme-cn-url]
[![Stars][stars-badge]][stars-url]
[![CI Build][ci-badge]][ci-url]
[![Release][release-badge]][release-url]
[![Download][download-badge]][download-url]
[![Telegram][telegram-badge]][telegram-url]

> **⚠ Warning**: This document is gpt-translated and may contain inaccuracies or errors.
[readme-cn-badge]: https://img.shields.io/badge/README-简体中文-blue.svg?style=for-the-badge&logo=readme
[readme-cn-url]: README.md
[stars-badge]: https://img.shields.io/github/stars/shadow3aaa/fas-rs?style=for-the-badge&logo=github
Expand Down Expand Up @@ -61,12 +63,24 @@

- ### **`powersave` / `balance` / `performance` / `fast` Description:**

- **mode:**
- Currently, `fas-rs` does not have an official switching mode manager, but is connected to the configuration interface of [`scene`](http://vtools.omarea.com). If you don’t use scene, the configuration of `balance` will be used by default.
- If you have some understanding of programming on Linux, you can switch to the corresponding mode by writing any one of the 4 modes to the `/dev/fas_rs/mode` node, and at the same time, reading it can also know the current `fas-rs` mode
- **Parameter Description:**
- margin(ms): Allowed frame drop margin. The smaller the value, the higher the frame rate, the larger the value, the more power is saved (0 <= margin < 1000)
- temp_thresh (0.001℃): trigger temperature of fas-based thermal control
- #### **Mode Switching:**

- Currently, `fas-rs` lacks an official mode-switching manager, instead integrating the [`scene`](http://vtools.omarea.com) configuration interface. If you do not use scene, the default configuration is `balance`.
- If you have some Linux programming knowledge, you can write any of the 4 modes to the `/dev/fas_rs/mode` node to switch modes, and reading it will show the current `fas-rs` mode.

- #### **Mode Parameter Description:**

- **margin:**

- Type: `integer`
- Unit: `milliseconds`
- Allowed frame drop margin; smaller values increase frame rate, larger values save power (0 <= margin < 1000)

- **temp_thresh:**

- Type: `integer` or `"disabled"`
- `integer`: Sets the core temperature at which `fas-rs` triggers thermal control (unit: 0.001°C)
- `"disabled"`: Disables built-in thermal control in `fas-rs`

### **`games.toml` configuration standard example:**

Expand All @@ -90,15 +104,19 @@ scene_game_list = true

[powersave]
margin = 3
temp_thresh = 60000

[balance]
margin = 2
temp_thresh = 75000

[performance]
margin = 1
temp_thresh = 90000

[fast]
margin = 0
temp_thresh = 95000
```

## **Configuration merge**
Expand Down
10 changes: 9 additions & 1 deletion src/framework/config/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ pub struct Config {
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
pub struct ModeConfig {
pub margin: u64,
pub temp_thresh: u64,
pub temp_thresh: TemperatureThreshold,
}

#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
pub enum TemperatureThreshold {
#[serde(rename = "disabled")]
Disabled,
#[serde(untagged)]
Temp(u64),
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/framework/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use log::{error, info};
use toml::Value;

use crate::framework::{error::Result, node::Mode};
pub use data::{Config as ConfigConfig, ConfigData, ModeConfig};
pub use data::{Config as ConfigConfig, ConfigData, ModeConfig, TemperatureThreshold};
use read::wait_and_read;

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
10 changes: 8 additions & 2 deletions src/framework/scheduler/looper/thermal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{fs, path::PathBuf};

use anyhow::Result;

use crate::{Config, Mode};
use crate::{framework::config::TemperatureThreshold, Config, Mode};

pub struct Thermal {
target_fps_offset: f64,
Expand Down Expand Up @@ -49,8 +49,14 @@ impl Thermal {
}

pub fn target_fps_offset(&mut self, config: &mut Config, mode: Mode) -> f64 {
let target = match config.mode_config(mode).temp_thresh {
TemperatureThreshold::Disabled => {
return 0.0;
}
TemperatureThreshold::Temp(t) => t,
};

self.temperature_update();
let target = config.mode_config(mode).temp_thresh;
if self.temperature > target {
self.target_fps_offset -= 0.1;
} else {
Expand Down

0 comments on commit 89bfb3a

Please sign in to comment.