From 3883cd8304b2cd888818ff4c25eb2d8149e99cb9 Mon Sep 17 00:00:00 2001 From: SikongJueluo Date: Tue, 20 May 2025 18:11:04 +0800 Subject: [PATCH] fix: matrix key not work --- public/EquipmentTemplates/MatrixKey.json | 16 +++ .../equipments/MechanicalButton.vue | 115 +++++------------- src/stores/equipments.ts | 14 +-- 3 files changed, 51 insertions(+), 94 deletions(-) diff --git a/public/EquipmentTemplates/MatrixKey.json b/public/EquipmentTemplates/MatrixKey.json index 7ec4cd4..bd6ed2f 100644 --- a/public/EquipmentTemplates/MatrixKey.json +++ b/public/EquipmentTemplates/MatrixKey.json @@ -29,6 +29,7 @@ "attrs": { "size": 0.5, "bindKey": "1", + "bindMatrixKey": "0", "pins": [] }, "rotate": 0, @@ -46,6 +47,7 @@ "attrs": { "size": 0.5, "bindKey": "2", + "bindMatrixKey": "1", "pins": [] }, "rotate": 0, @@ -63,6 +65,7 @@ "attrs": { "size": 0.5, "bindKey": "3", + "bindMatrixKey": "2", "pins": [] }, "rotate": 0, @@ -80,6 +83,7 @@ "attrs": { "size": 0.5, "bindKey": "A", + "bindMatrixKey": "3", "pins": [] }, "rotate": 0, @@ -97,6 +101,7 @@ "attrs": { "size": 0.5, "bindKey": "4", + "bindMatrixKey": "4", "pins": [] }, "rotate": 0, @@ -114,6 +119,7 @@ "attrs": { "size": 0.5, "bindKey": "5", + "bindMatrixKey": "5", "pins": [] }, "rotate": 0, @@ -131,6 +137,7 @@ "attrs": { "size": 0.5, "bindKey": "6", + "bindMatrixKey": "6", "pins": [] }, "rotate": 0, @@ -148,6 +155,7 @@ "attrs": { "size": 0.5, "bindKey": "B", + "bindMatrixKey": "7", "pins": [] }, "rotate": 0, @@ -165,6 +173,7 @@ "attrs": { "size": 0.5, "bindKey": "7", + "bindMatrixKey": "8", "pins": [] }, "rotate": 0, @@ -182,6 +191,7 @@ "attrs": { "size": 0.5, "bindKey": "8", + "bindMatrixKey": "9", "pins": [] }, "rotate": 0, @@ -199,6 +209,7 @@ "attrs": { "size": 0.5, "bindKey": "9", + "bindMatrixKey": "10", "pins": [] }, "rotate": 0, @@ -216,6 +227,7 @@ "attrs": { "size": 0.5, "bindKey": "C", + "bindMatrixKey": "11", "pins": [] }, "rotate": 0, @@ -233,6 +245,7 @@ "attrs": { "size": 0.5, "bindKey": "*", + "bindMatrixKey": "12", "pins": [] }, "rotate": 0, @@ -250,6 +263,7 @@ "attrs": { "size": 0.5, "bindKey": "0", + "bindMatrixKey": "13", "pins": [] }, "rotate": 0, @@ -267,6 +281,7 @@ "attrs": { "size": 0.5, "bindKey": "#", + "bindMatrixKey": "14", "pins": [] }, "rotate": 0, @@ -284,6 +299,7 @@ "attrs": { "size": 0.5, "bindKey": "D", + "bindMatrixKey": "15", "pins": [] }, "rotate": 0, diff --git a/src/components/equipments/MechanicalButton.vue b/src/components/equipments/MechanicalButton.vue index 6c92e42..6c11f94 100644 --- a/src/components/equipments/MechanicalButton.vue +++ b/src/components/equipments/MechanicalButton.vue @@ -1,28 +1,16 @@ @@ -206,7 +155,9 @@ function toggleButtonState(isPressed: boolean) { // 矩阵键盘 if (eqps.enableMatrixKey) { const ret = eqps.setMatrixKey(props.bindMatrixKey, isPressed); - if (!ret) + + if (ret) eqps.matrixKeypadSetKeyStates(eqps.matrixKeyStates); + else dialog.error( `绑定的矩阵键盘值只能是0 ~ 15,而不是: ${props.bindMatrixKey}`, ); diff --git a/src/stores/equipments.ts b/src/stores/equipments.ts index 1377525..e259b54 100644 --- a/src/stores/equipments.ts +++ b/src/stores/equipments.ts @@ -38,16 +38,6 @@ export const useEquipments = defineStore('equipments', () => { if (true === enableJtagBoundaryScan.value) jtagBoundaryScan(); }); - watchPostEffect(async () => { - if (true === enableMatrixKey.value) { - const ret = await matrixKeypadSetKeyStates(matrixKeyStates) - if (!ret) { - dialog.error("设置矩阵键盘失败") - enableMatrixKey.value = false; - } - } - }) - // Parse and Set function setAddr(address: string | undefined): boolean { if (isString(address) && z.string().ip("4").safeParse(address).success) { @@ -76,7 +66,6 @@ export const useEquipments = defineStore('equipments', () => { } function setMatrixKey(keyNum: number | string | undefined, keyValue: boolean): boolean { - let _keyNum: number; if (isString(keyNum)) { _keyNum = toNumber(keyNum); @@ -180,11 +169,12 @@ export const useEquipments = defineStore('equipments', () => { async function matrixKeypadSetKeyStates(keyStates: boolean[]) { const release = await matrixKeypadClientMutex.acquire(); + console.log("set Key !!!!!!!!!!!!"); try { const resp = await matrixKeypadClient.setMatrixKeyStatus( boardAddr.value, boardPort.value, - matrixKeyStates + keyStates ); return resp; } catch (e) {