diff --git a/.gitignore b/.gitignore
index 40c50802..95228f92 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@ embedded/node_modules
embedded/dist
*~
.pio/
-.vscode/
\ No newline at end of file
+.vscode/
+.history/
\ No newline at end of file
diff --git a/Grbl_Esp32/Machines/3x_v3.h b/Grbl_Esp32/Machines/3axis_v3.h
similarity index 81%
rename from Grbl_Esp32/Machines/3x_v3.h
rename to Grbl_Esp32/Machines/3axis_v3.h
index 5d8313fc..d0ad82b8 100644
--- a/Grbl_Esp32/Machines/3x_v3.h
+++ b/Grbl_Esp32/Machines/3axis_v3.h
@@ -1,6 +1,6 @@
// Pin assignments for the ESP32 Development Controller, v3.5.
-// https://github.com/bdring/Grbl_ESP32_Development_Controller
-// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
+// https://github.com/bdring/Grbl_ESP32_Development_Controller
+// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
#define MACHINE_NAME "MACHINE_ESP32_V3.5"
@@ -21,8 +21,8 @@
#define SPINDLE_PWM_PIN GPIO_NUM_17 // labeled SpinPWM
#define SPINDLE_ENABLE_PIN GPIO_NUM_22 // labeled SpinEnbl
-#define MIST_PIN GPIO_NUM_21 // labeled Mist
-#define FLOOD_PIN GPIO_NUM_16 // labeled Flood
+#define COOLANT_MIST_PIN GPIO_NUM_21 // labeled Mist
+#define COOLANT_FLOOD_PIN GPIO_NUM_16 // labeled Flood
#define PROBE_PIN GPIO_NUM_32 // labeled Probe
#define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // labeled Door, needs external pullup
diff --git a/Grbl_Esp32/Machines/3x_v4.h b/Grbl_Esp32/Machines/3axis_v4.h
similarity index 89%
rename from Grbl_Esp32/Machines/3x_v4.h
rename to Grbl_Esp32/Machines/3axis_v4.h
index 8c8835e8..fb7bce45 100644
--- a/Grbl_Esp32/Machines/3x_v4.h
+++ b/Grbl_Esp32/Machines/3axis_v4.h
@@ -1,6 +1,6 @@
// Pin assignments for the ESP32 Development Controller, v4.1 and later.
-// https://github.com/bdring/Grbl_ESP32_Development_Controller
-// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
+// https://github.com/bdring/Grbl_ESP32_Development_Controller
+// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
#define MACHINE_NAME "MACHINE_ESP32_V4"
diff --git a/Grbl_Esp32/Machines/3x_xyx.h b/Grbl_Esp32/Machines/3axis_xyx.h
similarity index 80%
rename from Grbl_Esp32/Machines/3x_xyx.h
rename to Grbl_Esp32/Machines/3axis_xyx.h
index ca44c239..d2f07667 100644
--- a/Grbl_Esp32/Machines/3x_xyx.h
+++ b/Grbl_Esp32/Machines/3axis_xyx.h
@@ -1,8 +1,8 @@
-// This is the CPU Map for the ESP32 Development Controller
+// Pin assignments for the ESP32 Development Controller
// used to drive a dual motor gantry where the drivers
// labeled X, Y and Z drive the machine axes X, Y and X.
-// https://github.com/bdring/Grbl_ESP32_Development_Controller
-// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
+// https://github.com/bdring/Grbl_ESP32_Development_Controller
+// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
#define MACHINE_NAME "MACHINE_ESP32_V4_XYX"
#define X_STEP_PIN GPIO_NUM_26 /* labeled Y */
@@ -21,8 +21,8 @@
#define STEPPERS_DISABLE_PIN GPIO_NUM_13
-#define COOLANT_MIST_PIN_1 GPIO_NUM_21
-#define COOLANT_FLOOE_PIN_2 GPIO_NUM_25
+#define COOLANT_MIST_PIN GPIO_NUM_21
+#define COOLANT_FLOOD_PIN GPIO_NUM_25
#define SPINDLE_ENABLE_PIN GPIO_NUM_22
diff --git a/Grbl_Esp32/Machines/3x_esc_spindle.h b/Grbl_Esp32/Machines/add_esc_spindle.h
similarity index 63%
rename from Grbl_Esp32/Machines/3x_esc_spindle.h
rename to Grbl_Esp32/Machines/add_esc_spindle.h
index 65f6b189..33426a52 100644
--- a/Grbl_Esp32/Machines/3x_esc_spindle.h
+++ b/Grbl_Esp32/Machines/add_esc_spindle.h
@@ -1,9 +1,12 @@
-// This is an example of using a Brushless DC Hobby motor as
-// a spindle motor. See this wiki page for more info
-// https://github.com/bdring/Grbl_Esp32/wiki/BESC-Spindle-Feature
-//
-// To use this file you must first include another machine file
-// that defines the pin assignments, such as Machines/3x_v4.h
+// This is an additional configuration fragment that can be
+// included after a base configuration file. The base file
+// establishes most settings and the add-on changes a few things.
+// For example, in machines.h, you would write:
+// #include "Machines/3axis_v4.h" // Basic pin assignments
+// #include "Machines/add_esc_spindle.h" // Add-ons for ESC spindle
+
+// This uses a Brushless DC Hobby motor as a spindle motor. See:
+// https://github.com/bdring/Grbl_Esp32/wiki/BESC-Spindle-Feature
#define SHOW_EXTENDED_SETTINGS
diff --git a/Grbl_Esp32/Machines/atari_1020.h b/Grbl_Esp32/Machines/atari_1020.h
index 972ad5bd..328283b0 100644
--- a/Grbl_Esp32/Machines/atari_1020.h
+++ b/Grbl_Esp32/Machines/atari_1020.h
@@ -1,30 +1,14 @@
-/*
- atari_1020.h
- Part of Grbl_ESP32
+// Pin assignments and other configuration for an Atari 1020 pen plotter
- copyright (c) 2018 - Bart Dring This file was modified for use on the ESP32
- CPU. Do not use this with Grbl for atMega328P
-
- Grbl is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Grbl is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
-
- This contains all the special features required to control an
- Atari 1010 Pen Plotter
-*/
+// The pen plotter uses several special options, including unipolar
+// motors, custom homing and tool changing. The file atari_1020.cpp
+// defines custom functions to handle the special features. As such,
+// this file defines not only pin assignments but also many other
+// things that are necessary to override default choices that are
+// inappropriate for this particular machine.
#define MACHINE_NAME "MACHINE_ATARI_1020"
-// ================== CPU MAP ======================
#ifdef USE_RMT_STEPS
#undef USE_RMT_STEPS
#endif
@@ -78,7 +62,7 @@
#define INVERT_CONTROL_PIN_MASK B01110000
#define MACRO_BUTTON_0_PIN GPIO_NUM_34 // Pen Switch
-#define MACRO_BUTTON_1_PIN GPIO_NUM_35 // Color Switch
+#define MACRO_BUTTON_1_PIN GPIO_NUM_35 // Color Switch
#define MACRO_BUTTON_2_PIN GPIO_NUM_36 // Paper Switch
#ifdef DEFAULTS_GENERIC
@@ -131,8 +115,6 @@
#define DEFAULT_Y_MAX_TRAVEL 20000.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Z_MAX_TRAVEL 10.0 // This is percent in servo mode
-// ================== CPU MAP ======================
-
#define ATARI_1020
#define SOLENOID_PWM_FREQ 5000
@@ -144,7 +126,7 @@
#define SOLENOID_TASK_FREQ 50 // this is milliseconds
-#define MAX_PEN_NUMBER 4
+#define MAX_PEN_NUMBER 4
#define BUMPS_PER_PEN_CHANGE 3
diff --git a/Grbl_Esp32/Machines/custom_machine_template.h b/Grbl_Esp32/Machines/custom_machine_template.h
index 23cbb91a..03b74bbb 100644
--- a/Grbl_Esp32/Machines/custom_machine_template.h
+++ b/Grbl_Esp32/Machines/custom_machine_template.h
@@ -1,79 +1 @@
-/*
- custom_machine_template.h
- Part of Grbl_ESP32
-
- copyright (c) 2020 - Bart Dring. This file was intended for use on the ESP32
- CPU. Do not use this with Grbl for atMega328P
-
- Grbl_ESP32 is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Grbl_ESP32 is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Grbl. If not, see .
-
- ====================================================================
-
- See custom_machine_templete.cpp for getting started creating custom
- machines
-*/
-
-// =============== MACHINE NAME ========================
-// Change "MACHINE_CUSTOM", replacing "CUSTOM" with your chosen name
-
-// #define MACHINE_NAME "MACHINE_CUSTOM"
-
-// ================ config.h overrides ====================================
-// If you want to make some changes to config.h, it is best to do it here
-// if possible so all your changes are in your files. Many of the #defines
-// in config.h are only applied if the symbol is not already defined in
-// a machine definition file. Example:
-
-// #define N_AXIS 4
-
-// =============== MACHINE CONFIGURATION ========================
-// Look at the other files in the Machines/ directory
-// for all the things that can go here
-
-// Assign CPU pins to machine functions, for example:
-#define X_STEP_PIN GPIO_NUM_12
-#define X_DIRECTION_PIN GPIO_NUM_26
-#define X_LIMIT_PIN GPIO_NUM_2
-
-// #define SPINDLE_PWM_PIN GPIO_NUM_17
-
-// #define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35
-
-// Set the number of bits to the number of limit switches
-#define LIMIT_MASK B111
-
-// ============== Enable custom features =======================
-
-// There are several customization functions that the code only
-// calls if the symbols below are defined. To use such a function,
-// you must define the symbol herein, and define the function in
-// your my_machine.cpp file.
-
-// #define USE_MACHINE_INIT // Enables use of custom machine_init()
-// #define USE_CUSTOM_HOMING // Enables use of user_defined_homing()
-// #define USE_KINEMATICS // Enables use of inverse_kinematics(), kinematics_pre_homing(), and kinematics_post_homing()
-// #define USE_FWD_KINEMATIC // Enables use of forward_kinematics()
-// #define USE_TOOL_CHANGE // Enables use off user_tool_change()
-// #define USE_M30 // Enables use of user_m30()
-// #define USE_TRIAMINIC // Enables use of functions shown in grbl_triaminic.h
-// #define USE_MACHINE_TRINAMIC_INIT // Enables use of machine_triaminic_setup()
-
-// ===================== $$ Defaults ==========================================
-// defaults.h defines default values for the $$ settings that will be
-// applied when you upload new firmware or if you reset them with $RST=$.
-// You can override individual defaults by defining them here. Examples:
-
-// #define DEFAULT_SPINDLE_FREQ 2000.0
-// #define DEFAULT_X_MAX_TRAVEL 100.0
-
+// See template.h
\ No newline at end of file
diff --git a/Grbl_Esp32/Machines/espduino.h b/Grbl_Esp32/Machines/espduino.h
index 681de94b..59e11da3 100644
--- a/Grbl_Esp32/Machines/espduino.h
+++ b/Grbl_Esp32/Machines/espduino.h
@@ -4,7 +4,6 @@
// Rebooting...See this issue https://github.com/bdring/Grbl_Esp32/issues/314
// !!!! Experimental Untested !!!!!
-
#define MACHINE_NAME "MACHINE_ESPDUINO_32"
#define X_STEP_PIN GPIO_NUM_26
diff --git a/Grbl_Esp32/Machines/foo_6x.h b/Grbl_Esp32/Machines/foo_6axis.h
similarity index 99%
rename from Grbl_Esp32/Machines/foo_6x.h
rename to Grbl_Esp32/Machines/foo_6axis.h
index 127d2f50..60190a84 100644
--- a/Grbl_Esp32/Machines/foo_6x.h
+++ b/Grbl_Esp32/Machines/foo_6axis.h
@@ -1,4 +1,4 @@
-// Pin assignments for 6-axis system
+// Pin assignments for a 6-axis system
#define MACHINE_NAME "MACHINE_FOO_6X"
diff --git a/Grbl_Esp32/Machines/spi_daisy_4x.h b/Grbl_Esp32/Machines/spi_daisy_4axis.h
similarity index 100%
rename from Grbl_Esp32/Machines/spi_daisy_4x.h
rename to Grbl_Esp32/Machines/spi_daisy_4axis.h
diff --git a/Grbl_Esp32/Machines/template.h b/Grbl_Esp32/Machines/template.h
new file mode 100644
index 00000000..11f8acf3
--- /dev/null
+++ b/Grbl_Esp32/Machines/template.h
@@ -0,0 +1,240 @@
+// Template for a machine configuration file.
+
+// This contains a long list of things that might possibly be
+// configured. Most machines - especially simple cartesian machines
+// that use stepper motors - will only need to define a few of the
+// options herein, often just the pin assignments.
+
+// Pin assignments depend on how the ESP32 is connected to
+// the external machine. Typically the ESP32 module plugs into
+// an adapter board that wires specific ESP32 GPIO pins to
+// other connectors on the board, such as Pololu sockets for
+// stepper drivers or connectors for external drivers, limit
+// pins, spindle control, etc. This file describes how those
+// GPIO pins are wired to those other connectors.
+
+// Some machines might choose to use an adapter board in a
+// non-standard way, for example a 3-axis board might have axes
+// labeled XYZ, but the machine might have only 2 axes one of which is
+// driven by two ganged motors. In that case, you would need
+// a custom version of this file that assigns the pins differently
+// from the adapter board labels.
+
+// In addition to pin assignments, many other aspects of Grbl
+// can be configured, such as spindle speeds, special motor
+// types like servos and unipolars, homing order, default values
+// for $$ settings, etc. A detailed list of such options is
+// given below.
+
+// Furthermore, it is possible to implement special complex
+// behavior in custom C++ code, for non-Cartesian machines,
+// unusual homing cycles, etc. See the Special Features section
+// below for additional instructions.
+
+// === Machine Name
+// Change TEMPLATE to some name of your own choosing. That name
+// will be shown in a Grbl startup message to identify your
+// configuration. If you need to implement custom code functions
+// as in custom_code_template.cpp, the beginning #ifdef in
+// your custom .cpp file must match your chosen MACHINE_name ,
+// so as to enable the compilation of your file and suppress
+// compilation of other custom .cpp files.
+
+#define MACHINE_NAME "MACHINE_TEMPLATE"
+
+// === Number of axes
+
+// You can set the number of axes that the machine supports
+// by defining N_AXIS. If you do not define it, 3 will be
+// used. The value must be at least 3, even if your machine
+// has fewer axes.
+// #define N_AXIS 4
+
+
+// == Pin Assignments
+
+// Step and direction pins; these must be output-capable pins,
+// specifically ESP32 GPIO numbers 0..31
+// #define X_STEP_PIN GPIO_NUM_12
+// #define X_DIRECTION_PIN GPIO_NUM_14
+// #define Y_STEP_PIN GPIO_NUM_26
+// #define Y_DIRECTION_PIN GPIO_NUM_15
+// #define Z_STEP_PIN GPIO_NUM_27
+// #define Z_DIRECTION_PIN GPIO_NUM_33
+
+// The 1 bits in LIMIT_MASK set the axes that have limit switches
+// For example, if the Y axis has no limit switches but the
+// X, Z, A and B axes do, the LIMIT_MASK value would be B11101
+// #define LIMIT_MASK B111
+
+// #define X_LIMIT_PIN GPIO_NUM_17
+// #define Y_LIMIT_PIN GPIO_NUM_4
+// #define Z_LIMIT_PIN GPIO_NUM_16
+
+// Common enable for all steppers. If it is okay to leave
+// your drivers enabled at all times, you can leave
+// STEPPERS_DISABLE_PIN undefined and use the pin for something else.
+// #define STEPPERS_DISABLE_PIN GPIO_NUM_13
+
+// Pins for controlling various aspects of the machine. If your
+// machine does not support one of these features, you can leave
+// the corresponding pin undefined.
+
+// #define SPINDLE_PWM_PIN GPIO_NUM_2 // labeled SpinPWM
+// #define SPINDLE_ENABLE_PIN GPIO_NUM_22 // labeled SpinEnbl
+// #define COOLANT_MIST_PIN GPIO_NUM_21 // labeled Mist
+// #define COOLANT_FLOOD_PIN GPIO_NUM_25 // labeled Flood
+// #define PROBE_PIN GPIO_NUM_32 // labeled Probe
+
+// Input pins for various functions. If the corresponding pin is not defined,
+// the function will not be available.
+
+// CONTROL_SAFETY_DOOR_PIN shuts off the machine when a door is opened
+// or some other unsafe condition exists.
+// #define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // labeled Door, needs external pullup
+
+// RESET, FEED_HOLD, and CYCLE_START can control GCode execution at
+// the push of a button.
+
+// #define CONTROL_RESET_PIN GPIO_NUM_34 // labeled Reset, needs external pullup
+// #define CONTROL_FEED_HOLD_PIN GPIO_NUM_36 // labeled Hold, needs external pullup
+// #define CONTROL_CYCLE_START_PIN GPIO_NUM_39 // labeled Start, needs external pullup
+
+// === Ganging
+// If you need to use two motors on one axis, you can "gang" the motors by
+// defining a second pin to control the other motor on the axis. For example:
+
+// #define Y2_STEP_PIN GPIO_NUM_27 /* labeled Z */
+// #define Y2_DIRECTION_PIN GPIO_NUM_33 /* labeled Z */
+
+// === Servos
+// To use a servo motor on an axis, do not define step and direction
+// pins for that axis, but instead include a block like this:
+// #define USE_SERVO_AXES
+
+// #define SERVO_Z_PIN GPIO_NUM_22
+// #define SERVO_Z_CHANNEL_NUM 6
+// #define SERVO_Z_RANGE_MIN 0.0
+// #define SERVO_Z_RANGE_MAX 5.0
+// #define SERVO_Z_HOMING_TYPE SERVO_HOMING_TARGET // during homing it will instantly move to a target value
+// #define SERVO_Z_HOME_POS SERVO_Z_RANGE_MAX // move to max during homing
+// #define SERVO_Z_MPOS false // will not use mpos, uses work coordinates
+
+// === Homing cycles
+// The default homing order is Z first (HOMING_CYCLE_0),
+// then X (HOMING_CYCLE_1), and finally Y (HOMING_CYCLE_2)
+// For machines that need different homing order, you can
+// undefine HOMING_CYCLE_n and redefine it accordingly.
+// For example, the following would first home X and Y
+// simultaneously, then A and B simultaneously, and Z
+// not at all.
+
+// #undef HOMING_CYCLE_0
+// #define HOMING_CYCLE_0 ((1<
+
+#include MACHINE_PATHNAME_QUOTED(MACHINE_FILENAME)
+
+// You can choose two-file configurations by also defining MACHINE_FILENAME2,
+// for example:
+// $env:PLATFORMIO_BUILD_FLAGS='-DMACHINE_FILENAME=3axis_v4.h -DMACHINE_FILENAME2=add_esc_spindle.h'; platformio run
+
+#ifdef MACHINE_FILENAME2
+#include MACHINE_PATHNAME_QUOTED(MACHINE_FILENAME2)
+#endif
+
+#endif // MACHINE_FILENAME
#endif // _machine_h
diff --git a/build-all.ps1 b/build-all.ps1
new file mode 100644
index 00000000..964fc524
--- /dev/null
+++ b/build-all.ps1
@@ -0,0 +1,34 @@
+# This Windows PowerShell script uses PlatformIO to compile Grbl_ESP32
+# for every machine configuration in the Machines/ directory.
+# It is useful for automated testing.
+
+# Setting PYTHONIOENCODING avoids an obscure crash related to code page mismatch
+$env:PYTHONIOENCODING="utf-8"
+$envsave = $env:PLATFORMIO_BUILD_FLAGS
+
+Function BuildMachine($names) {
+ $basename = $names[0]
+ $addname = $names[1]
+ $env:PLATFORMIO_BUILD_FLAGS = "-DMACHINE_FILENAME=$basename"
+ $displayname = $basename
+ if ($addname -ne "") {
+ $env:PLATFORMIO_BUILD_FLAGS += " -DMACHINE_FILENAME2=$addname"
+ $displayname += " + $addname"
+ }
+ Write-Output "Building machine $displayname"
+ platformio run 2>&1 | Select-String error,Took
+ Write-Output " "
+}
+
+# First build all the base configurations with names that do not start with add_
+foreach ($filepath in Get-ChildItem -file .\Grbl_Esp32\Machines\* -Exclude add_*) {
+ BuildMachine($filepath.name, "")
+}
+
+# Then build all of the add-ons on top of a single base
+$base="3axis_v4.h"
+foreach ($filepath in Get-ChildItem -file .\Grbl_Esp32\Machines\add_*) {
+ BuildMachine($base, $filepath.name)
+}
+
+$env:PLATFORMIO_BUILD_FLAGS=$envsave
\ No newline at end of file
diff --git a/build-all.sh b/build-all.sh
new file mode 100644
index 00000000..b417aa73
--- /dev/null
+++ b/build-all.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# This shell script uses PlatformIO to compile Grbl_ESP32
+# for every machine configuration in the Machines/ directory.
+# It is useful for automated testing.
+
+trap "echo; exit" SIGINT
+
+# With -v, show all output. Otherwise, show just the result
+if [ "$1" = "-v" ]; then
+ FILTER="cat"
+else
+ FILTER="grep error\|Took"
+fi
+BuildMachine () {
+ basename=$1
+ addname=$2
+ BF="-DMACHINE_FILENAME=$basename"
+ displayname=$basename
+ if [ "$addname" != "" ]
+ then
+ BF="$BF -DMACHINE_FILENAME2=$addname"
+ displayname="$basename + $addname"
+ fi
+ echo "Building machine $displayname"
+ PLATFORMIO_BUILD_FLAGS=\'$BF\' platformio run 2>&1 | $FILTER
+ echo
+}
+
+# First build all the base configurations with names that do not start with add_
+for file in `ls ./Grbl_Esp32/Machines/* | grep -v add_\*`; do
+ base=`basename $file`
+ BuildMachine $base ""
+done
+
+# Then build all of the add-ons on top of a single base
+base="3axis_v4.h"
+for file in `ls ./Grbl_Esp32/Machines/add_*`
+do
+ adder=`basename $file`
+ BuildMachine $base $adder
+done