don't list non animation files

node_mode
Jake 2025-11-02 16:17:43 +08:00
parent 5a9eee688b
commit 7a619886c6
1 changed files with 19 additions and 16 deletions

View File

@ -117,7 +117,7 @@ window.onload = () => {
motorIDList.push(motor.ID); motorIDList.push(motor.ID);
addDial(motor.ID, motor.NAME); addDial(motor.ID, motor.NAME);
} }
if (connectedRobot.motors.length > 0){ if (connectedRobot.motors.length > 0) {
setSelectedMotor(connectedRobot.motors[0].ID); setSelectedMotor(connectedRobot.motors[0].ID);
} }
@ -420,7 +420,9 @@ window.onload = () => {
clearFileList(); clearFileList();
files.forEach(filename => { files.forEach(filename => {
if (filename) addFileToList(filename); if (filename && filename.toLowerCase().endsWith(".anim")) {
addFileToList(filename);
}
}); });
break; break;
@ -459,8 +461,8 @@ window.onload = () => {
//console.log(stringPayload); //console.log(stringPayload);
document.getElementById('log').value += "MSG: " + stringPayload + `\n`; document.getElementById('log').value += "MSG: " + stringPayload + `\n`;
const logBox = document.getElementById('log'); const logBox = document.getElementById('log');
logBox.value += "MSG: " + stringPayload + `\n`; logBox.value += "MSG: " + stringPayload + `\n`;
logBox.scrollTop = logBox.scrollHeight; logBox.scrollTop = logBox.scrollHeight;
// 🔹 Do something with the file // 🔹 Do something with the file
//handleLoadedFile(fileData); //handleLoadedFile(fileData);
break; break;
@ -517,20 +519,21 @@ logBox.scrollTop = logBox.scrollHeight;
}); });
function handlePositionStreamPacket(data) { function handlePositionStreamPacket(data) {
const motorCount = Math.floor(data.length / 2); // Each motor uses 2 bytes
//console.log(data);
const motorCount = Math.floor(data.length / 2); // Each motor uses 2 bytes
let d = [];
for (let i = 0; i < motorCount; i++) { for (let i = 0; i < motorCount; i++) {
const high = data[i * 2]; // High byte const high = data[i * 2]; // High byte
const low = data[i * 2 + 1]; // Low byte const low = data[i * 2 + 1]; // Low byte
const value = (high << 8) | low; // Combine into uint16_t const value = (low << 8) | high; // Combine into uint16_t
d.push(value);
if (dials[i]) { if (dials[i]) {
dials[i].value = value; dials[i].value = value;
} }
} }
console.log(data); }
}
function handleLoadedFile(data) { function handleLoadedFile(data) {
const raw = new Uint8Array(data); const raw = new Uint8Array(data);
@ -1121,7 +1124,7 @@ logBox.scrollTop = logBox.scrollHeight;
// If motor is in robot config already, grab the name // If motor is in robot config already, grab the name
let configMotor = connectedRobot.getMotor(motor.ID); let configMotor = connectedRobot.getMotor(motor.ID);
if (configMotor != null){ if (configMotor != null) {
motor.NAME = configMotor.NAME; motor.NAME = configMotor.NAME;
} }