fix: 修复jtag未认证的问题
This commit is contained in:
@@ -93,7 +93,7 @@ const props = withDefaults(defineProps<SevenSegmentDisplayProps>(), {
|
||||
size: 1,
|
||||
color: "red",
|
||||
AFTERGLOW_BUFFER_SIZE: 1, // 默认存储槽大小为100
|
||||
AFTERGLOW_UPDATE_INTERVAL: 1, // 默认更新间隔为2毫秒
|
||||
AFTERGLOW_UPDATE_INTERVAL: 5, // 默认更新间隔为2毫秒
|
||||
cathodeType: "common", // 默认为共阴极
|
||||
pins: () => [
|
||||
{ pinId: "a", constraint: "", x: 10, y: 170 }, // a段
|
||||
@@ -156,13 +156,16 @@ let updateIntervalTimer: number | null = null;
|
||||
function isSegmentActive(
|
||||
segment: "a" | "b" | "c" | "d" | "e" | "f" | "g" | "dp",
|
||||
): boolean {
|
||||
return segmentStates.value[segment] || afterglowBuffers.value[segment].some(state => state);
|
||||
return (
|
||||
segmentStates.value[segment] ||
|
||||
afterglowBuffers.value[segment].some((state) => state)
|
||||
);
|
||||
}
|
||||
|
||||
// 更新引脚状态的函数
|
||||
function updateSegmentStates() {
|
||||
// 先获取COM口状态
|
||||
const comPin = props.pins.find(p => p.pinId === "COM");
|
||||
const comPin = props.pins.find((p) => p.pinId === "COM");
|
||||
let comActive = true;
|
||||
if (comPin && comPin.constraint) {
|
||||
const comState = getConstraintState(comPin.constraint);
|
||||
@@ -182,7 +185,8 @@ function updateSegmentStates() {
|
||||
if (["a", "b", "c", "d", "e", "f", "g", "dp"].includes(pin.pinId)) {
|
||||
// 如果constraint为空,则默认为未激活状态
|
||||
if (!pin.constraint) {
|
||||
segmentStates.value[pin.pinId as keyof typeof segmentStates.value] = false;
|
||||
segmentStates.value[pin.pinId as keyof typeof segmentStates.value] =
|
||||
false;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -195,9 +199,10 @@ function updateSegmentStates() {
|
||||
// 共阳极: 低电平激活段
|
||||
newState = pinState === "low";
|
||||
}
|
||||
|
||||
|
||||
// 更新当前状态
|
||||
segmentStates.value[pin.pinId as keyof typeof segmentStates.value] = newState && comActive;
|
||||
segmentStates.value[pin.pinId as keyof typeof segmentStates.value] =
|
||||
newState && comActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,12 +212,14 @@ function updateAfterglowBuffers() {
|
||||
for (const segmentId of ["a", "b", "c", "d", "e", "f", "g", "dp"]) {
|
||||
const typedSegmentId = segmentId as keyof typeof segmentStates.value;
|
||||
const currentState = segmentStates.value[typedSegmentId];
|
||||
|
||||
|
||||
// 将当前状态添加到存储槽的开头
|
||||
afterglowBuffers.value[segmentId].unshift(currentState);
|
||||
|
||||
|
||||
// 如果存储槽超过了最大容量,移除最旧的状态
|
||||
if (afterglowBuffers.value[segmentId].length > props.AFTERGLOW_BUFFER_SIZE) {
|
||||
if (
|
||||
afterglowBuffers.value[segmentId].length > props.AFTERGLOW_BUFFER_SIZE
|
||||
) {
|
||||
afterglowBuffers.value[segmentId].pop();
|
||||
}
|
||||
}
|
||||
@@ -221,7 +228,7 @@ function updateAfterglowBuffers() {
|
||||
// 开始余晖更新间隔
|
||||
function startAfterglowUpdates() {
|
||||
if (updateIntervalTimer) return;
|
||||
|
||||
|
||||
updateIntervalTimer = window.setInterval(() => {
|
||||
updateSegmentStates();
|
||||
}, props.AFTERGLOW_UPDATE_INTERVAL);
|
||||
@@ -247,9 +254,11 @@ function onConstraintChange(constraint: string, level: string) {
|
||||
onMounted(() => {
|
||||
// 初始化余晖存储槽
|
||||
for (const segmentId of ["a", "b", "c", "d", "e", "f", "g", "dp"]) {
|
||||
afterglowBuffers.value[segmentId] = Array(props.AFTERGLOW_BUFFER_SIZE).fill(false);
|
||||
afterglowBuffers.value[segmentId] = Array(props.AFTERGLOW_BUFFER_SIZE).fill(
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
updateSegmentStates();
|
||||
onConstraintStateChange(onConstraintChange);
|
||||
startAfterglowUpdates();
|
||||
|
||||
Reference in New Issue
Block a user