GCode Lookup / Search in 'Send Code...' Field
CCS86 last edited by
I had an idea for a Web Control feature that I think would be super useful:
I'm starting to memorize my most often used gcodes, but still leave a tab open to the complete list for reference.
Integrating a plain text search/lookup in the gcode entry field would be extremely helpful. You could just type some keywords for the G/M code you were looking for, and in the autocomplete suggestions below, it would populate related gcodes with brief descriptions. You could then arrow down to the correct one, hit enter, and maybe even be prompted for relevant parameter values as well.
Danal last edited by Danal
This is VERY easy to do because the "gcode" page, https://duet3d.dozuki.com/Wiki/Gcode, has section tags in it that contain the G or M codes, and certain keywords that are useful for searches.
Here are some pieces of implementing this. I am putting them here because I tested them in a console debugger and I don't want to lose them.
- Place a copy of https://duet3d.dozuki.com/Wiki/Gcode.html on the SD card in /www.
This implies that update releases of DWC would need to include refreshes of this page, copied from the dozuki.
Add a field for the user to type "G1" or "Move" or whatever word they want to search. Probably on the console page (so as not to further clutter the main page).
Fetch the Gcode page into a variable, with regular old Java script.
var r = new XMLHttpRequest(); r.open('GET', '/Gcode.html', false); r.send(null); nextstring = r.responsetext;
- Run a loop, searching via a regular expression (I tested the regex repeatability; i did not test a loop):
sregex = /(.*?)("#Section_(?:(?!#Section_).)*?**what the user entered**.*?")(.*)/g; #loop of some sort sresult = sregex.exec(nextstring) nextstring = sresult link = sresult # Note: need to accumulate the links, and display them to the user. link = "//https://duet3d.dozuki.com/Wiki/Gcode" + link.substring(0,link.length - 1); # Remove trailing quote if (nextstring == "" ) break; # end of loop
- Present results to user as links.