Compare commits
No commits in common. "a56a65cc0db77d24f2bc3a61d92bbe12f17c914d" and "1fa944f3c7c894e1343fd57c0f3fc74792fdbb36" have entirely different histories.
a56a65cc0d
...
1fa944f3c7
|
@ -8,20 +8,28 @@
|
||||||
<p>
|
<p>
|
||||||
IDCode: 0x{{ jtagIDCode.toString(16).padStart(8, "0").toUpperCase() }}
|
IDCode: 0x{{ jtagIDCode.toString(16).padStart(8, "0").toUpperCase() }}
|
||||||
</p>
|
</p>
|
||||||
<button class="btn btn-circle w-6 h-6" :disabled="isGettingIDCode" :onclick="getIDCode">
|
<button class="btn btn-circle w-6 h-6" :onclick="getIDCode">
|
||||||
<RefreshCcwIcon class="icon" :class="{ 'animate-spin': isGettingIDCode }" />
|
<RefreshCcwIcon class="icon" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<UploadCard class="bg-base-200" :upload-event="eqps.jtagUploadBitstream"
|
<UploadCard
|
||||||
:download-event="eqps.jtagDownloadBitstream" :bitstream-file="eqps.jtagBitstream"
|
class="bg-base-200"
|
||||||
@update:bitstream-file="handleBitstreamChange">
|
:upload-event="eqps.jtagUploadBitstream"
|
||||||
|
:download-event="eqps.jtagDownloadBitstream"
|
||||||
|
:bitstream-file="eqps.jtagBitstream"
|
||||||
|
@update:bitstream-file="handleBitstreamChange"
|
||||||
|
>
|
||||||
</UploadCard>
|
</UploadCard>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<legend class="fieldset-legend text-sm mb-0.3">Jtag运行频率</legend>
|
<legend class="fieldset-legend text-sm mb-0.3">Jtag运行频率</legend>
|
||||||
<select class="select w-full" @change="handleSelectJtagSpeed" :value="props.jtagFreq">
|
<select
|
||||||
|
class="select w-full"
|
||||||
|
@change="handleSelectJtagSpeed"
|
||||||
|
:value="props.jtagFreq"
|
||||||
|
>
|
||||||
<option v-for="option in selectJtagSpeedOptions" :value="option.id">
|
<option v-for="option in selectJtagSpeedOptions" :value="option.id">
|
||||||
{{ option.text }}
|
{{ option.text }}
|
||||||
</option>
|
</option>
|
||||||
|
@ -30,12 +38,23 @@
|
||||||
<div class="flex flex-row items-center">
|
<div class="flex flex-row items-center">
|
||||||
<fieldset class="fieldset w-70">
|
<fieldset class="fieldset w-70">
|
||||||
<legend class="fieldset-legend text-sm">边界扫描刷新率 / Hz</legend>
|
<legend class="fieldset-legend text-sm">边界扫描刷新率 / Hz</legend>
|
||||||
<input type="number" class="input validator" required placeholder="Type a number between 1 to 1000" min="1"
|
<input
|
||||||
max="1000" v-model="jtagBoundaryScanFreq" title="Type a number between 1 to 1000" />
|
type="number"
|
||||||
|
class="input validator"
|
||||||
|
required
|
||||||
|
placeholder="Type a number between 1 to 1000"
|
||||||
|
min="1"
|
||||||
|
max="1000"
|
||||||
|
v-model="jtagBoundaryScanFreq"
|
||||||
|
title="Type a number between 1 to 1000"
|
||||||
|
/>
|
||||||
<p class="validator-hint">输入一个1 ~ 1000的数</p>
|
<p class="validator-hint">输入一个1 ~ 1000的数</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<button class="btn btn-primary grow mx-4" :class="eqps.enableJtagBoundaryScan ? '' : 'btn-soft'"
|
<button
|
||||||
:onclick="toggleJtagBoundaryScan">
|
class="btn btn-primary grow mx-4"
|
||||||
|
:class="eqps.enableJtagBoundaryScan ? '' : 'btn-soft'"
|
||||||
|
:onclick="toggleJtagBoundaryScan"
|
||||||
|
>
|
||||||
{{ eqps.enableJtagBoundaryScan ? "关闭边界扫描" : "启动边界扫描" }}
|
{{ eqps.enableJtagBoundaryScan ? "关闭边界扫描" : "启动边界扫描" }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -43,12 +62,21 @@
|
||||||
<h1 class="font-bold text-center text-2xl">外设</h1>
|
<h1 class="font-bold text-center text-2xl">外设</h1>
|
||||||
<div class="flex flex-row justify-around">
|
<div class="flex flex-row justify-around">
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<input type="checkbox" class="checkbox" :checked="eqps.enableMatrixKey"
|
<input
|
||||||
@change="handleMatrixkeyCheckboxChange" />
|
type="checkbox"
|
||||||
|
class="checkbox"
|
||||||
|
:checked="eqps.enableMatrixKey"
|
||||||
|
@change="handleMatrixkeyCheckboxChange"
|
||||||
|
/>
|
||||||
<p class="mx-2">启用矩阵键盘</p>
|
<p class="mx-2">启用矩阵键盘</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<input type="checkbox" class="checkbox" :checked="eqps.enablePower" @change="handlePowerCheckboxChange" />
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
class="checkbox"
|
||||||
|
:checked="eqps.enablePower"
|
||||||
|
@change="handlePowerCheckboxChange"
|
||||||
|
/>
|
||||||
<p class="mx-2">启用电源</p>
|
<p class="mx-2">启用电源</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -134,11 +162,8 @@ async function toggleJtagBoundaryScan() {
|
||||||
eqps.enableJtagBoundaryScan = !eqps.enableJtagBoundaryScan;
|
eqps.enableJtagBoundaryScan = !eqps.enableJtagBoundaryScan;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isGettingIDCode = ref(false);
|
|
||||||
async function getIDCode(isQuiet: boolean = false) {
|
async function getIDCode(isQuiet: boolean = false) {
|
||||||
isGettingIDCode.value = true;
|
|
||||||
jtagIDCode.value = await eqps.jtagGetIDCode(isQuiet);
|
jtagIDCode.value = await eqps.jtagGetIDCode(isQuiet);
|
||||||
isGettingIDCode.value = false;
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ const props = withDefaults(defineProps<SevenSegmentDisplayProps>(), {
|
||||||
size: 1,
|
size: 1,
|
||||||
color: "red",
|
color: "red",
|
||||||
AFTERGLOW_BUFFER_SIZE: 1, // 默认存储槽大小为100
|
AFTERGLOW_BUFFER_SIZE: 1, // 默认存储槽大小为100
|
||||||
AFTERGLOW_UPDATE_INTERVAL: 5, // 默认更新间隔为2毫秒
|
AFTERGLOW_UPDATE_INTERVAL: 1, // 默认更新间隔为2毫秒
|
||||||
cathodeType: "common", // 默认为共阴极
|
cathodeType: "common", // 默认为共阴极
|
||||||
pins: () => [
|
pins: () => [
|
||||||
{ pinId: "a", constraint: "", x: 10, y: 170 }, // a段
|
{ pinId: "a", constraint: "", x: 10, y: 170 }, // a段
|
||||||
|
@ -156,16 +156,13 @@ let updateIntervalTimer: number | null = null;
|
||||||
function isSegmentActive(
|
function isSegmentActive(
|
||||||
segment: "a" | "b" | "c" | "d" | "e" | "f" | "g" | "dp",
|
segment: "a" | "b" | "c" | "d" | "e" | "f" | "g" | "dp",
|
||||||
): boolean {
|
): boolean {
|
||||||
return (
|
return segmentStates.value[segment] || afterglowBuffers.value[segment].some(state => state);
|
||||||
segmentStates.value[segment] ||
|
|
||||||
afterglowBuffers.value[segment].some((state) => state)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新引脚状态的函数
|
// 更新引脚状态的函数
|
||||||
function updateSegmentStates() {
|
function updateSegmentStates() {
|
||||||
// 先获取COM口状态
|
// 先获取COM口状态
|
||||||
const comPin = props.pins.find((p) => p.pinId === "COM");
|
const comPin = props.pins.find(p => p.pinId === "COM");
|
||||||
let comActive = true;
|
let comActive = true;
|
||||||
if (comPin && comPin.constraint) {
|
if (comPin && comPin.constraint) {
|
||||||
const comState = getConstraintState(comPin.constraint);
|
const comState = getConstraintState(comPin.constraint);
|
||||||
|
@ -185,8 +182,7 @@ function updateSegmentStates() {
|
||||||
if (["a", "b", "c", "d", "e", "f", "g", "dp"].includes(pin.pinId)) {
|
if (["a", "b", "c", "d", "e", "f", "g", "dp"].includes(pin.pinId)) {
|
||||||
// 如果constraint为空,则默认为未激活状态
|
// 如果constraint为空,则默认为未激活状态
|
||||||
if (!pin.constraint) {
|
if (!pin.constraint) {
|
||||||
segmentStates.value[pin.pinId as keyof typeof segmentStates.value] =
|
segmentStates.value[pin.pinId as keyof typeof segmentStates.value] = false;
|
||||||
false;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,10 +195,9 @@ function updateSegmentStates() {
|
||||||
// 共阳极: 低电平激活段
|
// 共阳极: 低电平激活段
|
||||||
newState = pinState === "low";
|
newState = pinState === "low";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新当前状态
|
// 更新当前状态
|
||||||
segmentStates.value[pin.pinId as keyof typeof segmentStates.value] =
|
segmentStates.value[pin.pinId as keyof typeof segmentStates.value] = newState && comActive;
|
||||||
newState && comActive;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,14 +207,12 @@ function updateAfterglowBuffers() {
|
||||||
for (const segmentId of ["a", "b", "c", "d", "e", "f", "g", "dp"]) {
|
for (const segmentId of ["a", "b", "c", "d", "e", "f", "g", "dp"]) {
|
||||||
const typedSegmentId = segmentId as keyof typeof segmentStates.value;
|
const typedSegmentId = segmentId as keyof typeof segmentStates.value;
|
||||||
const currentState = segmentStates.value[typedSegmentId];
|
const currentState = segmentStates.value[typedSegmentId];
|
||||||
|
|
||||||
// 将当前状态添加到存储槽的开头
|
// 将当前状态添加到存储槽的开头
|
||||||
afterglowBuffers.value[segmentId].unshift(currentState);
|
afterglowBuffers.value[segmentId].unshift(currentState);
|
||||||
|
|
||||||
// 如果存储槽超过了最大容量,移除最旧的状态
|
// 如果存储槽超过了最大容量,移除最旧的状态
|
||||||
if (
|
if (afterglowBuffers.value[segmentId].length > props.AFTERGLOW_BUFFER_SIZE) {
|
||||||
afterglowBuffers.value[segmentId].length > props.AFTERGLOW_BUFFER_SIZE
|
|
||||||
) {
|
|
||||||
afterglowBuffers.value[segmentId].pop();
|
afterglowBuffers.value[segmentId].pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +221,7 @@ function updateAfterglowBuffers() {
|
||||||
// 开始余晖更新间隔
|
// 开始余晖更新间隔
|
||||||
function startAfterglowUpdates() {
|
function startAfterglowUpdates() {
|
||||||
if (updateIntervalTimer) return;
|
if (updateIntervalTimer) return;
|
||||||
|
|
||||||
updateIntervalTimer = window.setInterval(() => {
|
updateIntervalTimer = window.setInterval(() => {
|
||||||
updateSegmentStates();
|
updateSegmentStates();
|
||||||
}, props.AFTERGLOW_UPDATE_INTERVAL);
|
}, props.AFTERGLOW_UPDATE_INTERVAL);
|
||||||
|
@ -254,11 +247,9 @@ function onConstraintChange(constraint: string, level: string) {
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 初始化余晖存储槽
|
// 初始化余晖存储槽
|
||||||
for (const segmentId of ["a", "b", "c", "d", "e", "f", "g", "dp"]) {
|
for (const segmentId of ["a", "b", "c", "d", "e", "f", "g", "dp"]) {
|
||||||
afterglowBuffers.value[segmentId] = Array(props.AFTERGLOW_BUFFER_SIZE).fill(
|
afterglowBuffers.value[segmentId] = Array(props.AFTERGLOW_BUFFER_SIZE).fill(false);
|
||||||
false,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSegmentStates();
|
updateSegmentStates();
|
||||||
onConstraintStateChange(onConstraintChange);
|
onConstraintStateChange(onConstraintChange);
|
||||||
startAfterglowUpdates();
|
startAfterglowUpdates();
|
||||||
|
|
|
@ -27,6 +27,7 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
1000,
|
1000,
|
||||||
new Error("JtagClient Mutex Timeout!"),
|
new Error("JtagClient Mutex Timeout!"),
|
||||||
);
|
);
|
||||||
|
const jtagClient = AuthManager.createAuthenticatedJtagClient();
|
||||||
|
|
||||||
// Matrix Key
|
// Matrix Key
|
||||||
const matrixKeyStates = reactive(new Array<boolean>(16).fill(false));
|
const matrixKeyStates = reactive(new Array<boolean>(16).fill(false));
|
||||||
|
@ -35,6 +36,7 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
1000,
|
1000,
|
||||||
new Error("Matrixkeyclient Mutex Timeout!"),
|
new Error("Matrixkeyclient Mutex Timeout!"),
|
||||||
);
|
);
|
||||||
|
const matrixKeypadClient = AuthManager.createAuthenticatedMatrixKeyClient();
|
||||||
|
|
||||||
// Power
|
// Power
|
||||||
const powerClientMutex = withTimeout(
|
const powerClientMutex = withTimeout(
|
||||||
|
@ -42,6 +44,7 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
1000,
|
1000,
|
||||||
new Error("Matrixkeyclient Mutex Timeout!"),
|
new Error("Matrixkeyclient Mutex Timeout!"),
|
||||||
);
|
);
|
||||||
|
const powerClient = AuthManager.createAuthenticatedPowerClient();
|
||||||
|
|
||||||
// Enable Setting
|
// Enable Setting
|
||||||
const enableJtagBoundaryScan = ref(false);
|
const enableJtagBoundaryScan = ref(false);
|
||||||
|
@ -102,7 +105,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
async function jtagBoundaryScan() {
|
async function jtagBoundaryScan() {
|
||||||
const release = await jtagClientMutex.acquire();
|
const release = await jtagClientMutex.acquire();
|
||||||
try {
|
try {
|
||||||
const jtagClient = AuthManager.createAuthenticatedJtagClient();
|
|
||||||
const portStates = await jtagClient.boundaryScanLogicalPorts(
|
const portStates = await jtagClient.boundaryScanLogicalPorts(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
boardPort.value,
|
boardPort.value,
|
||||||
|
@ -123,7 +125,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
|
|
||||||
async function jtagUploadBitstream(bitstream: File): Promise<boolean> {
|
async function jtagUploadBitstream(bitstream: File): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const jtagClient = AuthManager.createAuthenticatedJtagClient();
|
|
||||||
const resp = await jtagClient.uploadBitstream(
|
const resp = await jtagClient.uploadBitstream(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
toFileParameterOrUndefined(bitstream),
|
toFileParameterOrUndefined(bitstream),
|
||||||
|
@ -139,7 +140,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
async function jtagDownloadBitstream(): Promise<boolean> {
|
async function jtagDownloadBitstream(): Promise<boolean> {
|
||||||
const release = await jtagClientMutex.acquire();
|
const release = await jtagClientMutex.acquire();
|
||||||
try {
|
try {
|
||||||
const jtagClient = AuthManager.createAuthenticatedJtagClient();
|
|
||||||
const resp = await jtagClient.downloadBitstream(
|
const resp = await jtagClient.downloadBitstream(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
boardPort.value,
|
boardPort.value,
|
||||||
|
@ -157,7 +157,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
async function jtagGetIDCode(isQuiet: boolean = false): Promise<number> {
|
async function jtagGetIDCode(isQuiet: boolean = false): Promise<number> {
|
||||||
const release = await jtagClientMutex.acquire();
|
const release = await jtagClientMutex.acquire();
|
||||||
try {
|
try {
|
||||||
const jtagClient = AuthManager.createAuthenticatedJtagClient();
|
|
||||||
const resp = await jtagClient.getDeviceIDCode(
|
const resp = await jtagClient.getDeviceIDCode(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
boardPort.value,
|
boardPort.value,
|
||||||
|
@ -174,7 +173,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
async function jtagSetSpeed(speed: number): Promise<boolean> {
|
async function jtagSetSpeed(speed: number): Promise<boolean> {
|
||||||
const release = await jtagClientMutex.acquire();
|
const release = await jtagClientMutex.acquire();
|
||||||
try {
|
try {
|
||||||
const jtagClient = AuthManager.createAuthenticatedJtagClient();
|
|
||||||
const resp = await jtagClient.setSpeed(
|
const resp = await jtagClient.setSpeed(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
boardPort.value,
|
boardPort.value,
|
||||||
|
@ -193,7 +191,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
const release = await matrixKeypadClientMutex.acquire();
|
const release = await matrixKeypadClientMutex.acquire();
|
||||||
console.log("set Key !!!!!!!!!!!!");
|
console.log("set Key !!!!!!!!!!!!");
|
||||||
try {
|
try {
|
||||||
const matrixKeypadClient = AuthManager.createAuthenticatedMatrixKeyClient();
|
|
||||||
const resp = await matrixKeypadClient.setMatrixKeyStatus(
|
const resp = await matrixKeypadClient.setMatrixKeyStatus(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
boardPort.value,
|
boardPort.value,
|
||||||
|
@ -212,7 +209,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
const release = await matrixKeypadClientMutex.acquire();
|
const release = await matrixKeypadClientMutex.acquire();
|
||||||
try {
|
try {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
const matrixKeypadClient = AuthManager.createAuthenticatedMatrixKeyClient();
|
|
||||||
const resp = await matrixKeypadClient.enabelMatrixKey(
|
const resp = await matrixKeypadClient.enabelMatrixKey(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
boardPort.value,
|
boardPort.value,
|
||||||
|
@ -220,7 +216,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
enableMatrixKey.value = resp;
|
enableMatrixKey.value = resp;
|
||||||
return resp;
|
return resp;
|
||||||
} else {
|
} else {
|
||||||
const matrixKeypadClient = AuthManager.createAuthenticatedMatrixKeyClient();
|
|
||||||
const resp = await matrixKeypadClient.disableMatrixKey(
|
const resp = await matrixKeypadClient.disableMatrixKey(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
boardPort.value,
|
boardPort.value,
|
||||||
|
@ -240,7 +235,6 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
async function powerSetOnOff(enable: boolean) {
|
async function powerSetOnOff(enable: boolean) {
|
||||||
const release = await powerClientMutex.acquire();
|
const release = await powerClientMutex.acquire();
|
||||||
try {
|
try {
|
||||||
const powerClient = AuthManager.createAuthenticatedPowerClient();
|
|
||||||
const resp = await powerClient.setPowerOnOff(
|
const resp = await powerClient.setPowerOnOff(
|
||||||
boardAddr.value,
|
boardAddr.value,
|
||||||
boardPort.value,
|
boardPort.value,
|
||||||
|
@ -268,6 +262,7 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
jtagBitstream,
|
jtagBitstream,
|
||||||
jtagBoundaryScanFreq,
|
jtagBoundaryScanFreq,
|
||||||
jtagClientMutex,
|
jtagClientMutex,
|
||||||
|
jtagClient,
|
||||||
jtagUploadBitstream,
|
jtagUploadBitstream,
|
||||||
jtagDownloadBitstream,
|
jtagDownloadBitstream,
|
||||||
jtagGetIDCode,
|
jtagGetIDCode,
|
||||||
|
@ -277,11 +272,13 @@ export const useEquipments = defineStore("equipments", () => {
|
||||||
enableMatrixKey,
|
enableMatrixKey,
|
||||||
matrixKeyStates,
|
matrixKeyStates,
|
||||||
matrixKeypadClientMutex,
|
matrixKeypadClientMutex,
|
||||||
|
matrixKeypadClient,
|
||||||
matrixKeypadEnable,
|
matrixKeypadEnable,
|
||||||
matrixKeypadSetKeyStates,
|
matrixKeypadSetKeyStates,
|
||||||
|
|
||||||
// Power
|
// Power
|
||||||
enablePower,
|
enablePower,
|
||||||
|
powerClient,
|
||||||
powerClientMutex,
|
powerClientMutex,
|
||||||
powerSetOnOff,
|
powerSetOnOff,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue