mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-27 08:14:31 +02:00
Moved custom code into Custom/ subdirectory
Also improved the build scripts
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ embedded/dist
|
|||||||
.pio/
|
.pio/
|
||||||
.vscode/
|
.vscode/
|
||||||
.history/
|
.history/
|
||||||
|
*.pyc
|
||||||
|
@@ -23,9 +23,10 @@
|
|||||||
This contains all the special features required to control an
|
This contains all the special features required to control an
|
||||||
Atari 1010 Pen Plotter
|
Atari 1010 Pen Plotter
|
||||||
*/
|
*/
|
||||||
#include "grbl.h"
|
|
||||||
|
|
||||||
#ifdef ATARI_1020
|
// This file is enabled by defining CUSTOM_CODE_FILENAME "atari_1020.cpp"
|
||||||
|
// in Machines/atari_1020.h, thus causing this file to be included
|
||||||
|
// from ../custom_code.cpp
|
||||||
|
|
||||||
#define HOMING_PHASE_FULL_APPROACH 0 // move to right end
|
#define HOMING_PHASE_FULL_APPROACH 0 // move to right end
|
||||||
#define HOMING_PHASE_CHECK 1 // check reed switch
|
#define HOMING_PHASE_CHECK 1 // check reed switch
|
||||||
@@ -319,6 +320,3 @@ void user_m30() {
|
|||||||
sprintf(gcode_line, "G90G0X%3.2f\r", ATARI_PAPER_WIDTH); //
|
sprintf(gcode_line, "G90G0X%3.2f\r", ATARI_PAPER_WIDTH); //
|
||||||
inputBuffer.push(gcode_line);
|
inputBuffer.push(gcode_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -30,7 +30,7 @@ Machines/template.h to a similar name.
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
Machines/my_machine.h
|
Machines/my_machine.h
|
||||||
my_machine.cpp
|
Custom/my_machine.cpp
|
||||||
|
|
||||||
Edit machine.h to include your Machines/my_machine.h file
|
Edit machine.h to include your Machines/my_machine.h file
|
||||||
|
|
||||||
@@ -43,14 +43,6 @@ enabled with USE_ defines in Machines/my_machine.h
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// It is necessary to include grbl.h so that the machine definitions
|
|
||||||
// will be loaded before the remainder of this file is processed.
|
|
||||||
#include "grbl.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
|
|
||||||
#ifdef MACHINE_CUSTOM
|
|
||||||
|
|
||||||
#ifdef USE_MACHINE_INIT
|
#ifdef USE_MACHINE_INIT
|
||||||
/*
|
/*
|
||||||
machine_init() is 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
|
||||||
@@ -173,6 +165,3 @@ void machine_trinamic_setup() {
|
|||||||
// If you add any additional functions specific to your machine that
|
// If you add any additional functions specific to your machine that
|
||||||
// require calls from common code, guard their calls in the common code with
|
// require calls from common code, guard their calls in the common code with
|
||||||
// #ifdef USE_WHATEVER and add function prototypes (also guarded) to grbl.h
|
// #ifdef USE_WHATEVER and add function prototypes (also guarded) to grbl.h
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@@ -50,10 +50,9 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "grbl.h"
|
// This file is enabled by defining CUSTOM_CODE_FILENAME "polar_coaster.cpp"
|
||||||
|
// in Machines/polar_coaster.h, thus causing this file to be included
|
||||||
#ifdef MACHINE_POLAR_COASTER
|
// from ../custom_code.cpp
|
||||||
#ifdef USE_KINEMATICS
|
|
||||||
|
|
||||||
void calc_polar(float *target_xyz, float *polar, float last_angle);
|
void calc_polar(float *target_xyz, float *polar, float last_angle);
|
||||||
float abs_angle(float ang);
|
float abs_angle(float ang);
|
||||||
@@ -175,7 +174,6 @@ void inverse_kinematics(float *target, plan_line_data_t *pl_data, float *positio
|
|||||||
// TO DO don't need a feedrate for rapids
|
// TO DO don't need a feedrate for rapids
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Forward kinematics converts position back to the original cartesian system. It is
|
Forward kinematics converts position back to the original cartesian system. It is
|
||||||
typically used for reporting
|
typically used for reporting
|
||||||
@@ -264,8 +262,6 @@ float abs_angle(float ang) {
|
|||||||
return ang;
|
return ang;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Polar coaster has macro buttons, this handles those button pushes.
|
// Polar coaster has macro buttons, this handles those button pushes.
|
||||||
void user_defined_macro(uint8_t index)
|
void user_defined_macro(uint8_t index)
|
||||||
{
|
{
|
||||||
@@ -298,6 +294,3 @@ void user_defined_macro(uint8_t index)
|
|||||||
void user_m30() {
|
void user_m30() {
|
||||||
inputBuffer.push("$H\r");
|
inputBuffer.push("$H\r");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#define MACHINE_NAME "MACHINE_ATARI_1020"
|
#define MACHINE_NAME "MACHINE_ATARI_1020"
|
||||||
|
|
||||||
|
#define CUSTOM_CODE_FILENAME "Custom/atari_1020.cpp"
|
||||||
|
|
||||||
#ifdef USE_RMT_STEPS
|
#ifdef USE_RMT_STEPS
|
||||||
#undef USE_RMT_STEPS
|
#undef USE_RMT_STEPS
|
||||||
#endif
|
#endif
|
||||||
|
@@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
#define MACHINE_NAME "MACHINE_POLAR_COASTER"
|
#define MACHINE_NAME "MACHINE_POLAR_COASTER"
|
||||||
|
|
||||||
// This must be defined so that polar_coaster.cpp is not skipped
|
// This causes the custom code file to be included in the build
|
||||||
#define MACHINE_POLAR_COASTER
|
// via ../custom_code.cpp
|
||||||
|
#define CUSTOM_CODE_FILENAME "Custom/polar_coaster.cpp"
|
||||||
|
|
||||||
#define RADIUS_AXIS 0
|
#define RADIUS_AXIS 0
|
||||||
#define POLAR_AXIS 1
|
#define POLAR_AXIS 1
|
||||||
|
@@ -34,14 +34,16 @@
|
|||||||
// === Machine Name
|
// === Machine Name
|
||||||
// Change TEMPLATE to some name of your own choosing. That name
|
// Change TEMPLATE to some name of your own choosing. That name
|
||||||
// will be shown in a Grbl startup message to identify your
|
// will be shown in a Grbl startup message to identify your
|
||||||
// configuration. If you need to implement custom code functions
|
// configuration.
|
||||||
// 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"
|
#define MACHINE_NAME "MACHINE_TEMPLATE"
|
||||||
|
|
||||||
|
// If your machine requires custom code as described below in
|
||||||
|
// Special Features, you must copy Custom/custom_code_template.cpp
|
||||||
|
// to a new name like Custom/my_custom_code.cpp, implement the
|
||||||
|
// functions therein, and enable its use by defining:
|
||||||
|
// #define CUSTOM_CODE_FILENAME "Custom/my_custom_code.cpp"
|
||||||
|
|
||||||
// === Number of axes
|
// === Number of axes
|
||||||
|
|
||||||
// You can set the number of axes that the machine supports
|
// You can set the number of axes that the machine supports
|
||||||
|
8
Grbl_Esp32/custom_code.cpp
Normal file
8
Grbl_Esp32/custom_code.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// This file loads custom code from the Custom/ subdirectory if
|
||||||
|
// CUSTOM_CODE_FILENAME is defined.
|
||||||
|
|
||||||
|
#include "grbl.h"
|
||||||
|
|
||||||
|
#ifdef CUSTOM_CODE_FILENAME
|
||||||
|
#include CUSTOM_CODE_FILENAME
|
||||||
|
#endif
|
32
build-all.py
32
build-all.py
@@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
|
# Note: If you experience random errors running this script within
|
||||||
|
# VSCode, try running it from a regular terminal window. Some VSCode
|
||||||
|
# extensions seem to randomly interfere with the files that platformio
|
||||||
|
# uses during compilation.
|
||||||
|
|
||||||
# Compile Grbl_ESP32 for each of the machines defined in Machines/ .
|
# Compile Grbl_ESP32 for each of the machines defined in Machines/ .
|
||||||
# Add-on files are built on top of a single base.
|
# Add-on files are built on top of a single base.
|
||||||
# This is useful for automated testing, to make sure you haven't broken something
|
# This is useful for automated testing, to make sure you haven't broken something
|
||||||
@@ -9,31 +14,16 @@
|
|||||||
# contain the word "error". If you need to see everything, for example to
|
# contain the word "error". If you need to see everything, for example to
|
||||||
# see the details of an errored build, include -v on the command line.
|
# see the details of an errored build, include -v on the command line.
|
||||||
|
|
||||||
from __future__ import print_function
|
from builder import buildMachine
|
||||||
import os, subprocess, sys
|
import os, sys
|
||||||
|
|
||||||
|
cmd = ['platformio','run']
|
||||||
|
|
||||||
env = dict(os.environ)
|
|
||||||
verbose = '-v' in sys.argv
|
verbose = '-v' in sys.argv
|
||||||
|
|
||||||
def buildMachine(baseName, addName=None):
|
|
||||||
displayName = baseName
|
|
||||||
flags = '-DMACHINE_FILENAME=' + baseName
|
|
||||||
if addName:
|
|
||||||
displayName += ' + ' + addName
|
|
||||||
flags += ' -DMACHINE_FILENAME2=' + addName
|
|
||||||
print('Building machine ' + displayName)
|
|
||||||
env['PLATFORMIO_BUILD_FLAGS'] = flags
|
|
||||||
app = subprocess.Popen(['platformio','run'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, env=env)
|
|
||||||
for line in app.stdout:
|
|
||||||
if verbose or "Took" in line or "error" in line.lower():
|
|
||||||
print(line, end='')
|
|
||||||
print()
|
|
||||||
|
|
||||||
adderBase = '3axis_v4.h'
|
adderBase = '3axis_v4.h'
|
||||||
for name in os.listdir('Grbl_Esp32/Machines'):
|
for name in os.listdir('Grbl_Esp32/Machines'):
|
||||||
if name.startswith('add_'):
|
if name.startswith('add_'):
|
||||||
buildMachine(adderBase, name)
|
buildMachine(adderBase, addName=name, verbose=verbose)
|
||||||
else:
|
else:
|
||||||
buildMachine(name)
|
buildMachine(name, verbose=verbose)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,18 +1,20 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
# Compile Grbl_ESP32 for the machine listed on the command line, as in
|
# Compile Grbl_ESP32 for each of the machines defined in Machines/ .
|
||||||
# ./build-machine.py 3xis_v4.h
|
# Add-on files are built on top of a single base.
|
||||||
|
# This is useful for automated testing, to make sure you haven't broken something
|
||||||
|
|
||||||
# Add-ons can be built by listing both the base name and the adder, as in
|
# The output is filtered so that the only lines you see are a single
|
||||||
# ./build-machine.py 3axis_v4.h add_esc_spindle.h
|
# success or failure line for each build, plus any preceding lines that
|
||||||
|
# contain the word "error". If you need to see everything, for example to
|
||||||
# -q suppresses most messages
|
# see the details of an errored build, include -v on the command line.
|
||||||
# -u uploads the firmware to the target machine
|
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import os, subprocess, sys
|
from builder import buildMachine
|
||||||
|
import os, sys
|
||||||
|
|
||||||
|
extraArgs=None
|
||||||
|
|
||||||
cmd=['platformio','run']
|
|
||||||
verbose = '-v' in sys.argv or '-q' not in sys.argv
|
verbose = '-v' in sys.argv or '-q' not in sys.argv
|
||||||
if '-v' in sys.argv:
|
if '-v' in sys.argv:
|
||||||
sys.argv.remove('-v')
|
sys.argv.remove('-v')
|
||||||
@@ -20,30 +22,12 @@ if '-q' in sys.argv:
|
|||||||
sys.argv.remove('-q')
|
sys.argv.remove('-q')
|
||||||
if '-u' in sys.argv:
|
if '-u' in sys.argv:
|
||||||
sys.argv.remove('-u')
|
sys.argv.remove('-u')
|
||||||
cmd.append('--target=upload')
|
extraArgs = '--target=upload'
|
||||||
|
|
||||||
env = dict(os.environ)
|
|
||||||
|
|
||||||
def buildMachine(baseName, addName=None):
|
|
||||||
displayName = baseName
|
|
||||||
flags = '-DMACHINE_FILENAME=' + baseName
|
|
||||||
if addName:
|
|
||||||
displayName += ' + ' + addName
|
|
||||||
flags += ' -DMACHINE_FILENAME2=' + addName
|
|
||||||
print('Building machine ' + displayName)
|
|
||||||
env['PLATFORMIO_BUILD_FLAGS'] = flags
|
|
||||||
if verbose:
|
|
||||||
subprocess.Popen(cmd, env=env).wait()
|
|
||||||
else:
|
|
||||||
app = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, env=env)
|
|
||||||
for line in app.stdout:
|
|
||||||
if "Took" in line or 'Uploading' in line or "error" in line.lower():
|
|
||||||
print(line, end='')
|
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) == 2:
|
||||||
buildMachine(sys.argv[1], None)
|
buildMachine(sys.argv[1], addName=None, verbose=verbose, extraArgs=extraArgs)
|
||||||
elif len(sys.argv) == 3:
|
elif len(sys.argv) == 3:
|
||||||
buildMachine(sys.argv[1], sys.argv[2])
|
buildMachine(sys.argv[1], addName=sys.argv[2], verbose=verbose, extraArgs=extraArgs)
|
||||||
else:
|
else:
|
||||||
print("Usage: ./build-machine.py [-q] [-u] machine_name.h [add_name.h]")
|
print("Usage: ./build-machine.py [-q] [-u] machine_name.h [add_name.h]")
|
||||||
print(' Build for the given machine and optional add-on regardless of machine.h')
|
print(' Build for the given machine and optional add-on regardless of machine.h')
|
||||||
|
32
builder.py
Normal file
32
builder.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# This script is imported by build-machine.py and build-all.py
|
||||||
|
# It performs a platformio build with a given base machine file
|
||||||
|
# and an optional add-on file. The verbose argument controls
|
||||||
|
# whether the full output is displayed, or filtered to show
|
||||||
|
# only summary information. extraArgs can be used to perform
|
||||||
|
# uploading after compilation.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
import subprocess, os
|
||||||
|
|
||||||
|
env = dict(os.environ)
|
||||||
|
|
||||||
|
def buildMachine(baseName, addName=None, verbose=True, extraArgs=None):
|
||||||
|
cmd = ['platformio','run']
|
||||||
|
if extraArgs:
|
||||||
|
cmd.append(extraArgs)
|
||||||
|
displayName = baseName
|
||||||
|
flags = '-DMACHINE_FILENAME=' + baseName
|
||||||
|
if addName:
|
||||||
|
displayName += ' + ' + addName
|
||||||
|
flags += ' -DMACHINE_FILENAME2=' + addName
|
||||||
|
print('Building machine ' + displayName)
|
||||||
|
env['PLATFORMIO_BUILD_FLAGS'] = flags
|
||||||
|
if verbose:
|
||||||
|
app = subprocess.Popen(cmd, env=env)
|
||||||
|
else:
|
||||||
|
app = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1)
|
||||||
|
for line in app.stdout:
|
||||||
|
if "Took" in line or 'Uploading' in line or "error" in line.lower():
|
||||||
|
print(line, end='')
|
||||||
|
app.wait()
|
||||||
|
print()
|
@@ -28,4 +28,5 @@ framework = arduino
|
|||||||
upload_speed = 512000
|
upload_speed = 512000
|
||||||
board_build.partitions = min_spiffs.csv
|
board_build.partitions = min_spiffs.csv
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
build_flags = -DCORE_DEBUG_LEVEL=0
|
build_flags = -DCORE_DEBUG_LEVEL=0 -Wno-unused-variable -Wno-unused-function
|
||||||
|
src_filter = +<*.h> +<*.s> +<*.S> +<*.cpp> +<*.c> +<*.ino> +<src/> -<.git/> -<data/> -<test/> -<tests/> -<Custom/>
|
||||||
|
Reference in New Issue
Block a user