Skip to content

Commit

Permalink
adds utility for reading firmware version in v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sphawes committed Feb 12, 2025
1 parent f46251f commit 84638c9
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 5 deletions.
2 changes: 1 addition & 1 deletion commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export let commands = {
MOVE_FEED_FORWARD: [0x04, "UNICAST", 2],
MOVE_FEED_BACKWARD: [0x05, "UNICAST", 2],
MOVE_FEED_STATUS: [0x06, "UNICAST", 1],
VENDOR_OPTIONS: [0xbf, "UNICAST", 0],
VENDOR_OPTIONS: [0xbf, "UNICAST", 21],
GET_FEEDER_ADDRESS: [0xc0, "BROADCAST", 13],
IDENTIFY_FEEDER: [0xc1, "BROADCAST", 13],
PROGRAM_FEEDER_FLOOR: [0xc2, "BROADCAST", 14],
Expand Down
66 changes: 62 additions & 4 deletions feederBus.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,27 @@ export class feederBus {
//if there's more payload than just the command id, or it's defined from payload.length we add it in
if(command[2] > 1 || command[2] == 0){
data = data.concat(payload);

console.log("header and command ID")
console.log(data);

console.log("submitted payload")
console.log(payload);

console.log("payload difference")
console.log(command[2] - 1 - payload.length);

const payloadDiff = command[2] - 1 - payload.length;

if(payloadDiff > 0){ // if payload isn't padded out, stuff zeros

let stuff = Array(payloadDiff).fill(0);
console.log(stuff);
data = data.concat(stuff);
console.log(data);

}

}

//convert to gcode line
Expand Down Expand Up @@ -418,12 +439,19 @@ export class feederBus {
newFeed.appendChild(feedText);
newFeed.classList.add("feed");

//firmware button
let newFirmware = document.createElement("button");
let firmwareText = document.createTextNode("FW Version");
newFirmware.appendChild(firmwareText);
newFirmware.classList.add("firmware");

newFeederDiv.appendChild(feederImage);
newFeederDiv.appendChild(newAddress);
newFeederDiv.appendChild(newUUID);
newFeederDiv.appendChild(newButton);
newFeederDiv.appendChild(newFeed);
newFeederDiv.classList.add("found-feeder")
newFeederDiv.appendChild(newFirmware);
newFeederDiv.classList.add("found-feeder");

let foundFeeders = document.getElementById("found-feeders");

Expand Down Expand Up @@ -453,14 +481,44 @@ export class feederBus {

await this.sendPacket(commands.IDENTIFY_FEEDER, 0xFF, uuid);

return true


return true

}
}
}

async getFirmware(address){
console.log(address);

let versionString = "";

for(let i = 0; i<16; i++){ //go through all sixteen pages of 20

let response = await this.sendPacket(commands.VENDOR_OPTIONS, address, [i]);

if(response == false){
this.modal.show("Firmware Version of Feeder at Slot " + address, "Firmware is 1.3 or earlier, update feeder firmware to use this feature.");
return;
}

for(let j = 0; j < response.length; j++){
const character = String.fromCharCode(response[j]);
if(j > 4){
versionString = versionString + character;
console.log(character);
}

}

console.log(versionString);
}


console.log(versionString);

this.modal.show("Firmware Version of Feeder at Slot " + address, versionString);
}

async programSlotsUtility(){

let resp = await this.modal.show("Before Beginning", "To program your slots, first remove all Photon feeders from your machine. Once you've done this, click ok.\n\nIf at any point you'd like to exit this utility, click cancel.");
Expand Down
16 changes: 16 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ document.getElementById("flash-fifty-button").addEventListener("click", () => {
//event delegation style listener for the feeder parent div, handling feeding and such from the parent
// https://davidwalsh.name/event-delegate
document.getElementById("found-feeders").addEventListener("click", function(e) {

// e.target is the clicked element!
let clickedElement = e.target;

// If it was a list item
if(clickedElement.className.split(' ').includes("identify") && clickedElement.nodeName == "BUTTON") {
// List item found! Output the ID!
Expand All @@ -218,6 +220,7 @@ document.getElementById("found-feeders").addEventListener("click", function(e) {

feeder.sendPacket(commands.IDENTIFY_FEEDER, 0xFF, uuid);
}

else if(clickedElement.className.split(' ').includes("feed") && clickedElement.nodeName == "BUTTON"){
let foundFeederDiv = clickedElement.parentElement;

Expand All @@ -227,6 +230,19 @@ document.getElementById("found-feeders").addEventListener("click", function(e) {

feeder.sendPacket(commands.MOVE_FEED_FORWARD, addr, 0x28);
}

else if(clickedElement.className.split(' ').includes("firmware") && clickedElement.nodeName == "BUTTON"){
let foundFeederDiv = clickedElement.parentElement;

let addr = foundFeederDiv.getElementsByTagName('H3')[0].innerHTML;

addr = parseInt(addr);

feeder.getFirmware(addr);
}



});


6 changes: 6 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
// config options
optimizeDeps: { exclude: ["fsevents"] },

publicDir: 'public'
}

0 comments on commit 84638c9

Please sign in to comment.