mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
feat: HDR 休眠阈值可自定义,新增进入/退出双阈值迟滞机制
- up.sh: 比率 ≥ 进入阈值(默认 1.15)进入休眠,≤ 退出阈值(默认 1.05)恢复, hdr.flag 由时间冷却改为休眠状态标记,迟滞区间内不抖动 - WebUI: 开启 HDR 休眠后展开进入/退出阈值输入,随主配置保存 - customize.sh/config.json/README 同步新字段 hdr_enter_ratio / hdr_exit_ratio
This commit is contained in:
1 parent
7ebbfaf24b
commit
f9dd4c40d6
8 files changed
+80
-20
No files matched your search
@@ -64,6 +64,8 @@ _基于 KernelSU WebUI + Rust 事件驱动架构_
|
||||
| `sleep_time` | 休眠时段,格式 `HHMM-HHMM` | 空(禁用) |
|
||||
| `auto_bri_sleep` | 自动亮度开启时跳过 | `1`(启用) |
|
||||
| `display_hdr_sleep` | HDR 内容时跳过 | `0`(禁用) |
|
||||
| `hdr_enter_ratio` | HDR 进入休眠阈值(HDR/SDR 比率)| `1.15` |
|
||||
| `hdr_exit_ratio` | HDR 退出休眠阈值(HDR/SDR 比率)| `1.05` |
|
||||
| `log_level` | 日志等级(off/error/warn/info) | `info` |
|
||||
| `log_max_size` | 日志文件大小上限(KB) | `512` |
|
||||
| `now_bri_file` | 当前亮度节点路径 | 标准 panel0 路径 |
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"log_max_size": 512,
|
||||
"auto_bri_sleep": 1,
|
||||
"display_hdr_sleep": 0,
|
||||
"hdr_enter_ratio": 1.15,
|
||||
"hdr_exit_ratio": 1.05,
|
||||
"sleep_time": "",
|
||||
"inotify_events": "c",
|
||||
"now_bri_file": "/sys/class/backlight/panel0-backlight/brightness",
|
||||
|
||||
@@ -67,6 +67,8 @@ write_config_json() {
|
||||
--arg log_max_size "${cfg_log_max_size:-512}" \
|
||||
--arg auto_bri_sleep "${cfg_auto_bri_sleep:-1}" \
|
||||
--arg display_hdr_sleep "${cfg_display_hdr_sleep:-0}" \
|
||||
--arg hdr_enter_ratio "${cfg_hdr_enter_ratio:-1.15}" \
|
||||
--arg hdr_exit_ratio "${cfg_hdr_exit_ratio:-1.05}" \
|
||||
--arg compatibility_mode "${cfg_compatibility_mode:-0}" \
|
||||
--arg sleep_time "${cfg_sleep_time:-}" \
|
||||
--arg inotify_events "${cfg_inotify_events:-c}" \
|
||||
@@ -81,6 +83,8 @@ write_config_json() {
|
||||
log_max_size: ($log_max_size | tonumber),
|
||||
auto_bri_sleep: ($auto_bri_sleep | tonumber),
|
||||
display_hdr_sleep: ($display_hdr_sleep | tonumber),
|
||||
hdr_enter_ratio: ($hdr_enter_ratio | tonumber),
|
||||
hdr_exit_ratio: ($hdr_exit_ratio | tonumber),
|
||||
compatibility_mode:($compatibility_mode | tonumber),
|
||||
sleep_time: $sleep_time,
|
||||
inotify_events: $inotify_events,
|
||||
@@ -297,6 +301,8 @@ INIT_CONFIG() {
|
||||
cfg_log_max_size=512
|
||||
cfg_auto_bri_sleep=1
|
||||
cfg_display_hdr_sleep=0
|
||||
cfg_hdr_enter_ratio=1.15
|
||||
cfg_hdr_exit_ratio=1.05
|
||||
cfg_compatibility_mode=0
|
||||
cfg_sleep_time=""
|
||||
cfg_inotify_events="c"
|
||||
@@ -315,6 +321,8 @@ ENSURE_DEFAULTS() {
|
||||
.log_max_size = (.log_max_size // 512) |
|
||||
.auto_bri_sleep = (.auto_bri_sleep // 1) |
|
||||
.display_hdr_sleep = (.display_hdr_sleep // 0) |
|
||||
.hdr_enter_ratio = (.hdr_enter_ratio // 1.15) |
|
||||
.hdr_exit_ratio = (.hdr_exit_ratio // 1.05) |
|
||||
.compatibility_mode= (.compatibility_mode // 0) |
|
||||
.sleep_time = (.sleep_time // "") |
|
||||
.inotify_events = (.inotify_events // "c") |
|
||||
|
||||
+20
-19
@@ -76,6 +76,8 @@ max_bri="$(get_cfg max_bri 0)"
|
||||
sleep_time="$(get_cfg sleep_time '')"
|
||||
auto_bri_sleep="$(get_cfg auto_bri_sleep 1)"
|
||||
display_hdr_sleep="$(get_cfg display_hdr_sleep 0)"
|
||||
hdr_enter_ratio="$(get_cfg hdr_enter_ratio 1.15)"
|
||||
hdr_exit_ratio="$(get_cfg hdr_exit_ratio 1.05)"
|
||||
steps_num="$(get_cfg steps_num 50)"
|
||||
|
||||
# 解析休眠时间
|
||||
@@ -166,22 +168,11 @@ MAIN() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# 显示 HDR 内容时休眠
|
||||
# 显示 HDR 内容时休眠 (迟滞: 比率达到进入阈值休眠, 降至退出阈值恢复)
|
||||
if [ "$display_hdr_sleep" = "1" ]; then
|
||||
local hdr_flag_file="$PID_DIR/hdr.flag"
|
||||
if [ -f "$hdr_flag_file" ]; then
|
||||
local flag_time now
|
||||
flag_time="$(cat "$hdr_flag_file")"
|
||||
now="$(date +%s)"
|
||||
if awk "BEGIN{exit !(($now - $flag_time) < 2)}" 2>/dev/null; then
|
||||
_log "HDR 冷却期内,跳过提升" "INFO"
|
||||
return
|
||||
else
|
||||
rm -f "$hdr_flag_file"
|
||||
fi
|
||||
fi
|
||||
local hdr_ratio
|
||||
local hdr_state_file="$PID_DIR/hdr.flag"
|
||||
local hdr_cache_file="$PID_DIR/.hdr_ratio_cache"
|
||||
local hdr_ratio
|
||||
hdr_ratio="$(dumpsys display 2>/dev/null | sed -n 's/.*hdrSdrRatio \([0-9.]*\).*/\1/p' | head -n 1)"
|
||||
if echo "$hdr_ratio" | grep -qE '^[0-9]+\.[0-9]+$'; then
|
||||
echo -n "$hdr_ratio" >"$hdr_cache_file"
|
||||
@@ -190,13 +181,23 @@ MAIN() {
|
||||
_log "HDR 比率读取为空,使用缓存值: $hdr_ratio" "INFO"
|
||||
fi
|
||||
if echo "$hdr_ratio" | grep -qE '^[0-9]+\.[0-9]+$'; then
|
||||
local hdr_ratio_rounded
|
||||
hdr_ratio_rounded="$(awk "BEGIN{printf \"%.2f\", $hdr_ratio}")"
|
||||
if awk "BEGIN{exit !($hdr_ratio_rounded > 1.00)}" 2>/dev/null; then
|
||||
_log "检测到 HDR 内容 (比率: $hdr_ratio_rounded),跳过提升" "INFO"
|
||||
date +%s >"$hdr_flag_file"
|
||||
hdr_ratio="$(awk "BEGIN{printf \"%.2f\", $hdr_ratio}")"
|
||||
if [ -f "$hdr_state_file" ]; then
|
||||
if awk "BEGIN{exit !($hdr_ratio <= $hdr_exit_ratio)}" 2>/dev/null; then
|
||||
rm -f "$hdr_state_file"
|
||||
_log "HDR 休眠解除 (比率: $hdr_ratio ≤ 退出阈值 $hdr_exit_ratio)" "INFO"
|
||||
else
|
||||
_log "HDR 休眠中 (比率: $hdr_ratio),跳过提升" "INFO"
|
||||
return
|
||||
fi
|
||||
elif awk "BEGIN{exit !($hdr_ratio >= $hdr_enter_ratio)}" 2>/dev/null; then
|
||||
touch "$hdr_state_file"
|
||||
_log "检测到 HDR 内容 (比率: $hdr_ratio ≥ 进入阈值 $hdr_enter_ratio),进入休眠" "INFO"
|
||||
return
|
||||
fi
|
||||
elif [ -f "$hdr_state_file" ]; then
|
||||
_log "HDR 比率不可读,保持休眠,跳过提升" "INFO"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -271,6 +271,10 @@
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
|
||||
.time-input-wide {
|
||||
width: 48px;
|
||||
}
|
||||
|
||||
.time-input::-webkit-outer-spin-button,
|
||||
.time-input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
|
||||
@@ -20,6 +20,8 @@ export function useConfig() {
|
||||
// 执行策略
|
||||
const autoBriSleep = ref(false)
|
||||
const displayHdrSleep = ref(false)
|
||||
const hdrEnterRatio = ref('1.15')
|
||||
const hdrExitRatio = ref('1.05')
|
||||
const compatibilityMode = ref(false)
|
||||
const sleepMode = ref(false)
|
||||
const sleepStartH = ref('19')
|
||||
@@ -58,6 +60,8 @@ export function useConfig() {
|
||||
stepsNum,
|
||||
autoBriSleep,
|
||||
displayHdrSleep,
|
||||
hdrEnterRatio,
|
||||
hdrExitRatio,
|
||||
compatibilityMode,
|
||||
sleepMode,
|
||||
sleepStartH,
|
||||
@@ -88,6 +92,8 @@ export function useConfig() {
|
||||
logMaxSize.value = cfg.log_max_size != null ? String(cfg.log_max_size) : '500'
|
||||
autoBriSleep.value = cfg.auto_bri_sleep === 1
|
||||
displayHdrSleep.value = cfg.display_hdr_sleep === 1
|
||||
hdrEnterRatio.value = cfg.hdr_enter_ratio != null ? String(cfg.hdr_enter_ratio) : '1.15'
|
||||
hdrExitRatio.value = cfg.hdr_exit_ratio != null ? String(cfg.hdr_exit_ratio) : '1.05'
|
||||
compatibilityMode.value = cfg.compatibility_mode === 1
|
||||
nowBriFile.value = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE
|
||||
sysMaxBriFile.value = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE
|
||||
@@ -136,6 +142,8 @@ export function useConfig() {
|
||||
steps_num: parseInt(stepsNum.value) || 50,
|
||||
auto_bri_sleep: autoBriSleep.value ? 1 : 0,
|
||||
display_hdr_sleep: displayHdrSleep.value ? 1 : 0,
|
||||
hdr_enter_ratio: parseFloat(hdrEnterRatio.value) || 1.15,
|
||||
hdr_exit_ratio: parseFloat(hdrExitRatio.value) || 1.05,
|
||||
compatibility_mode: compatibilityMode.value ? 1 : 0,
|
||||
sleep_time: getSleepTimeStr(),
|
||||
})
|
||||
@@ -183,6 +191,8 @@ export function useConfig() {
|
||||
maxBri.value = backup.max_bri != null ? String(backup.max_bri) : ''
|
||||
autoBriSleep.value = backup.auto_bri_sleep === 1
|
||||
displayHdrSleep.value = backup.display_hdr_sleep === 1
|
||||
hdrEnterRatio.value = backup.hdr_enter_ratio != null ? String(backup.hdr_enter_ratio) : '1.15'
|
||||
hdrExitRatio.value = backup.hdr_exit_ratio != null ? String(backup.hdr_exit_ratio) : '1.05'
|
||||
compatibilityMode.value = backup.compatibility_mode === 1
|
||||
stepsNum.value = backup.steps_num != null ? String(backup.steps_num) : '50'
|
||||
logMaxSize.value = backup.log_max_size != null ? String(backup.log_max_size) : '500'
|
||||
@@ -248,6 +258,8 @@ export function useConfig() {
|
||||
logMaxSize,
|
||||
autoBriSleep,
|
||||
displayHdrSleep,
|
||||
hdrEnterRatio,
|
||||
hdrExitRatio,
|
||||
compatibilityMode,
|
||||
sleepMode,
|
||||
sleepStartH,
|
||||
|
||||
@@ -36,6 +36,8 @@ export async function runCmd(cmd) {
|
||||
log_max_size: 1024,
|
||||
auto_bri_sleep: 1,
|
||||
display_hdr_sleep: 0,
|
||||
hdr_enter_ratio: 1.15,
|
||||
hdr_exit_ratio: 1.05,
|
||||
sleep_time: '1900-0600',
|
||||
inotify_events: 'c',
|
||||
now_bri_file: '/sys/mock/brightness',
|
||||
|
||||
@@ -137,7 +137,7 @@ function handleSaveWebUI() {
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">显示 HDR 内容时休眠</span>
|
||||
<span class="config-desc">HDR/SDR 比率 > 1 时不提升</span>
|
||||
<span class="config-desc">比率 ≥ 进入阈值休眠,≤ 退出阈值恢复</span>
|
||||
<span class="config-desc" style="color: var(--color-warning)"
|
||||
>出现闪屏建议改用黑名单</span
|
||||
>
|
||||
@@ -145,6 +145,35 @@ function handleSaveWebUI() {
|
||||
<Switch v-model="config.displayHdrSleep.value" />
|
||||
</div>
|
||||
|
||||
<div class="config-item-expand" :class="{ show: config.displayHdrSleep.value }">
|
||||
<div class="custom-time-picker">
|
||||
<div class="time-unit">
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.hdrEnterRatio.value"
|
||||
class="time-input time-input-wide"
|
||||
min="1"
|
||||
max="5"
|
||||
step="0.01"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<span class="time-sep">进入</span>
|
||||
</div>
|
||||
<div class="time-unit">
|
||||
<input
|
||||
type="number"
|
||||
v-model="config.hdrExitRatio.value"
|
||||
class="time-input time-input-wide"
|
||||
min="1"
|
||||
max="5"
|
||||
step="0.01"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<span class="time-sep">退出</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="config-item">
|
||||
<div class="config-label">
|
||||
<span class="config-name">兼容模式 (轮询驱动)</span>
|
||||
|
||||
Reference in new issue
Block a user