diff --git a/Configuration.h b/Configuration.h index 4ceaeda..2eb1c2e 100644 --- a/Configuration.h +++ b/Configuration.h @@ -49,6 +49,10 @@ // Splash screen display delay in milliseconds. #define SPLASH_SCREEN_DELAY 7000 +#define OUTPUT_GCODE_TO 2 + +#define PERCENTAGE_TIME_CALCULATION_ENABLED true + #define FORWARD_REWIND_COUNT 5 // SD Chip Select Pin diff --git a/Documentation/Configuration.md b/Documentation/Configuration.md index 15382cd..df1db06 100644 --- a/Documentation/Configuration.md +++ b/Documentation/Configuration.md @@ -107,6 +107,12 @@ The ```FORWARD_REWIND_COUNT``` directive set the number of file jumped forward o ## SD_CS The ```SPLASH_SCREEN_DELAY``` directive sets the SD card chip select pin. The default setting is 4. +## OUTPUT_GCODE_TO +The ```OUTPUT_GCODE_TO``` directive defines where processed g-code is output. This setting determines if g-code is to be output to only the display, only the serial port, both or neither. This directive is only relavant for with the touchscreen/SD configuration running in SD mode. In classic mode processed g-code is always sent to the serial port. The option is useful for increasing print speed and debugging. When set to the default, display only it provides a visual g-code being processed. However, display calls have a high processor utilization which reduces the print speed. When set to serial only or both g-code is output to the serial port which can be monitored. This can be useful when debugging, but also results in a high processor utilization. When set to neither g-code is not displayed or sent to the serial port resulting in increased printing speed. The following numerical settings should be used (0-Neither, 1-Serial Only, 2-Display Only, 3-Both). The default setting is Display Only (2). + +## PERCENTAGE_TIME_CALCULATION_ENABLED +The ```PERCENTAGE_TIME_CALCULATION_ENABLED``` directive sets the default setting of the percentage completed and time remaining calculation. This setting determines if the percentage completed and time remaining calculation is executed and displayed on the screen when printing. The option to turn off the calculation is available to increase print speed and reduce print time. This directive is only relavant for with the touchscreen/SD configuration. The default setting is true. + ## PIEZO_PIN The ```PIEZO_PIN``` directive sets the piezo buzzer pin. To deactivate the buzzer set the value to -1. The default setting is 3. diff --git a/Documentation/G-Code.md b/Documentation/G-Code.md index bbcfcea..a0f04fc 100644 --- a/Documentation/G-Code.md +++ b/Documentation/G-Code.md @@ -103,6 +103,11 @@ The M311 command allows you to override the pen movement feed rates set in your ### M312 The M312 command sets the pen up federate multiplier. This command allows the SphereBot to move off the object at a faster rate. One means the pen will go up at the same speed (degrees/second) as it goes down. Each increase by one will logarithmically double the pen up speed. +### M990 +Sets the g-code output device print device. When set to Neither (P0) output of the g-code is disable, except in classic mode which always outputs g-code to the serial port. When set to Serial Only (P1) g-code is output to just the serial port. This can be useful when debugging, but results in a high processor utilization. When set to Display Only (P2) g-code is output to just the display. This also results in a high processor utilization. When set to Both (P3) g-code is output to both the serial port and the display. This directive is only relavant for with the touchscreen/SD configuration running in SD mode. + +### M991 + Disable/Enable percentage completed and time remaining calculation. The ability to disable the percentage completed and time remaining calculation is provided to increase speed by reducing processor calculations during printing. When set to disabled (P0) the calculation is disabled. When set to enabled (P1) the calculation is enabled and displayed. This command is only relavant for with the touchscreen/SD configuration. ### Using M3xx commands. Using a file to preset the M301 through M312 values and saving the configuration with the M500 command provides a great deal of versatility. diff --git a/Documentation/Inkscape.md b/Documentation/Inkscape.md index 40c11b4..953507f 100644 --- a/Documentation/Inkscape.md +++ b/Documentation/Inkscape.md @@ -4,7 +4,7 @@ The following is a tutorial outlining the steps of converting a SphereBot SVG template (3200x800) into gcode using InkScape v1.x. The tutorial also discusses some of the challenges and solutions provided with some of the newer Mxxx commands of moving gcode between different SphereBots. ## Template -*To Be Completed in the a future release.* +*To be completed in the a future release.* ## Steps to Generate G-Code 1. Open your SVG (Scalable Vector Graphics) file in InkScape. @@ -53,16 +53,16 @@ The following is a tutorial outlining the steps of converting a SphereBot SVG te You now have a g-code file you can run on your SphereBot. Note that in the future you will not need to confirming all of the settings for the GCodetools ```Tools library```, ```Orientation points``` and ```Path to Gcode``` as they will remain the same as the last time they were used. -*To Be Completed in the a future release.* +*To be completed in the a future release.* ## Modifying Your G-Code File with Comments -*To Be Completed in the a future release.* +*To be completed in the a future release.* ## Adding M00 Pen Change Commands -*To Be Completed in the a future release.* +*To be completed in the a future release.* ## Newer Mxxx Commands -*To Be Completed in the a future release.* +*To be completed in the a future release.* ## Document History diff --git a/README.md b/README.md index 58cdb3e..7752d01 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,16 @@ Arduino Firmware for use with the Adafruit Motor/Stepper/Servo Shield for Arduin This fork takes on a large number of changes including consistent naming conventions, an advanced G-Code parser, additional custom G-Code commands, a touchscreen control, SD card reader support and audio alerts. Many of these features are being actively developed. Additional documentation can be found in the documentation folder along with comments in both the SphereBot.ino and configuration.h files. -This code relaese works with the original hardware configuration (Arduino & motor control shield) where g-code files are send to the SphereBot from a PC through a USB cable or you can add a touchscreen shield which allows you to operate in either the original mode cabled to a PC supplying the g-code file or in fully autonomous mode using g-code files stored on the SD card. +This code release works with the original hardware configuration (Arduino & motor control shield) where g-code files are send to the SphereBot from a PC through a USB cable or you can add a touchscreen shield which allows you to operate in either the original mode cabled to a PC supplying the g-code file or in fully autonomous mode using g-code files stored on the SD card. Also addressed is a MAJOR bug fix in the arc drawing function. Previous code used the current x,y location stored in the stepper motor control code which was rounded to it's integer value while g-code values are represented with 6 decimal places (doubles). At times this would cause the start angle of the arc to be greater than ending angle, which resulted in the drawing of a full circle and not a partial arc. -The version 1.9.2 prerelease is missing the follow features. +The version 1.9.3 prerelease is missing the follow features. - Version 2.0 release setup notes/documentation. - A completed comprehensive mechanical assembly document. - InkScape documentation stepping through creating gcode with the gcodetools along with using some of new the advanced Mxxx commands. - An alphabetical menu search. -- Commands codes to turn off serial output, display output and percent/time calculations (speed inprovements). ### Forking (Please Don't) diff --git a/SD/gcode/snowflakes.ngc b/SD/gcode/snowflakeband.ngc similarity index 100% rename from SD/gcode/snowflakes.ngc rename to SD/gcode/snowflakeband.ngc diff --git a/SD/gcode/~Inkscape (Universal).gcode b/SD/gcode/~Inkscape (Universal).gcode index 732b476..5d3e7f2 100644 --- a/SD/gcode/~Inkscape (Universal).gcode +++ b/SD/gcode/~Inkscape (Universal).gcode @@ -22,6 +22,8 @@ M309 P5 ;M309 Pxxx - Z Adjust Preset Threshold: 5 Z Adjust Calculated: -1 M310 P500.00 ;M310 Pxxx - Preset XY Feedrate : 500.00 M311 P60.00 ;M311 Pxxx - Preset Pen Feedrate: 60.00 M312 P2 ;M312 Pxxx - Pen Up Feedrate Multiplier: 2 +M990 P2 ;M990 Px - Output G-Code To: (0-Neither, 1-Serial Only, 2-Display Only, 3-Both): 2 +M991 P1 ;M991 Pxxx - Percentage Time Calculation (0-Disabled, 1-Enabled): 1 M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM (23): 23 M999 % \ No newline at end of file diff --git a/SD/gcode/~M990BothSerialDiaplay b/SD/gcode/~M990BothSerialDiaplay new file mode 100644 index 0000000..00bb3f0 --- /dev/null +++ b/SD/gcode/~M990BothSerialDiaplay @@ -0,0 +1,10 @@ +% +;Output G-Code Both +; +;Output g-code to both the serial port +;or display. +; +M990 P3 +M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM (23): 23 +M999 +% \ No newline at end of file diff --git a/SD/gcode/~M990NeitherSerialDisplay b/SD/gcode/~M990NeitherSerialDisplay new file mode 100644 index 0000000..ecf13d8 --- /dev/null +++ b/SD/gcode/~M990NeitherSerialDisplay @@ -0,0 +1,10 @@ +% +;Output G-Code Neither +; +;Output g-code to neither the serial port +;or display. +; +M990 P0 +M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM (23): 23 +M999 +% \ No newline at end of file diff --git a/SD/gcode/~M990OnlyDisplay b/SD/gcode/~M990OnlyDisplay new file mode 100644 index 0000000..a33756f --- /dev/null +++ b/SD/gcode/~M990OnlyDisplay @@ -0,0 +1,9 @@ +% +;Output G-Code Display +; +;Output g-code to only the display. +; +M990 P2 +M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM (23): 23 +M999 +% \ No newline at end of file diff --git a/SD/gcode/~M990OnlySerial b/SD/gcode/~M990OnlySerial new file mode 100644 index 0000000..d457c17 --- /dev/null +++ b/SD/gcode/~M990OnlySerial @@ -0,0 +1,9 @@ +% +;Output G-Code Serial +; +;Output g-code to only the serial port. +; +M990 P1 +M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM (23): 23 +M999 +% \ No newline at end of file diff --git a/SD/gcode/~M991DisablePercentageTimeCalculation.gcode b/SD/gcode/~M991DisablePercentageTimeCalculation.gcode new file mode 100644 index 0000000..14d99d4 --- /dev/null +++ b/SD/gcode/~M991DisablePercentageTimeCalculation.gcode @@ -0,0 +1,13 @@ +% +;Disable Percentage/Time +;Calculation +; +;Disables the percentage completed and time +;remaining calculation. This option removes +;the calculations inorder to increase the +;printing time. +; +M991 P0 +M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM (23): 23 +M999 +% \ No newline at end of file diff --git a/SD/gcode/~M991EnablePercentageTimeCalculation b/SD/gcode/~M991EnablePercentageTimeCalculation new file mode 100644 index 0000000..8834113 --- /dev/null +++ b/SD/gcode/~M991EnablePercentageTimeCalculation @@ -0,0 +1,14 @@ +% +;Enable Percentage/Time +;Calculation +; +;Enables the percentage completed and time +;remaining calculation. This option allows +;for the calculations inorder to display the +;percentage completed and time remaining. +;(45% 3:45) +; +M991 P1 +M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM (23): 23 +M999 +% \ No newline at end of file diff --git a/SerialDisplayPrint.cpp b/SerialDisplayPrint.cpp index 3381bf5..b5eca08 100644 --- a/SerialDisplayPrint.cpp +++ b/SerialDisplayPrint.cpp @@ -194,13 +194,3 @@ void SerialDisplayPrint::println(char *data, PrintDevice device) if (device == Both || device == SerialOnly) Serial->println(data); } - -void SerialDisplayPrint::println(PrintDevice device) -{ -#if ADAFRUIT_TFT_TOUCH_SHIELD - if (device == Both || device == DisplayOnly) - AdvanceToNextLineOnDisplay(); -#endif - if (device == Both || device == SerialOnly) - Serial->println(); -} diff --git a/SerialDisplayPrint.h b/SerialDisplayPrint.h index 824e90b..b427280 100644 --- a/SerialDisplayPrint.h +++ b/SerialDisplayPrint.h @@ -17,7 +17,7 @@ Released into the public domain. class SerialDisplayPrint { public: - enum PrintDevice { Both, SerialOnly, DisplayOnly }; + enum PrintDevice { Neither, SerialOnly, DisplayOnly, Both }; SerialDisplayPrint(); void begin(HardwareSerial &serial); @@ -26,19 +26,18 @@ class SerialDisplayPrint #endif void SetTextSize(int textSize); void SetTextDisplay(); - void print(byte data, PrintDevice device = Both); - void print(short data, PrintDevice device = Both); - void print(int data, PrintDevice device = Both); - void print(unsigned long data, PrintDevice device = Both); - void print(double data, PrintDevice device = Both); - void print(char *data, PrintDevice device = Both); - void println(byte data, PrintDevice device = Both); - void println(short data, PrintDevice device = Both); - void println(int data, PrintDevice device = Both); - void println(unsigned long data, PrintDevice device = Both); - void println(double data, PrintDevice device = Both); - void println(char *data, PrintDevice device = Both); - void println(PrintDevice device = Both); + void print(byte data, PrintDevice device); + void print(short data, PrintDevice device); + void print(int data, PrintDevice device); + void print(unsigned long data, PrintDevice device); + void print(double data, PrintDevice device); + void print(char *data, PrintDevice device); + void println(byte data, PrintDevice device); + void println(short data, PrintDevice device); + void println(int data, PrintDevice device); + void println(unsigned long data, PrintDevice device); + void println(double data, PrintDevice device); + void println(char *data, PrintDevice device); private: HardwareSerial *Serial; diff --git a/SphereBot.ino b/SphereBot.ino index 2b5401e..0c431b1 100644 --- a/SphereBot.ino +++ b/SphereBot.ino @@ -70,6 +70,12 @@ by Terence Golla (tgolla). M312 - Sets the pen up feedrate multiplier. One means the pen will go up at the same speed (degrees/second) as it goes down. Each increase by one will logarithmically double the pen up speed. + M990 - Sets the g-code output device. + P0 - Neither, P1 - Serial Only, P2 - Display Only, P3 - Both + This command is only relavant for with the touchscreen/SD configuration. + M991 - Disable/Enable percentage completed and time remaining calculation. + P0 - Disabled, P1 - Enabled + This command is only relavant for with the touchscreen/SD configuration. M999 - Display Mxxx command values. Note: To add define the M999 directive true in configuration.h. This directive was add as a safety measure for development as the code is memory intensive with respect to both sketch @@ -181,36 +187,43 @@ double penFeedrate; double presetXyFeedrate; double presetPenFeedrate; short penUpFeedrateMultiplier; +byte outputGcodeTo; +bool percentageTimeCalculationEnabled; +SerialDisplayPrint::PrintDevice outputGcodeToPrintDevice; // EEPROM memory locations. byte valueSavedEEPROMMemoryLocation = SAVED_EEPROM_BASE_MEMORY_LOCATION; byte minPenEEPROMMemoryLocation = 1; byte maxPenEEPROMMemoryLocation = - minPenEEPROMMemoryLocation + EEPROMTyped.sizeOf(minPenPosition); + minPenEEPROMMemoryLocation + EEPROMTyped.sizeOf(minPenPosition); byte penUpEEPROMMemoryLocation = - maxPenEEPROMMemoryLocation + EEPROMTyped.sizeOf(maxPenPosition); + maxPenEEPROMMemoryLocation + EEPROMTyped.sizeOf(maxPenPosition); byte penDownEEPROMMemoryLocation = - penUpEEPROMMemoryLocation + EEPROMTyped.sizeOf(penUpPosition); + penUpEEPROMMemoryLocation + EEPROMTyped.sizeOf(penUpPosition); byte mzModeEEPROMMemoryLocation = - penDownEEPROMMemoryLocation + EEPROMTyped.sizeOf(penDownPosition); + penDownEEPROMMemoryLocation + EEPROMTyped.sizeOf(penDownPosition); byte mAdjustEEPROMMemoryLocation = - mzModeEEPROMMemoryLocation + EEPROMTyped.sizeOf(mzMode); + mzModeEEPROMMemoryLocation + EEPROMTyped.sizeOf(mzMode); byte zAdjustEEPROMMemoryLocation = - mAdjustEEPROMMemoryLocation + EEPROMTyped.sizeOf(mAdjust); + mAdjustEEPROMMemoryLocation + EEPROMTyped.sizeOf(mAdjust); byte mAdjustPresetEEPROMMemoryLocation = - zAdjustEEPROMMemoryLocation + EEPROMTyped.sizeOf(zAdjust); + zAdjustEEPROMMemoryLocation + EEPROMTyped.sizeOf(zAdjust); byte zAdjustPresetEEPROMMemoryLocation = - mAdjustPresetEEPROMMemoryLocation + EEPROMTyped.sizeOf(mAdjustPreset); + mAdjustPresetEEPROMMemoryLocation + EEPROMTyped.sizeOf(mAdjustPreset); byte xyFeedrateEEPROMMemoryLocation = - zAdjustPresetEEPROMMemoryLocation + EEPROMTyped.sizeOf(zAdjustPreset); + zAdjustPresetEEPROMMemoryLocation + EEPROMTyped.sizeOf(zAdjustPreset); byte penFeedrateEEPROMMemoryLocation = - xyFeedrateEEPROMMemoryLocation + EEPROMTyped.sizeOf(xyFeedrate); + xyFeedrateEEPROMMemoryLocation + EEPROMTyped.sizeOf(xyFeedrate); byte presetXyFeedrateEEPROMMemoryLocation = - penFeedrateEEPROMMemoryLocation + EEPROMTyped.sizeOf(penFeedrate); + penFeedrateEEPROMMemoryLocation + EEPROMTyped.sizeOf(penFeedrate); byte presetPenFeedrateEEPROMMemoryLocation = - presetXyFeedrateEEPROMMemoryLocation + EEPROMTyped.sizeOf(presetXyFeedrate); + presetXyFeedrateEEPROMMemoryLocation + EEPROMTyped.sizeOf(presetXyFeedrate); byte penUpFeedrateMultiplierEEPROMMemoryLocation = - presetPenFeedrateEEPROMMemoryLocation + EEPROMTyped.sizeOf(presetPenFeedrate); + presetPenFeedrateEEPROMMemoryLocation + EEPROMTyped.sizeOf(presetPenFeedrate); +byte outputGcodeToEEPROMMemoryLocation = + penUpFeedrateMultiplierEEPROMMemoryLocation + EEPROMTyped.sizeOf(penUpFeedrateMultiplier); +byte percentageTimeCalculationEnabledEEPROMMemoryLocation = + outputGcodeToEEPROMMemoryLocation + EEPROMTyped.sizeOf(outputGcodeTo); // Number expected to be found in EEPROM memory location 0 that indicates // pen setting have been stored in memory. @@ -324,7 +337,7 @@ void setup() tft.print("An EggBot Clone"); tft.setCursor(10, 10 + (8 * 5) + 2 + (8 * 2) + 4); tft.setTextSize(1); - tft.print("v1.9.2"); + tft.print("v1.9.3"); delay(SPLASH_SCREEN_DELAY); tft.fillScreen(ILI9341_WHITE); @@ -356,10 +369,11 @@ void setup() if (serialMode) { + loadPenConfiguration(); // Adjust for serial mode. #if ADAFRUIT_TFT_TOUCH_SHIELD SerialDisplay.SetTextDisplay(); #endif - SerialDisplay.println("Ready"); + SerialDisplay.println("Ready", SerialDisplay.SerialOnly); delay(100); } @@ -513,12 +527,16 @@ void loop() char *gCodeFilenamePath = createFilenamePath(filename, "/gcode", ""); - SerialDisplay.print("Calculating total number of lines: ", SerialDisplay.DisplayOnly); - unsigned long totalLines = calculatefileTotalLineCount(gCodeFilenamePath); - SerialDisplay.println(totalLines, SerialDisplay.DisplayOnly); - double currentLine = 0; int previousPercentage = 0; + unsigned long totalLines; + + if (percentageTimeCalculationEnabled) + { + SerialDisplay.print("Calculating total number of lines: ", SerialDisplay.DisplayOnly); + totalLines = calculatefileTotalLineCount(gCodeFilenamePath); + SerialDisplay.println(totalLines, SerialDisplay.DisplayOnly); + } GCode.Initialize(); @@ -534,28 +552,31 @@ void loop() GCode.ParseLine(); processCommand(); - currentLine = currentLine + 1; - int percentage = (currentLine / totalLines) * 100; - - // Display percentage done and estimated time remaining (MM:SS). - if (percentage > previousPercentage) + if (percentageTimeCalculationEnabled) { - unsigned long timePassed = millis() - startTime; - unsigned long secondsPassed = timePassed/1000; - unsigned long secondsRemaining = (secondsPassed / percentage) * (100 - percentage); - - SerialDisplay.print("(", SerialDisplay.DisplayOnly); - SerialDisplay.print(percentage, SerialDisplay.DisplayOnly); - SerialDisplay.print("% ", SerialDisplay.DisplayOnly); - SerialDisplay.print(secondsRemaining / 60, SerialDisplay.DisplayOnly); - SerialDisplay.print(":", SerialDisplay.DisplayOnly); - secondsRemaining = secondsRemaining % 60; - if (secondsRemaining < 10) - SerialDisplay.print("0", SerialDisplay.DisplayOnly); - SerialDisplay.print(secondsRemaining, SerialDisplay.DisplayOnly); - SerialDisplay.println(")", SerialDisplay.DisplayOnly); - - previousPercentage = percentage; + currentLine = currentLine + 1; + int percentage = (currentLine / totalLines) * 100; + + // Display percentage done and estimated time remaining (MM:SS). + if (percentage > previousPercentage) + { + unsigned long timePassed = millis() - startTime; + unsigned long secondsPassed = timePassed/1000; + unsigned long secondsRemaining = (secondsPassed / percentage) * (100 - percentage); + + SerialDisplay.print("(", SerialDisplay.DisplayOnly); + SerialDisplay.print(percentage, SerialDisplay.DisplayOnly); + SerialDisplay.print("% ", SerialDisplay.DisplayOnly); + SerialDisplay.print(secondsRemaining / 60, SerialDisplay.DisplayOnly); + SerialDisplay.print(":", SerialDisplay.DisplayOnly); + secondsRemaining = secondsRemaining % 60; + if (secondsRemaining < 10) + SerialDisplay.print("0", SerialDisplay.DisplayOnly); + SerialDisplay.print(secondsRemaining, SerialDisplay.DisplayOnly); + SerialDisplay.println(")", SerialDisplay.DisplayOnly); + + previousPercentage = percentage; + } } } } @@ -676,14 +697,14 @@ void displayFileInfo(char *filename) } SerialDisplay.SetTextSize(1); - SerialDisplay.println(SerialDisplay.DisplayOnly); + SerialDisplay.println("", SerialDisplay.DisplayOnly); SerialDisplay.println(filename, SerialDisplay.DisplayOnly); } } void touchScreenToContinue(char* message) { - SerialDisplay.println(SerialDisplay.DisplayOnly); + SerialDisplay.println("", SerialDisplay.DisplayOnly); if (message != NULL) SerialDisplay.println(message, SerialDisplay.DisplayOnly); SerialDisplay.println("Touch screen to continue...", SerialDisplay.DisplayOnly); @@ -774,6 +795,8 @@ void loadPenConfiguration() EEPROMTyped.read(presetXyFeedrateEEPROMMemoryLocation, presetXyFeedrate); EEPROMTyped.read(presetPenFeedrateEEPROMMemoryLocation, presetPenFeedrate); EEPROMTyped.read(penUpFeedrateMultiplierEEPROMMemoryLocation, penUpFeedrateMultiplier); + EEPROMTyped.read(outputGcodeToEEPROMMemoryLocation, outputGcodeTo); + EEPROMTyped.read(percentageTimeCalculationEnabledEEPROMMemoryLocation, percentageTimeCalculationEnabled); } else { @@ -791,6 +814,8 @@ void loadPenConfiguration() presetXyFeedrate = DEFAULT_PRESET_XY_FEEDRATE; presetPenFeedrate = DEFAULT_PRESET_PEN_FEEDRATE; penUpFeedrateMultiplier = DEFAULT_PEN_UP_FEEDRATE_MULTIPLIER; + outputGcodeTo = OUTPUT_GCODE_TO; + percentageTimeCalculationEnabled = PERCENTAGE_TIME_CALCULATION_ENABLED; } // Used to determine the MZ mode when set to Auto. @@ -805,6 +830,19 @@ void loadPenConfiguration() xyFeedrate = presetXyFeedrate; if (presetPenFeedrate > 0) penFeedrate = presetPenFeedrate; + +#if ADAFRUIT_TFT_TOUCH_SHIELD + outputGcodeToPrintDevice = static_cast(outputGcodeTo); + if (serialMode) + { + if (outputGcodeTo = SerialDisplay.Neither) + outputGcodeToPrintDevice= SerialDisplay.SerialOnly; + if (outputGcodeTo = SerialDisplay.DisplayOnly) + outputGcodeToPrintDevice= SerialDisplay.Both; + } +#else + outputGcodeToPrintDevice = SerialDisplay.SerialOnly; +#endif } // Saves the pen configuration to memeoy. @@ -824,6 +862,8 @@ void savePenConfiguration() EEPROMTyped.write(presetXyFeedrateEEPROMMemoryLocation, presetXyFeedrate); EEPROMTyped.write(presetPenFeedrateEEPROMMemoryLocation, presetPenFeedrate); EEPROMTyped.write(penUpFeedrateMultiplierEEPROMMemoryLocation, penUpFeedrateMultiplier); + EEPROMTyped.write(outputGcodeToEEPROMMemoryLocation, outputGcodeTo); + EEPROMTyped.write(percentageTimeCalculationEnabledEEPROMMemoryLocation, percentageTimeCalculationEnabled); EEPROMTyped.write(valueSavedEEPROMMemoryLocation, EEPROM_MAGIC_NUMBER); } @@ -1296,108 +1336,147 @@ void processCommand(bool noSerialResponse) clearPenConfiguration(); break; + // M990 - Sets the g-code output device. + // P0 - Neither, P1 - Serial Only, P2 - Display Only, P3 - Both + // This command is only relavant for with the touchscreen/SD configuration. + case 990: + if (GCode.HasWord('P')) + { + if (GCode.GetWordValue('P') >= SerialDisplay.Neither && GCode.GetWordValue('P') <= SerialDisplay.Both ) + { + outputGcodeTo = GCode.GetWordValue('P'); + outputGcodeToPrintDevice= static_cast(outputGcodeTo); + } + } + break; + + // M991 - Disable/Enable percentage completed and time remaining calculation. + // P0 - Disabled, P1 - Enabled + // This command is only relavant for with the touchscreen/SD configuration. + case 991: + if (GCode.HasWord('P')) + { + if (GCode.GetWordValue('P') > 0) + percentageTimeCalculationEnabled = true; + else + percentageTimeCalculationEnabled = false; + } + break; + #if M999 == true case 999: // M999 - Display Mxxx command values. - SerialDisplay.println(); - SerialDisplay.print("M301 P"); - SerialDisplay.print(minPenPosition); - SerialDisplay.print(" ;M301 Pxxx - Minimun Pen Position: "); - SerialDisplay.println(minPenPosition); - - SerialDisplay.print("M302 P"); - SerialDisplay.print(maxPenPosition); - SerialDisplay.print(" ;M302 Pxxx - Maximun Pen Position: "); - SerialDisplay.println(maxPenPosition); - - SerialDisplay.print("M303 P"); - SerialDisplay.print(penUpPosition); - SerialDisplay.print(" ;M303 Pxxx - Pen Up Position: "); - SerialDisplay.println(penUpPosition); - - SerialDisplay.print("M304 P"); - SerialDisplay.print(penDownPosition); - SerialDisplay.print(" ;M304 Pxxx - Pen Down Position: "); - SerialDisplay.println(penDownPosition); - - SerialDisplay.print("M305 P"); - SerialDisplay.print(mzMode); - SerialDisplay.print(" ;M305 Px - MZ Mode (0-M, 1-Z, 2-Auto): "); - SerialDisplay.print(mzMode); - SerialDisplay.print(" MZ Active Mode: "); - SerialDisplay.println(mzActiveMode); - - SerialDisplay.print("M306 P"); - SerialDisplay.print(mAdjust); - SerialDisplay.print(" ;M306 Px - M Adjust (0-Off, 1-Preset, 2-Calculated): "); - SerialDisplay.println(mAdjust); - - SerialDisplay.print("M307 P"); - SerialDisplay.print(zAdjust); - SerialDisplay.print(" ;M307 Px - Z Adjust: (0-Off, 1-Preset, 2-Calculated): "); - SerialDisplay.println(zAdjust); - - SerialDisplay.print("M308 P"); - SerialDisplay.print(mAdjustPreset); - SerialDisplay.print(" ;M308 Pxxx - M Adjust Preset Threshold: "); - SerialDisplay.print(mAdjustPreset); - SerialDisplay.print(" M Adjust Calculated: "); - SerialDisplay.println(mAdjustCalculated); - - SerialDisplay.print("M309 P"); - SerialDisplay.print(zAdjustPreset); - SerialDisplay.print(" ;M309 Pxxx - Z Adjust Preset Threshold: "); - SerialDisplay.print(zAdjustPreset); - SerialDisplay.print(" Z Adjust Calculated: "); - SerialDisplay.println(zAdjustCalculated); - - SerialDisplay.print("G1 X0 Y0 F"); - SerialDisplay.print(xyFeedrate); - SerialDisplay.print(" ;Gx Xxxx Yxxx Fxxx - XY Feedrate: "); - SerialDisplay.println(xyFeedrate); + SerialDisplay.println("", outputGcodeToPrintDevice); + SerialDisplay.println("M17 ;Enable stepper motors.", outputGcodeToPrintDevice); + SerialDisplay.println("M18 ;Disable stepper motors.", outputGcodeToPrintDevice); + SerialDisplay.println("M300 S145 ;Set pen up.", outputGcodeToPrintDevice); + + SerialDisplay.print("M301 P", outputGcodeToPrintDevice); + SerialDisplay.print(minPenPosition, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M301 Pxxx - Minimun Pen Position: ", outputGcodeToPrintDevice); + SerialDisplay.println(minPenPosition, outputGcodeToPrintDevice); + + SerialDisplay.print("M302 P", outputGcodeToPrintDevice); + SerialDisplay.print(maxPenPosition, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M302 Pxxx - Maximun Pen Position: ", outputGcodeToPrintDevice); + SerialDisplay.println(maxPenPosition, outputGcodeToPrintDevice); + + SerialDisplay.print("M303 P", outputGcodeToPrintDevice); + SerialDisplay.print(penUpPosition, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M303 Pxxx - Pen Up Position: ", outputGcodeToPrintDevice); + SerialDisplay.println(penUpPosition, outputGcodeToPrintDevice); + + SerialDisplay.print("M304 P", outputGcodeToPrintDevice); + SerialDisplay.print(penDownPosition, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M304 Pxxx - Pen Down Position: ", outputGcodeToPrintDevice); + SerialDisplay.println(penDownPosition, outputGcodeToPrintDevice); + + SerialDisplay.print("M305 P", outputGcodeToPrintDevice); + SerialDisplay.print(mzMode, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M305 Px - MZ Mode (0-M, 1-Z, 2-Auto): ", outputGcodeToPrintDevice); + SerialDisplay.print(mzMode, outputGcodeToPrintDevice); + SerialDisplay.print(" MZ Active Mode: ", outputGcodeToPrintDevice); + SerialDisplay.println(mzActiveMode, outputGcodeToPrintDevice); + + SerialDisplay.print("M306 P", outputGcodeToPrintDevice); + SerialDisplay.print(mAdjust, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M306 Px - M Adjust (0-Off, 1-Preset, 2-Calculated): ", outputGcodeToPrintDevice); + SerialDisplay.println(mAdjust, outputGcodeToPrintDevice); + + SerialDisplay.print("M307 P", outputGcodeToPrintDevice); + SerialDisplay.print(zAdjust, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M307 Px - Z Adjust: (0-Off, 1-Preset, 2-Calculated): ", outputGcodeToPrintDevice); + SerialDisplay.println(zAdjust, outputGcodeToPrintDevice); + + SerialDisplay.print("M308 P", outputGcodeToPrintDevice); + SerialDisplay.print(mAdjustPreset, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M308 Pxxx - M Adjust Preset Threshold: ", outputGcodeToPrintDevice); + SerialDisplay.print(mAdjustPreset, outputGcodeToPrintDevice); + SerialDisplay.print(" M Adjust Calculated: ", outputGcodeToPrintDevice); + SerialDisplay.println(mAdjustCalculated, outputGcodeToPrintDevice); + + SerialDisplay.print("M309 P", outputGcodeToPrintDevice); + SerialDisplay.print(zAdjustPreset, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M309 Pxxx - Z Adjust Preset Threshold: ", outputGcodeToPrintDevice); + SerialDisplay.print(zAdjustPreset, outputGcodeToPrintDevice); + SerialDisplay.print(" Z Adjust Calculated: ", outputGcodeToPrintDevice); + SerialDisplay.println(zAdjustCalculated, outputGcodeToPrintDevice); + + SerialDisplay.print("G1 X0 Y0 F", outputGcodeToPrintDevice); + SerialDisplay.print(xyFeedrate, outputGcodeToPrintDevice); + SerialDisplay.print(" ;Gx Xxxx Yxxx Fxxx - XY Feedrate: ", outputGcodeToPrintDevice); + SerialDisplay.println(xyFeedrate, outputGcodeToPrintDevice); if (mzActiveMode == M) { - SerialDisplay.print("M300 S"); - SerialDisplay.print(penUpPosition); - SerialDisplay.print(" F"); + SerialDisplay.print("M300 S", outputGcodeToPrintDevice); + SerialDisplay.print(penUpPosition, outputGcodeToPrintDevice); + SerialDisplay.print(" F", outputGcodeToPrintDevice); } else { - SerialDisplay.print("G1 Z"); - SerialDisplay.print(penUpPosition); - SerialDisplay.print(" F"); + SerialDisplay.print("G1 Z", outputGcodeToPrintDevice); + SerialDisplay.print(penUpPosition, outputGcodeToPrintDevice); + SerialDisplay.print(" F", outputGcodeToPrintDevice); } - SerialDisplay.print(penFeedrate); - SerialDisplay.print(" ;M300 Sxxx Fxxx or Gx Zxxx Fxxx - Pen Feedrate: "); - SerialDisplay.println(penFeedrate); - - SerialDisplay.print("M310 P"); - SerialDisplay.print(presetXyFeedrate); - SerialDisplay.print(" ;M310 Pxxx - Preset XY Feedrate : "); - SerialDisplay.println(presetXyFeedrate); - - SerialDisplay.print("M311 P"); - SerialDisplay.print(presetPenFeedrate); - SerialDisplay.print(" ;M311 Pxxx - Preset Pen Feedrate: "); - SerialDisplay.println(presetPenFeedrate); - - SerialDisplay.print("M312 P"); - SerialDisplay.print(penUpFeedrateMultiplier); - SerialDisplay.print(" ;M312 Pxxx - Pen Up Feedrate Multiplier: "); - SerialDisplay.println(penUpFeedrateMultiplier); - - SerialDisplay.print("M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM ("); - SerialDisplay.print(EEPROM_MAGIC_NUMBER); - SerialDisplay.print("): "); - SerialDisplay.println(EEPROM.read(valueSavedEEPROMMemoryLocation)); - - SerialDisplay.println("M501 ;Load pen configuration from EEPROM (or defaults if cleared)."); - SerialDisplay.println("M502 ;Clear pen configuration from EEPROM."); - SerialDisplay.println("M18 ;Disable stepper motors."); - SerialDisplay.println("M17 ;Enable stepper motors."); - - SerialDisplay.println(); + SerialDisplay.print(penFeedrate, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M300 Sxxx Fxxx or Gx Zxxx Fxxx - Pen Feedrate: ", outputGcodeToPrintDevice); + SerialDisplay.println(penFeedrate, outputGcodeToPrintDevice); + + SerialDisplay.print("M310 P", outputGcodeToPrintDevice); + SerialDisplay.print(presetXyFeedrate, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M310 Pxxx - Preset XY Feedrate : ", outputGcodeToPrintDevice); + SerialDisplay.println(presetXyFeedrate, outputGcodeToPrintDevice); + + SerialDisplay.print("M311 P", outputGcodeToPrintDevice); + SerialDisplay.print(presetPenFeedrate, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M311 Pxxx - Preset Pen Feedrate: ", outputGcodeToPrintDevice); + SerialDisplay.println(presetPenFeedrate, outputGcodeToPrintDevice); + + SerialDisplay.print("M312 P", outputGcodeToPrintDevice); + SerialDisplay.print(penUpFeedrateMultiplier, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M312 Pxxx - Pen Up Feedrate Multiplier: ", outputGcodeToPrintDevice); + SerialDisplay.println(penUpFeedrateMultiplier, outputGcodeToPrintDevice); + + SerialDisplay.print("M500 ;Save pen configuration to EEPROM. Values Saved in EEPROM (", outputGcodeToPrintDevice); + SerialDisplay.print(EEPROM_MAGIC_NUMBER, outputGcodeToPrintDevice); + SerialDisplay.print("): ", outputGcodeToPrintDevice); + SerialDisplay.println(EEPROM.read(valueSavedEEPROMMemoryLocation), outputGcodeToPrintDevice); + + SerialDisplay.println("M501 ;Load pen configuration from EEPROM (or defaults if cleared).", outputGcodeToPrintDevice); + SerialDisplay.println("M502 ;Clear pen configuration from EEPROM.", outputGcodeToPrintDevice); + + SerialDisplay.print("M990 P", outputGcodeToPrintDevice); + SerialDisplay.print(outputGcodeTo, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M990 Px - Output G-Code To: (0-Neither, 1-Serial Only, 2-Display Only, 3-Both): ", outputGcodeToPrintDevice); + SerialDisplay.println(outputGcodeTo, outputGcodeToPrintDevice); + + SerialDisplay.print("M991 P", outputGcodeToPrintDevice); + SerialDisplay.print(percentageTimeCalculationEnabled, outputGcodeToPrintDevice); + SerialDisplay.print(" ;M991 Pxxx - Percentage Time Calculation (0-Disabled, 1-Enabled): ", outputGcodeToPrintDevice); + SerialDisplay.println(percentageTimeCalculationEnabled, outputGcodeToPrintDevice); + + SerialDisplay.println("", outputGcodeToPrintDevice); break; #endif } @@ -1409,15 +1488,15 @@ void processCommand(bool noSerialResponse) { if (!noSerialResponse) { - SerialDisplay.print("ok:"); + SerialDisplay.print("ok:", outputGcodeToPrintDevice); if (!GCode.line[0]) { GCode.RemoveCommentSeparators(); - SerialDisplay.println(GCode.comments); + SerialDisplay.println(GCode.comments, outputGcodeToPrintDevice); } else { - SerialDisplay.println(GCode.line); + SerialDisplay.println(GCode.line, outputGcodeToPrintDevice); } } }