Beeprint Web interface with Marlin

Tagged: ,

Viewing 5 reply threads
  • Author
    Posts
    • #31641
      Victor
      Participant

        I need to recompile web interface to make it working properly with Marlin because in the current status some things are broken due to unsupported gcode.

        The command fix that I’m considering to do is the following

        /*
        tool 'T0' 'T1' ''
        */
        export const preHeatTool = (tool, temperature) => {
          if (tool === 'Bed') {
            return 'M140 S' + temperature + '\r\n';
          } else {
            return 'M104 S' + temperature + ' ' + tool + '\r\n';
          }
        };
        
        export const multipleStatRequest = () => {
          return 'M105\r\n' + // Report temperatures
            'M31\r\n' + // Report print time
            'M27\r\n' + // Report SD card print status (percentage)
            '\r\n';
        };
        
        export const requestFileList = (path = '') => {
          return 'M20 ' + path + '\r\n';
        };
        
        export const selectAndPrint = (file) => {
          return 'M23 ' + file + '\r\n' +
            'M24\r\n' +
            '\r\n';
        };
        export const printSelectFile = (file) => {
          return 'M23 ' + file + '\r\n';
        };
        export const printResumeStart = () => {
          return 'M24\r\n';
        };
        export const printPause = () => {
          return 'M25\r\n';
        };
        export const printStop = (file) => {
          return 'M524\r\n';
        };
        export const deleteFile = (file) => {
          return 'M30 ' + file + '\r\n';
        };
        
        // From 0 to 255
        export const setFanSpeed = (speed) => {
          return 'M106 S' + speed + '\r\n';
        };
        
        export const cooldown = () => {
          return 'M104 S0\r\n' +
            'M140 S0\r\n';
        };
        export const unlock = () => {
          return 'M84\r\n';
        };
        
        export const moveAxes = (axis, step) => {
          let xA = '0.0';
          let yA = '0.0';
          let zA = '0.0';
        
          if (axis.toUpperCase() === 'X') {
            xA = step + '.0';
          } else if (axis.toUpperCase() === 'Y') {
            yA = step + '.0';
          } else if (axis.toUpperCase() === 'Z') {
            zA = step + '.0';
          }
          return 'G91\r\n' +
            'G0 X' + xA + ' Y' + yA + '.0 Z' + zA + '.0 F3000\r\n' +
            'G90\r\n';
        };
        
        export const extrudeFilament = (extruder, step) => {
          return 'T' + extruder + '\r\n' +
            'G91\r\n' +
            'G1 E' + step + ' F1000\r\n' +
            'G90\r\n';
        };
        
        export const homingXY = () => {
          return 'G28 X Y\r\n';
        };
        export const homingZ = () => {
          return 'G28 Z\r\n';
        };
        export const homingAll = () => {
          return 'G28 \r\n';
        };
        export const resetPrinter = () => {
          return 'M107\r\n' +
            'G1 Z10\r\n' +
            'M104 S0\r\n' +
            'M140 S0\r\n' +
            'M84\r\n';
        };
        
        export const coolDown = () => {
          return 'M104 S0\r\n' +
            'M140 S0\r\n' +
            'M106 S255\r\n';
        };
        export const unlockMotors = () => {
          return 'M84\r\n';
        };

        I don’t know if may be needed some fix also to the code that parse the response of these commands.
        I would like some more details on the step to follow to compile the web interface to MksWifi_WebView.bin of the firmware as the current guide explain only the build process of the mkswifi.bin. In the repo readme there is written to run npm run build but this alone cannot work. It is also missing the description of the needed dependencies. I want to be able to generate a MksWifi_WebView.bin to place in sd to update the webinterface.

        Thanks for the support.

        • This topic was modified 1 year, 2 months ago by Victor. Reason: extruder selection fix
        • This topic was modified 1 year, 2 months ago by Renzo Mischianti. Reason: Fix code format
      • #31643
        Victor
        Participant

          To detail better my building attempts.

          In addition to the problem to compile webinterface files themselves to include Marlin commands patch, to get the file that should be placed in the data folder according the guide, but there isn’t any indication on to configure the toolchain to compile them (I can see that is some node project with react redux dependencies).

          I have also tried to recompile it leaving the data folder untouched and following everything mentioned in the guide (using the older Arduino IDE because the mentioned SPIFFS plugin isn’t updated for the latest version) just to see what happens, and I get a compiled file named MKS_WIFI_upgrade_with_BeePrint_web_interface.bin of 375KB that is basically same size of MksWifi.bin compiled from the ino file despite webview should be around 3048KB.

          Checking the MKS_WIFI_upgrade_with_BeePrint_web_interface folder structure I can see also metadata folders that aren’t of ArduinoIDE but belongs to different IDEs as Sloeber and Intellij and is unclear if one of both of them have a role in the unclear build process of MksWifi_WebView.bin file.

          In all other things you have been very clear and detailed but build of MksWifi_WebView.bin is a mistery. Maybe depend by the fact I’m trying to export it to bin rather than upload directly with plugin but I cannot access the module directly as it is soldered inside the machine.

          Would be very appreciated if you can explain how to do.

          • This reply was modified 1 year, 2 months ago by Victor.
          • This reply was modified 1 year, 2 months ago by Victor.
        • #31652
          Renzo Mischianti
          Keymaster

            Hi Victor,
            I uploaded a new version with the Marilin command to the web UI.
            To generate a bin, I followed the old guide and worked correctly.

            I built your version, and you can download it from here.

            Bye Renzo

            • #31654
              Victor
              Participant

                Thank you very much for the reply and for the build.

                About build issues

                If there is nothing else to do other than what is written in the guides so the problems I’m facing with compilation are caused by some mismatch in the toolkit versions I’m using because the webinterface refuses to compile.

                What version of Node and npm packages you used to build the content of data folder?

                and…The tools plugin in arduino creates only a SPIFFS image of content in data folder (so basically MksWifi_WebView.bin is just the data folder converted in SPIFFS) and then upload it, or it also combines SPIFFS image of data folder with the compiled .ino file?

                About Marlin gcode firmware test

                The gcode that I have posted seems that needs to be further adjusted. the problem is with multipleStatRequest that I did not understand.

                export const multipleStatRequest = () => {
                return ‘M105\r\n’ +
                ‘M997\r\n’ + // M997 request printig status
                ‘M994\r\n’ +
                ‘M992\r\n’ + // M992 printing time
                ‘M27\r\n’ + // M27 printing percentage
                ‘\r\n’;
                };

                In the comment it is said that M997 requests print status, but if I search
                M997 in both reprap and marlin documentation it seems it is used to request in application firmware update.
                M994 in marlin is reported as “Restore flash from SD”
                in Reprap wiki I cannot find what this command does

                you indicated M992 as printing time but in gcode documentation I see that is used for clearing the emergency stop condition.

                So could you explain if you use them in some unconventional way or there is some other gcode convention used and where I can find info about these so I can better do a proper conversion?

                EDIT
                I have realized that multipleStatRequest contains instructions that aren’t gcode but are translated by wifi code to other commands.
                This has confused me a lot, leading me to the wrong considerations that was M997 that caused the reboot of the printer because that gcode is used for the firmware in Marlin.
                Now I have yet to understand what is that could cause this:
                if I print a file using beeprint at the end of print the printer reboot and restart again the print of the same file,

                Thanks again. I know… I have done a lot of questions =)

                • This reply was modified 1 year, 2 months ago by Victor.
                • This reply was modified 1 year, 2 months ago by Victor.
                • This reply was modified 1 year, 2 months ago by Victor.
            • #31658
              Renzo Mischianti
              Keymaster

                Hi Victor,
                ok, my version of Node is

                
                PS D:\Projects\IdeaProjects\mks\mks_wifi_mischianti_ui> node --version
                v16.18.0
                

                my npm version is

                
                PS D:\Projects\IdeaProjects\mks\mks_wifi_mischianti_ui> npm --version
                9.1.2
                

                here my complete list of library dependencies

                
                PS D:\Projects\IdeaProjects\mks\mks_wifi_mischianti_ui> npm list        
                beeprint_mks_wifi@1.7 D:\Projects\IdeaProjects\mks\mks_wifi_mischianti_ui
                +-- @babel/core@7.12.17
                +-- @babel/plugin-proposal-class-properties@7.14.5
                +-- @babel/polyfill@7.12.1
                +-- @babel/preset-env@7.12.17
                +-- @babel/preset-react@7.12.13
                +-- @formatjs/intl-pluralrules@4.1.2
                +-- @formatjs/intl-relativetimeformat@9.2.2
                +-- @material-ui/core@4.12.3
                +-- @material-ui/icons@4.11.2
                +-- @wojtekmaj/enzyme-adapter-react-17@0.8.0
                +-- autoprefixer@10.3.1
                +-- axios@0.21.4
                +-- babel-loader@8.2.2
                +-- babel-plugin-module-resolver@4.1.0
                +-- compression-webpack-plugin@8.0.1
                +-- connected-react-router@6.9.3
                +-- copy-webpack-plugin@6.4.1
                +-- cross-env@7.0.3
                +-- css-loader@5.2.7
                +-- d3-format@3.0.1
                +-- d3-time-format@4.0.0
                +-- enzyme@3.11.0
                +-- eslint-config-standard@14.1.1
                +-- eslint-plugin-import@2.22.1
                +-- eslint-plugin-node@11.1.0
                +-- eslint-plugin-promise@4.3.1
                +-- eslint-plugin-react@7.22.0
                +-- eslint-plugin-standard@4.1.0
                +-- eslint@6.8.0
                +-- file-loader@5.1.0
                +-- history@4.10.1
                +-- html-webpack-plugin@4.5.2
                +-- http-server@14.1.1
                +-- intl@1.2.5
                +-- jest@24.9.0
                +-- lodash.throttle@4.1.1
                +-- node-sass@6.0.1
                +-- perfect-scrollbar@1.5.2
                +-- react-ace@9.5.0
                +-- react-dom@17.0.2
                +-- react-grid-layout@1.3.4
                +-- react-intl@5.20.9
                +-- react-perfect-scrollbar@1.5.8
                +-- react-redux@7.2.4
                +-- react-router-dom@5.2.0
                +-- react-sizeme@3.0.1
                +-- react-stockcharts@0.7.9-SNAPSHOT.7
                +-- react@17.0.2
                +-- redux-logic@3.0.3
                +-- redux@4.1.1
                +-- regenerator-runtime@0.13.9
                +-- replace-in-file-webpack-plugin@1.0.6
                +-- sass-loader@11.1.1
                +-- save-svg-as-png@1.4.17
                +-- serve@11.3.2
                +-- shx@0.3.3
                +-- style-loader@2.0.0
                +-- terser-webpack-plugin@5.1.4
                +-- webpack-cli@4.8.0
                +-- webpack-dev-server@3.11.3
                +-- webpack-merge@5.8.0
                +-- webpack-visualizer-plugin2@1.0.0
                -- webpack@5.50.0
                

                For the “compilation” o web folder you can follow the instructions of the guide, but basically, after build the project you can launch the uploader of ArduinoIDE 1.x (now there is a version for 2.x, but I use the old one)

                and you can find the file path in the console and grab It.

                Basically in the temporary folder like C:\Users\renzo\AppData\Local\Temp\arduino_build_785244 you can find some file like so:

                
                
                core
                libraries
                preproc
                sketch
                build.options.json
                includes.cache
                local.eagle.app.v6.common.ld
                MKS_WIFI_upgrade_with_BeePrint_web_interface.ino.bin
                MKS_WIFI_upgrade_with_BeePrint_web_interface.ino.elf
                MKS_WIFI_upgrade_with_BeePrint_web_interface.ino.map
                MKS_WIFI_upgrade_with_BeePrint_web_interface.spiffs.bin
                

                For the Gcode follow the relative article with the specified code offered from the MKS_WIFI firmware

                You can find the relative implementation here on the firmware.

                
                
                        {
                          /*transfer gcode*/
                          //Serial.write(cmd_line, readNum);
                          if((strchr((const char *)cmd_line, 'G') != 0)
                            || (strchr((const char *)cmd_line, 'M') != 0)
                            || (strchr((const char *)cmd_line, 'T') != 0))
                          {
                            if(strchr((const char *)cmd_line, '\n') != 0 )
                            {
                              String gcode((const char *)cmd_line);
                
                            //  sprintf((char *)dbgStr, "read %d: %s\n", readNum, cmd_line);
                
                          //    net_print((const uint8_t *)dbgStr, strlen((char *)dbgStr));
                
                              if(gcode.startsWith("M998") && (M3_TYPE == ROBIN))
                              {
                                net_print((const uint8_t *) "ok\r\n", strlen((const char *)"ok\r\n"));
                              }
                              else if(gcode.startsWith("M997"))
                              {
                                if(gPrinterInf.print_state == PRINTER_IDLE)
                                //  net_print((const uint8_t *) "M997 IDLE\r\n", strlen((const char *)"M997 IDLE\r\n"));
                                  strcpy((char *)dbgStr, "M997 IDLE\r\n");
                                else if(gPrinterInf.print_state == PRINTER_PRINTING)
                                //  net_print((const uint8_t *) "M997 PRINTING\r\n", strlen((const char *)"M997 PRINTING\r\n"));
                                  strcpy((char *)dbgStr, "M997 PRINTING\r\n");
                                else if(gPrinterInf.print_state == PRINTER_PAUSE)
                                  //net_print((const uint8_t *) "M997 PAUSE\r\n", strlen((const char *)"M997 PAUSE\r\n"));
                                  strcpy((char *)dbgStr, "M997 PAUSE\r\n");
                                else
                                  strcpy((char *)dbgStr, "M997 NOT CONNECTED\r\n");
                              //  net_print((const uint8_t *) "ok\r\n", strlen((const char *)"ok\r\n"));
                              }
                              else if(gcode.startsWith("M27"))
                              {
                                memset(dbgStr, 0, sizeof(dbgStr));
                                sprintf((char *)dbgStr, "M27 %d\r\n", gPrinterInf.print_file_inf.print_rate);
                              //  net_print((const uint8_t *) dbgStr, strlen((const char *)dbgStr));
                              //  net_print((const uint8_t *) "ok\r\n", strlen((const char *)"ok\r\n"));
                              }
                              else if(gcode.startsWith("M992"))
                              {
                                memset(dbgStr, 0, sizeof(dbgStr));
                                sprintf((char *)dbgStr, "M992 %02d:%02d:%02d\r\n",
                                  gPrinterInf.print_file_inf.print_hours, gPrinterInf.print_file_inf.print_mins, gPrinterInf.print_file_inf.print_seconds);
                              //  net_print((const uint8_t *) dbgStr, strlen((const char *)dbgStr));
                              //  net_print((const uint8_t *) "ok\r\n", strlen((const char *)"ok\r\n"));
                              }
                              else if(gcode.startsWith("M994"))
                              {
                                memset(dbgStr, 0, sizeof(dbgStr));
                                sprintf((char *)dbgStr, "M994 %s;%d\r\n",
                                  gPrinterInf.print_file_inf.file_name.c_str(), gPrinterInf.print_file_inf.file_size);
                              //  net_print((const uint8_t *) dbgStr, strlen((const char *)dbgStr));
                              //  net_print((const uint8_t *) "ok\r\n", strlen((const char *)"ok\r\n"));
                              }
                              else  if(gcode.startsWith("M115"))
                              {
                                memset(dbgStr, 0, sizeof(dbgStr));
                                if(M3_TYPE == ROBIN)
                                  strcpy((char *)dbgStr, "FIRMWARE_NAME:Robin\r\n");
                                else if(M3_TYPE == TFT28)
                                  strcpy((char *)dbgStr, "FIRMWARE_NAME:TFT28/32\r\n");
                                else if(M3_TYPE == TFT24)
                                  strcpy((char *)dbgStr, "FIRMWARE_NAME:TFT24\r\n");
                
                              //  net_print((const uint8_t *) dbgStr, strlen((const char *)dbgStr));
                              //  net_print((const uint8_t *) "ok\r\n", strlen((const char *)"ok\r\n"));
                              }
                              /*else if(gcode.startsWith("M105"))
                              {
                                memset(dbgStr, 0, sizeof(dbgStr));
                                sprintf((char *)dbgStr, "T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n",
                                  (int)gPrinterInf.curSprayerTemp[0], (int)gPrinterInf.desireSprayerTemp[0], (int)gPrinterInf.curBedTemp, (int)gPrinterInf.desireBedTemp,
                                  (int)gPrinterInf.curSprayerTemp[0], (int)gPrinterInf.desireSprayerTemp[0], (int)gPrinterInf.curSprayerTemp[1], (int)gPrinterInf.desireSprayerTemp[1]);
                
                              //  net_print((const uint8_t *) dbgStr, strlen((const char *)dbgStr));
                              //  net_print((const uint8_t *) "ok\r\n", strlen((const char *)"ok\r\n"));
                              }*/
                              else
                              {
                                DEBUG_PRINT(F("GCODE COMMANDS "));
                                DEBUG_PRINTLN(gcode);
                
                                if(gPrinterInf.print_state == PRINTER_IDLE)
                                {
                                  if(gcode.startsWith("M23") || gcode.startsWith("M24"))
                                   {
                                    gPrinterInf.print_state = PRINTER_PRINTING;
                                    gPrinterInf.print_file_inf.file_name = "";
                                    gPrinterInf.print_file_inf.file_size = 0;
                                    gPrinterInf.print_file_inf.print_rate = 0;
                                    gPrinterInf.print_file_inf.print_hours = 0;
                                    gPrinterInf.print_file_inf.print_mins = 0;
                                    gPrinterInf.print_file_inf.print_seconds = 0;
                
                                    printFinishFlag = false;
                                   }
                                }
                                gcodeM3.concat(gcode);
                
                              }
                
                            }
                          }
                

                Your effort and dedication make it a pleasure to support you. Let me know how I can continue to help you achieve your goals!

                Bye Renzo

                • #31659
                  Victor
                  Participant

                    Now I have been able to compile it,
                    the file elimination now works

                    however still I cannot understand

                    – what could cause the annoying crash at the end of print. I have seen that another user had this problem and it has solved using another firmware version not sure if printer firmware or wifi firmware
                    – why the stop print doesn’t work despite the command matches the reprap one.
                    . why print from subfolders doesn’t work

                    Thank you again. I really appreciate your work, this interface is an awesome addition to any 3D printer.

                • #31681
                  Renzo Mischianti
                  Keymaster

                    Mmmm…
                    the Gcode output isn’t managed; the commands on documentation are wrapped from MKS WiFi firmware and do the work, not the printer board, and I don’t know as Marilin works.
                    Bye Renzo

                  • #31798
                    schnurly
                    Participant

                      I’m using Marlin 2.1.2.4 with an MKS TFT display and noticed that, just like in version 1.6, the file deletion function isn’t working. I also tried the experimental version, but it ended up breaking everything.
                      P.S. Thanks for the great work!

                  Viewing 5 reply threads
                  • You must be logged in to reply to this topic.
                  Exit mobile version