Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    GCode Lookup / Search in 'Send Code...' Field

    Scheduled Pinned Locked Moved
    Duet Web Control
    2
    2
    122
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CCS86undefined
      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.

      Thoughts?

      1 Reply Last reply Reply Quote 0
      • Danalundefined
        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 is necessary because the browser will not let Javascript fetch web pages from "across domains". DWC will be running from the "domain" of your local printer. It won't fetch dozuki.com pages. This is a security thing.

        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[3]
          link = sresult[2] 
            # 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.

        That's it!

        Delta / Kossel printer fanatic

        1 Reply Last reply Reply Quote 1
        • First post
          Last post
        Unless otherwise noted, all forum content is licensed under CC-BY-SA