feat(工具箱/MSU2 USB 小屏幕控制): 支持设置屏幕亮度

This commit is contained in:
2026-03-14 13:43:14 +08:00
parent f31020d31c
commit b2d715a1b1

View File

@@ -30,6 +30,13 @@
type="primary" type="primary"
@click="lcdSetDirection(1)" @click="lcdSetDirection(1)"
>设置显示方向</n-button> >设置显示方向</n-button>
<n-button
type="primary"
title="注意:仅支持 PRO 版本的设备"
@click="lcdSetBrightness(lcdBrightness)"
>设置屏幕亮度</n-button>
</n-flex>
<n-flex>
<n-button <n-button
type="primary" type="primary"
:disabled="isUseNewDisplayDataConvertFunction" :disabled="isUseNewDisplayDataConvertFunction"
@@ -110,6 +117,16 @@
/> />
</n-form-item> </n-form-item>
<n-form-item label="屏幕亮度:">
<n-input-number
v-model:value="lcdBrightness"
title="单位:占空比"
:min="0"
:max="1000"
:step="1"
/>
</n-form-item>
<n-form-item label="屏幕捕获帧率:"> <n-form-item label="屏幕捕获帧率:">
<n-input-number <n-input-number
v-model:value="screenCaptureFrameRate" v-model:value="screenCaptureFrameRate"
@@ -212,6 +229,9 @@ const isUseNewDisplayDataConvertFunction = ref(true);
/** 屏幕捕获是否已就绪 */ /** 屏幕捕获是否已就绪 */
const isScreenCaptureReady = ref(false); const isScreenCaptureReady = ref(false);
/** 屏幕亮度 */
const lcdBrightness = ref(500);
/** 渲染间隔,毫秒 */ /** 渲染间隔,毫秒 */
const renderInterval = ref(100); const renderInterval = ref(100);
@@ -941,6 +961,37 @@ function convertDisplayDataLegacy(imageData = []) {
} }
/**
* @description 设置屏幕亮度
* @param {number} pwmDuty 占空比,范围 0 ~ 1000
*/
async function lcdSetBrightness(pwmDuty = 500) {
if (typeof pwmDuty !== 'number' || isNaN(pwmDuty)) {
pwmDuty = 500;
}
if (pwmDuty > 1000) {
pwmDuty = 1000;
}
if (pwmDuty < 0) {
pwmDuty = 0;
}
let hexUse = [];
hexUse.push(2); // LCD 多次写入指令
hexUse.push(3); // 设置指令
hexUse.push(18); // 屏幕亮度指令
hexUse.push(Math.floor(pwmDuty / 256)); // 占空比高字节
hexUse.push(pwmDuty % 256); // 占空比低字节
hexUse.push(0);
await sendData(hexUse);
}
/** /**
* @description 设置显示方向 * @description 设置显示方向
* @param {0|1} direction 显示方向 * @param {0|1} direction 显示方向