1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-13 18:14:23 +02:00

Suggestions from bdring, added build-all scripts

This commit is contained in:
Mitch Bradley
2020-03-07 15:22:35 -10:00
parent 1731e8d1c4
commit cb278528ee
17 changed files with 422 additions and 157 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@ embedded/dist
*~ *~
.pio/ .pio/
.vscode/ .vscode/
.history/

View File

@@ -1,6 +1,6 @@
// Pin assignments for the ESP32 Development Controller, v3.5. // Pin assignments for the ESP32 Development Controller, v3.5.
// https://github.com/bdring/Grbl_ESP32_Development_Controller // https://github.com/bdring/Grbl_ESP32_Development_Controller
// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/ // https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
#define MACHINE_NAME "MACHINE_ESP32_V3.5" #define MACHINE_NAME "MACHINE_ESP32_V3.5"
@@ -21,8 +21,8 @@
#define SPINDLE_PWM_PIN GPIO_NUM_17 // labeled SpinPWM #define SPINDLE_PWM_PIN GPIO_NUM_17 // labeled SpinPWM
#define SPINDLE_ENABLE_PIN GPIO_NUM_22 // labeled SpinEnbl #define SPINDLE_ENABLE_PIN GPIO_NUM_22 // labeled SpinEnbl
#define MIST_PIN GPIO_NUM_21 // labeled Mist #define COOLANT_MIST_PIN GPIO_NUM_21 // labeled Mist
#define FLOOD_PIN GPIO_NUM_16 // labeled Flood #define COOLANT_FLOOD_PIN GPIO_NUM_16 // labeled Flood
#define PROBE_PIN GPIO_NUM_32 // labeled Probe #define PROBE_PIN GPIO_NUM_32 // labeled Probe
#define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // labeled Door, needs external pullup #define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // labeled Door, needs external pullup

View File

@@ -1,6 +1,6 @@
// Pin assignments for the ESP32 Development Controller, v4.1 and later. // Pin assignments for the ESP32 Development Controller, v4.1 and later.
// https://github.com/bdring/Grbl_ESP32_Development_Controller // https://github.com/bdring/Grbl_ESP32_Development_Controller
// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/ // https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
#define MACHINE_NAME "MACHINE_ESP32_V4" #define MACHINE_NAME "MACHINE_ESP32_V4"

View File

@@ -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 // used to drive a dual motor gantry where the drivers
// labeled X, Y and Z drive the machine axes X, Y and X. // labeled X, Y and Z drive the machine axes X, Y and X.
// https://github.com/bdring/Grbl_ESP32_Development_Controller // https://github.com/bdring/Grbl_ESP32_Development_Controller
// https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/ // https://www.tindie.com/products/33366583/grbl_esp32-cnc-development-board-v35/
#define MACHINE_NAME "MACHINE_ESP32_V4_XYX" #define MACHINE_NAME "MACHINE_ESP32_V4_XYX"
#define X_STEP_PIN GPIO_NUM_26 /* labeled Y */ #define X_STEP_PIN GPIO_NUM_26 /* labeled Y */
@@ -21,8 +21,8 @@
#define STEPPERS_DISABLE_PIN GPIO_NUM_13 #define STEPPERS_DISABLE_PIN GPIO_NUM_13
#define COOLANT_MIST_PIN_1 GPIO_NUM_21 #define COOLANT_MIST_PIN GPIO_NUM_21
#define COOLANT_FLOOE_PIN_2 GPIO_NUM_25 #define COOLANT_FLOOD_PIN GPIO_NUM_25
#define SPINDLE_ENABLE_PIN GPIO_NUM_22 #define SPINDLE_ENABLE_PIN GPIO_NUM_22

View File

@@ -1,9 +1,12 @@
// This is an example of using a Brushless DC Hobby motor as // This is an additional configuration fragment that can be
// a spindle motor. See this wiki page for more info // included after a base configuration file. The base file
// https://github.com/bdring/Grbl_Esp32/wiki/BESC-Spindle-Feature // establishes most settings and the add-on changes a few things.
// // For example, in machines.h, you would write:
// To use this file you must first include another machine file // #include "Machines/3axis_v4.h" // Basic pin assignments
// that defines the pin assignments, such as Machines/3x_v4.h // #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 #define SHOW_EXTENDED_SETTINGS

View File

@@ -1,30 +1,14 @@
/* // Pin assignments and other configuration for an Atari 1020 pen plotter
atari_1020.h
Part of Grbl_ESP32
copyright (c) 2018 - Bart Dring This file was modified for use on the ESP32 // The pen plotter uses several special options, including unipolar
CPU. Do not use this with Grbl for atMega328P // motors, custom homing and tool changing. The file atari_1020.cpp
// defines custom functions to handle the special features. As such,
Grbl is free software: you can redistribute it and/or modify // this file defines not only pin assignments but also many other
it under the terms of the GNU General Public License as published by // things that are necessary to override default choices that are
the Free Software Foundation, either version 3 of the License, or // inappropriate for this particular machine.
(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 <http://www.gnu.org/licenses/>.
This contains all the special features required to control an
Atari 1010 Pen Plotter
*/
#define MACHINE_NAME "MACHINE_ATARI_1020" #define MACHINE_NAME "MACHINE_ATARI_1020"
// ================== CPU MAP ======================
#ifdef USE_RMT_STEPS #ifdef USE_RMT_STEPS
#undef USE_RMT_STEPS #undef USE_RMT_STEPS
#endif #endif
@@ -78,7 +62,7 @@
#define INVERT_CONTROL_PIN_MASK B01110000 #define INVERT_CONTROL_PIN_MASK B01110000
#define MACRO_BUTTON_0_PIN GPIO_NUM_34 // Pen Switch #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 #define MACRO_BUTTON_2_PIN GPIO_NUM_36 // Paper Switch
#ifdef DEFAULTS_GENERIC #ifdef DEFAULTS_GENERIC
@@ -131,8 +115,6 @@
#define DEFAULT_Y_MAX_TRAVEL 20000.0 // mm NOTE: Must be a positive value. #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 #define DEFAULT_Z_MAX_TRAVEL 10.0 // This is percent in servo mode
// ================== CPU MAP ======================
#define ATARI_1020 #define ATARI_1020
#define SOLENOID_PWM_FREQ 5000 #define SOLENOID_PWM_FREQ 5000
@@ -144,7 +126,7 @@
#define SOLENOID_TASK_FREQ 50 // this is milliseconds #define SOLENOID_TASK_FREQ 50 // this is milliseconds
#define MAX_PEN_NUMBER 4 #define MAX_PEN_NUMBER 4
#define BUMPS_PER_PEN_CHANGE 3 #define BUMPS_PER_PEN_CHANGE 3

View File

@@ -1,79 +1 @@
/* // See template.h
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 <http://www.gnu.org/licenses/>.
====================================================================
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

View File

@@ -4,7 +4,6 @@
// Rebooting...See this issue https://github.com/bdring/Grbl_Esp32/issues/314 // Rebooting...See this issue https://github.com/bdring/Grbl_Esp32/issues/314
// !!!! Experimental Untested !!!!! // !!!! Experimental Untested !!!!!
#define MACHINE_NAME "MACHINE_ESPDUINO_32" #define MACHINE_NAME "MACHINE_ESPDUINO_32"
#define X_STEP_PIN GPIO_NUM_26 #define X_STEP_PIN GPIO_NUM_26

View File

@@ -1,4 +1,4 @@
// Pin assignments for 6-axis system // Pin assignments for a 6-axis system
#define MACHINE_NAME "MACHINE_FOO_6X" #define MACHINE_NAME "MACHINE_FOO_6X"

View File

@@ -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<<X_AXIS)|(1<<Y_AXIS))
// #undef HOMING_CYCLE_1
// #define HOMING_CYCLE_1 ((1<<A_AXIS)|(1<<B_AXIS))
// #undef HOMING_CYCLE_2
// #endif
// === Default settings
// Grbl has many run-time settings that the user can changed by
// commands like $110=2000 . Their values are stored in EEPROM
// so they persist after the controller has been powered down.
// Those settings have default values that are used if the user
// has not altered them, or if the settings are explicitly reset
// to the default values wth $RST=$.
//
// The default values are established in defaults.h, but you
// can override any one of them by definining it here, for example:
//#define DEFAULT_INVERT_LIMIT_PINS 1
//#define DEFAULT_REPORT_INCHES 1
// === Control Pins
// The control pins with names that begin with CONTROL_ are
// ignored by default, to avoid noise problems. To make them
// work, you must undefine IGNORE_CONTROL_PINS
// #undef IGNORE_CONTROL_PINS
// If some of the control pin switches are normally closed
// (the default is normally open), you can invert some of them
// with INVERT_CONTROL_PIN_MASK. The bits in the mask are
// Cycle Start, Feed Hold, Reset, Safety Door. To use a
// normally open switch on Reset, you would say
// #define INVERT_CONTROL_PIN_MASK B1101
// If your control pins do not have adequate hardware signal
// conditioning, you can define these to use software to
// reduce false triggering.
// #define ENABLE_CONTROL_SW_DEBOUNCE // Default disabled. Uncomment to enable.
// #define CONTROL_SW_DEBOUNCE_PERIOD 32 // in milliseconds default 32 microseconds
// Grbl_ESP32 use the ESP32's special RMT (IR remote control) hardware
// engine to achieve more precise high step rates than can be done
// in software. That feature is enabled by default, but there are
// some machines that might not want to use it, such as machines that
// do not use ordinary stepper motors. To turn it off, do this:
// #undef USE_RMT_STEPS
// === Special Features
// Grbl_ESP32 can support non-Cartesian machines and some other
// scenarios that cannot be handled by choosing from a set of
// predefined selections. Instead they require machine-specific
// C++ code functions. There are callouts in the core code for
// such code, guarded by ifdefs that enable calling the individual
// functions. custom_code_template.cpp describes the functions
// that you can implement. The ifdef guards are described below:
//
// USE_CUSTOM_HOMING enables the user_defined_homing() function
// that can implement an arbitrary homing sequence.
// #define USE_CUSTOM_HOMING
// USE_KINEMATICS enables the functions inverse_kinematics(),
// kinematics_pre_homing(), and kinematics_post_homing(),
// so non-Cartesian machines can be implemented.
// #define USE_KINEMATICS
// USE_FWD_KINEMATIC enables the forward_kinematics() function
// that converts motor positions in non-Cartesian coordinate
// systems back to Cartesian form, for status reports.
//#define USE_FWD_KINEMATIC
// USE_TOOL_CHANGE enables the user_tool_change() function
// that implements custom tool change procedures.
// #define USE_TOOL_CHANGE
// Any one of MACRO_BUTTON_0_PIN, MACRO_BUTTON_1_PIN, and MACRO_BUTTON_2_PIN
// enables the user_defined_macro(number) function which
// implements custom behavior at the press of a button
// #define MACRO_BUTTON_0_PIN
// USE_M30 enables the user_m30() function which implements
// custom behavior when a GCode programs stops at the end
// #define USE_M30
// USE_TRIAMINIC enables a suite of functions that are defined
// in grbl_triaminic.cpp, allowing the use of Triaminic stepper
// drivers that require software configuration at startup.
// There are several options that control the details of such
// drivers; inspect the code in grbl_triaminic.cpp to see them.
// #define USE_TRIAMINIC
// #define X_TRIAMINIC
// #define X_DRIVER_TMC2209
// #define TRIAMINIC_DAISY_CHAIN
// USE_MACHINE_TRINAMIC_INIT enables the machine_triaminic_setup()
// function that replaces the normal setup of Triaminic drivers.
// It could, for, example, setup StallGuard or other special modes.
// #define USE_MACHINE_TRINAMIC_INIT
// === Grbl behavior options
// There are quite a few options that control aspects of Grbl that
// are not specific to particular machines. They are listed and
// described in config.h after it includes the file machine.h.
// Normally you would not need to change them, but if you do,
// it will be necessary to make the change in config.h

View File

@@ -99,6 +99,10 @@ Some features should not be changed. See notes below.
#define N_AXIS 3 #define N_AXIS 3
#endif #endif
#ifndef LIMIT_MASK
#define LIMIT_MASK B0
#endif
#define VERBOSE_HELP // Currently this doesn't do anything #define VERBOSE_HELP // Currently this doesn't do anything
#define GRBL_MSG_LEVEL MSG_LEVEL_INFO // what level of [MSG:....] do you want to see 0=all off #define GRBL_MSG_LEVEL MSG_LEVEL_INFO // what level of [MSG:....] do you want to see 0=all off

2
Grbl_Esp32/cpu_map.h Normal file
View File

@@ -0,0 +1,2 @@
// Machine configuration is now done in machine.h
// Read that file for instructions.

View File

@@ -1,5 +1,5 @@
/* /*
custom_machine_template.cpp custom_code_template.cpp
Part of Grbl_ESP32 Part of Grbl_ESP32
copyright (c) 2020 - Bart Dring. This file was intended for use on the ESP32 copyright (c) 2020 - Bart Dring. This file was intended for use on the ESP32
@@ -20,13 +20,13 @@
======================================================================= =======================================================================
This is a template for a custom machine file. The various optional functions are This is a template for user-defined C++ code functions. Grbl can be
called by main Grbl_ESP when enabled via #define statements in Machines/my_machine.h. configured to call some optional functions, enabled by #define statements
The machine designer must fill in the contents of the functions that are enabled. in the machine definition .h file. Implement the functions thus enabled
See each function for more information herein. The possible functions are listed and described below.
Copy custom_machine_template.cpp and Machines/custom_machine_template.h, To use this file, copy it to a name of your own choosing, and also copy
changing the filenames to your machine's name. Machines/template.h to a similar name.
Example: Example:
Machines/my_machine.h Machines/my_machine.h
@@ -36,6 +36,9 @@ Edit machine.h to include your Machines/my_machine.h file
Edit Machines/my_machine.h according to the instructions therein. Edit Machines/my_machine.h according to the instructions therein.
Fill in the function definitions below for the functions that you have
enabled with USE_ defines in Machines/my_machine.h
=============================================================================== ===============================================================================
*/ */
@@ -44,13 +47,13 @@ Edit Machines/my_machine.h according to the instructions therein.
// will be loaded before the remainder of this file is processed. // will be loaded before the remainder of this file is processed.
#include "grbl.h" #include "grbl.h"
// !!! Change this to the name you chose in Machines/my_machine.h // !!! Change this to the MACHINE_name you chose in Machines/my_machine.h
// The compiler will skip the rest of this file unless that name is defined // The compiler will skip the rest of this file unless that name is defined
#ifdef MACHINE_CUSTOM #ifdef MACHINE_CUSTOM
#ifdef USE_MACHINE_INIT #ifdef USE_MACHINE_INIT
/* /*
This function will be called when Grbl_ESP32 first starts. You can use it to do any machine_init() is called when Grbl_ESP32 first starts. You can use it to do any
special things your machine needs at startup. special things your machine needs at startup.
*/ */
void machine_init() { void machine_init() {
@@ -110,10 +113,11 @@ bool kinematics_pre_homing(uint8_t cycle_mask)) {
kinematics_post_homing() is called at the end of normal homing kinematics_post_homing() is called at the end of normal homing
*/ */
void kinematics_post_homing() { void kinematics_post_homing() {
} }
#endif #endif
#ifdef USE_FWD_KINEMATICS #ifdef USE_FWD_KINEMATIC
/* /*
The status command uses forward_kinematics() to convert The status command uses forward_kinematics() to convert
your motor positions to cartesian X,Y,Z... coordinates. your motor positions to cartesian X,Y,Z... coordinates.
@@ -132,16 +136,18 @@ void forward_kinematics(float *position) {
to perform appropriate actions for your machine. to perform appropriate actions for your machine.
*/ */
void user_tool_change(uint8_t new_tool) { void user_tool_change(uint8_t new_tool) {
} }
#endif #endif
#ifdef MACRO_BUTTON_0_PIN #if defined(MACRO_BUTTON_0_PIN) || defined(MACRO_BUTTON_1_PIN) || defined(MACRO_BUTTON_2_PIN)
/* /*
options. user_defined_macro() is called with the button number to options. user_defined_macro() is called with the button number to
perform whatever actions you choose. perform whatever actions you choose.
*/ */
void user_defined_macro(uint8_t index) void user_defined_macro(uint8_t index)
{ {
} }
#endif #endif
@@ -150,6 +156,7 @@ void user_defined_macro(uint8_t index)
user_m30() is called when an M30 gcode signals the end of a gcode file. user_m30() is called when an M30 gcode signals the end of a gcode file.
*/ */
void user_m30() { void user_m30() {
} }
#endif #endif

View File

@@ -1,33 +1,62 @@
// Configure for a specific machine by including one or more // This file is where you choose the machine type, by including
// machine definition files as described below. Machine // one or more machine definition files as described below.
// definition files assign CPU pins to machine functions
// according to the wiring of interface boards.
#ifndef _machine_h #ifndef _machine_h
#define _machine_h #define _machine_h
// For initial testing, start with this one which disables all I/O pins #ifndef MACHINE_FILENAME
// #include "Machines/test_drive.h"
// For actual use, select the appropriate board from Machines/, // !!! For initial testing, start with test_drive.h which disables
// or create your own, for example: // all I/O pins
#include "Machines/3x_v4.h" #include "Machines/test_drive.h"
// Some configurations use two files, the first assigning pins // !!! For actual use, change the line above to select a board
// and the second providing additional customization, for example: // from Machines/, for example:
// #include "Machines/3x_v4.h" // #include "Machines/3axis_v4.h"
// #include "Machines/3x_esc_spindle.h"
// Some configurations use two files, the first establishing a base
// configuration and the second providing additional customization,
// for example:
// #include "Machines/3axis_v4.h"
// #include "Machines/add_esc_spindle.h"
/* --------------------------------------------------------------------------------------- // === OEM Single File Configuration Option
OEM Single File Configuration Option // OEMs that wish to publish source code that is configured for a
// specific machine may put all of their configuration definitions
// directly in this file, without including any other file above.
Instructions: Comment out all #include's above and paste the machine definition and #else
any default settings that you wish to override below.
*/
// Paste machine definitions here. // By using the external environment to define MACHINE_FILENAME,
// a configuration can be chosen without editing this file.
// That is useful for automated testing scripts.
//
// For example, when using the platformio compilation environment
// under Linux, you could issue the following command line:
// PLATFORMIO_BUILD_FLAGS=-DMACHINE_FILENAME=3axis_v4.h platformio run
//
// Under Windows, using PowerShell, the command would be:
// $env:PLATFORMIO_BUILD_FLAGS='-DMACHINE_FILENAME=3axis_v4.h'; platformio run
//
// When using the Arduino IDE, there is no easy way to pass variables
// to the compiler, so this feature is not useful for Arduino.
//
// MACHINE_FILENAME must not include the Machines/ path prefix; it is
// supplied automatically.
// Paste default settings override definitions here. // MACHINE_PATHNAME_QUOTED constructs a path that is suitable for #include
#define MACHINE_PATHNAME_QUOTED(name) <Machines/name>
#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 #endif // _machine_h

34
build-all.ps1 Normal file
View File

@@ -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

42
build-all.sh Normal file
View File

@@ -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