fix: matrix key not work
This commit is contained in:
parent
2aa2f1dc37
commit
3883cd8304
|
@ -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,
|
||||
|
|
|
@ -1,28 +1,16 @@
|
|||
<template>
|
||||
<div
|
||||
class="button-container"
|
||||
:style="{
|
||||
<div class="button-container" :style="{
|
||||
width: width + 'px',
|
||||
height: height + 'px',
|
||||
position: 'relative',
|
||||
}"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
:width="width"
|
||||
:height="height"
|
||||
viewBox="400 400 800 800"
|
||||
class="mechanical-button"
|
||||
>
|
||||
}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" :width="width" :height="height" viewBox="400 400 800 800"
|
||||
class="mechanical-button">
|
||||
<!-- defs 和按钮底座保持不变 -->
|
||||
<defs>
|
||||
<filter id="btn-shadow">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="20" result="blur" />
|
||||
<feColorMatrix
|
||||
result="bluralpha"
|
||||
type="matrix"
|
||||
:values="colorMatrix"
|
||||
/>
|
||||
<feColorMatrix result="bluralpha" type="matrix" :values="colorMatrix" />
|
||||
<feOffset in="bluralpha" dx="20" dy="20" result="offsetBlur" />
|
||||
<feMerge>
|
||||
<feMergeNode in="offsetBlur" />
|
||||
|
@ -49,81 +37,42 @@
|
|||
<circle r="20" cx="525" cy="1075" fill="#171717" />
|
||||
|
||||
<!-- 按钮主体 -->
|
||||
<circle
|
||||
r="220"
|
||||
cx="800"
|
||||
cy="800"
|
||||
fill="black"
|
||||
filter="url(#btn-shadow)"
|
||||
/>
|
||||
<circle
|
||||
:r="btnHeight"
|
||||
cx="800"
|
||||
cy="800"
|
||||
:fill="isKeyPressed ? 'url(#pressed)' : 'url(#normal)'"
|
||||
fill-opacity="0.9"
|
||||
@mousedown="toggleButtonState(true)"
|
||||
@mouseup="toggleButtonState(false)"
|
||||
@mouseleave="toggleButtonState(false)"
|
||||
style="
|
||||
<circle r="220" cx="800" cy="800" fill="black" filter="url(#btn-shadow)" />
|
||||
<circle :r="btnHeight" cx="800" cy="800" :fill="isKeyPressed ? 'url(#pressed)' : 'url(#normal)'"
|
||||
fill-opacity="0.9" @mousedown="toggleButtonState(true)" @mouseup="toggleButtonState(false)"
|
||||
@mouseleave="toggleButtonState(false)" style="
|
||||
pointer-events: auto;
|
||||
transition: all 20ms ease-in-out;
|
||||
cursor: pointer;
|
||||
"
|
||||
/>
|
||||
" />
|
||||
<!-- 按键文字 - 仅显示绑定的按键 -->
|
||||
<text
|
||||
v-if="bindKeyDisplay"
|
||||
x="800"
|
||||
y="800"
|
||||
font-size="310"
|
||||
text-anchor="middle"
|
||||
dominant-baseline="central"
|
||||
fill="#ccc"
|
||||
style="
|
||||
<text v-if="bindKeyDisplay" x="800" y="800" font-size="310" text-anchor="middle" dominant-baseline="central"
|
||||
fill="#ccc" style="
|
||||
font-family: Arial;
|
||||
filter: url(#btn-shadow);
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
mix-blend-mode: overlay;
|
||||
"
|
||||
>
|
||||
">
|
||||
{{ bindKeyDisplay }}
|
||||
</text>
|
||||
</svg>
|
||||
|
||||
<!-- 渲染自定义引脚数组 -->
|
||||
<div
|
||||
v-for="pin in props.pins"
|
||||
:key="pin.pinId"
|
||||
:style="{
|
||||
<div v-for="pin in props.pins" :key="pin.pinId" :style="{
|
||||
position: 'absolute',
|
||||
left: `${pin.x * props.size}px`,
|
||||
top: `${pin.y * props.size}px`,
|
||||
transform: 'translate(-50%, -50%)',
|
||||
zIndex: 3,
|
||||
pointerEvents: 'auto',
|
||||
}"
|
||||
:data-pin-wrapper="`${pin.pinId}`"
|
||||
:data-pin-x="`${pin.x * props.size}`"
|
||||
:data-pin-y="`${pin.y * props.size}`"
|
||||
>
|
||||
<Pin
|
||||
:ref="
|
||||
(el) => {
|
||||
}" :data-pin-wrapper="`${pin.pinId}`" :data-pin-x="`${pin.x * props.size}`"
|
||||
:data-pin-y="`${pin.y * props.size}`">
|
||||
<Pin :ref="(el) => {
|
||||
if (el) pinRefs[pin.pinId] = el;
|
||||
}
|
||||
"
|
||||
direction="output"
|
||||
type="digital"
|
||||
:label="pin.pinId"
|
||||
:constraint="pin.constraint"
|
||||
:pinId="pin.pinId"
|
||||
:size="0.8"
|
||||
:componentId="props.componentId"
|
||||
@value-change="handlePinValueChange"
|
||||
@pin-click="handlePinClick"
|
||||
/>
|
||||
" direction="output" type="digital" :label="pin.pinId" :constraint="pin.constraint" :pinId="pin.pinId"
|
||||
:size="0.8" :componentId="props.componentId" @value-change="handlePinValueChange" @pin-click="handlePinClick" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -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}`,
|
||||
);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue