1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-19 12:51:47 +02:00

Merge pull request #359 from bdring/Devt

Devt
This commit is contained in:
bdring
2020-03-23 15:09:06 +01:00
committed by GitHub
11 changed files with 310 additions and 57 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
.pioenvs/ .pioenvs/
.pio/
Thumbs.db Thumbs.db
.DS_Store .DS_Store
*.orig *.orig

View File

@@ -1,47 +1,24 @@
sudo: false sudo: false
language: python
language: bash
os: os:
- linux - linux
before_script: cache:
- "export DISPLAY=:99.0" directories:
- sleep 3 # give xvfb some time to start - "~/.platformio"
- wget http://downloads.arduino.cc/arduino-1.8.5-linux64.tar.xz
- tar xf arduino-1.8.5-linux64.tar.xz install:
- mv arduino-1.8.5 $HOME/arduino_ide - pip install -U platformio
- cd $HOME/arduino_ide/hardware
- mkdir esp32 script:
- cd esp32 - ./configure-features.py -e WIFI -d BLUETOOTH -v
- git clone https://github.com/espressif/arduino-esp32.git esp32 - ./build-machine.py test_drive.h
- cd esp32/tools - ./configure-features.py -e BLUETOOTH -d WIFI -v
- python get.py - ./build-machine.py test_drive.h
- cd .. - ./configure-features.py -e BLUETOOTH WIFI -v
- mv $TRAVIS_BUILD_DIR/libraries/ESP32SSDP $HOME/arduino_ide/libraries/ - ./build-all.py
- mv $TRAVIS_BUILD_DIR/libraries/arduinoWebSockets $HOME/arduino_ide/libraries/
script:
- cd $TRAVIS_BUILD_DIR
- source command.sh
- export PATH="$HOME/arduino_ide:$PATH"
- arduino --board esp32:esp32:esp32:PartitionScheme=min_spiffs,FlashFreq=40 --pref compiler.warning_level=all --save-prefs
- sed -n '48,72p;73q' $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- sed -i "s/\/\/#define ENABLE_BLUETOOTH/#define ENABLE_BLUETOOTH/g" $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- sed -i "s/#define ENABLE_BLUETOOTH/\/\/#define ENABLE_BLUETOOTH/g" $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- sed -i "s/\/\/#define ENABLE_WIFI/#define ENABLE_WIFI/g" $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- sed -n '48,72p;73q' $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- build_sketch $TRAVIS_BUILD_DIR/Grbl_Esp32/Grbl_Esp32.ino
- sed -i "s/\/\/#define ENABLE_BLUETOOTH/#define ENABLE_BLUETOOTH/g" $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- sed -i "s/#define ENABLE_WIFI/\/\/#define ENABLE_WIFI/g" $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- sed -n '48,72p;73q' $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- build_sketch $TRAVIS_BUILD_DIR/Grbl_Esp32/Grbl_Esp32.ino
- sed -i "s/\/\/#define ENABLE_BLUETOOTH/#define ENABLE_BLUETOOTH/g" $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- sed -i "s/\/\/#define ENABLE_WIFI/#define ENABLE_WIFI/g" $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- sed -n '48,72p;73q' $TRAVIS_BUILD_DIR/Grbl_Esp32/config.h
- build_sketch $TRAVIS_BUILD_DIR/Grbl_Esp32/Grbl_Esp32.ino
notifications: notifications:
email: email:
on_success: change on_success: change

View File

@@ -45,12 +45,13 @@ void setup() {
serial_init(); // Setup serial baud rate and interrupts serial_init(); // Setup serial baud rate and interrupts
grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Grbl_ESP32 Ver %s Date %s", GRBL_VERSION, GRBL_VERSION_BUILD); // print grbl_esp32 verion info grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Grbl_ESP32 Ver %s Date %s", GRBL_VERSION, GRBL_VERSION_BUILD); // print grbl_esp32 verion info
grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Compiled with ESP32 SDK:%s", ESP.getSdkVersion()); // print the SDK version grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Compiled with ESP32 SDK:%s", ESP.getSdkVersion()); // print the SDK version
#ifdef MACHINE_NAME // show the map name at startup // show the map name at startup
#ifdef MACHINE_EXTRA #ifdef MACHINE_NAME
#define MACHINE_STRING MACHINE_NAME MACHINE_EXTRA #ifdef MACHINE_EXTRA
#else #define MACHINE_STRING MACHINE_NAME MACHINE_EXTRA
#define MACHINE_STRING MACHINE_NAME #else
#endif #define MACHINE_STRING MACHINE_NAME
#endif
grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Using machine:%s", MACHINE_STRING); grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Using machine:%s", MACHINE_STRING);
#endif #endif
settings_init(); // Load Grbl settings from EEPROM settings_init(); // Load Grbl settings from EEPROM

View File

@@ -114,7 +114,7 @@ Some features should not be changed. See notes below.
//Connect to your local AP with these credentials //Connect to your local AP with these credentials
//#define CONNECT_TO_SSID "your SSID" //#define CONNECT_TO_SSID "your SSID"
//#define SSID_PASSWORD "your SSID password" //#define SSID_PASSWORD "your SSID password"
//CONFIGURE_EYECATCH_BEGIN (DO NOT MODIFY THIS LINE)
#define ENABLE_BLUETOOTH // enable bluetooth #define ENABLE_BLUETOOTH // enable bluetooth
#define ENABLE_SD_CARD // enable use of SD Card to run jobs #define ENABLE_SD_CARD // enable use of SD Card to run jobs
@@ -134,7 +134,7 @@ Some features should not be changed. See notes below.
#define ENABLE_CAPTIVE_PORTAL #define ENABLE_CAPTIVE_PORTAL
//#define ENABLE_AUTHENTICATION //#define ENABLE_AUTHENTICATION
//CONFIGURE_EYECATCH_END (DO NOT MODIFY THIS LINE)
#define NAMESPACE "GRBL" #define NAMESPACE "GRBL"
#define ESP_RADIO_MODE "RADIO_MODE" #define ESP_RADIO_MODE "RADIO_MODE"

9
build-all.py Normal file → Executable file
View File

@@ -21,9 +21,14 @@ cmd = ['platformio','run']
verbose = '-v' in sys.argv verbose = '-v' in sys.argv
numErrors = 0
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, addName=name, verbose=verbose) exitCode = buildMachine(adderBase, addName=name, verbose=verbose)
else: else:
buildMachine(name, verbose=verbose) exitCode = buildMachine(name, verbose=verbose)
if exitCode != 0:
numErrors += 1
sys.exit(numErrors)

21
build-all.sh Normal file → Executable file
View File

@@ -4,7 +4,7 @@
# for every machine configuration in the Machines/ directory. # for every machine configuration in the Machines/ directory.
# It is useful for automated testing. # It is useful for automated testing.
trap "echo; exit" SIGINT trap "echo; exit 255" SIGINT
# With -v, show all output. Otherwise, show just the result # With -v, show all output. Otherwise, show just the result
if [ "$1" = "-v" ]; then if [ "$1" = "-v" ]; then
@@ -12,18 +12,29 @@ if [ "$1" = "-v" ]; then
else else
FILTER="grep error\|Took" FILTER="grep error\|Took"
fi fi
set -o pipefail
NUM_ERRORS=0
BuildMachine () { BuildMachine () {
basename=$1 basename=$1
addname=$2 addname=$2
BF="-DMACHINE_FILENAME=$basename" BF="\"-DMACHINE_FILENAME=$basename\""
displayname=$basename displayname=$basename
if [ "$addname" != "" ] if [ "$addname" != "" ]
then then
BF="$BF -DMACHINE_FILENAME2=$addname" BF="$BF \"-DMACHINE_FILENAME2=$addname\""
displayname="$basename + $addname" displayname="$basename + $addname"
fi fi
echo "Building machine $displayname" echo "Building machine $displayname"
PLATFORMIO_BUILD_FLAGS=\'$BF\' platformio run 2>&1 | $FILTER PLATFORMIO_BUILD_FLAGS=$BF platformio run 2>&1 | $FILTER
local re=$?
# check result
if [ $re -ne 0 ]; then
echo "Failed to build machine $displayname"
echo
NUM_ERRORS=$(( NUM_ERRORS + 1 ))
return $re
fi
echo echo
} }
@@ -40,3 +51,5 @@ do
adder=`basename $file` adder=`basename $file`
BuildMachine $base $adder BuildMachine $base $adder
done done
exit $NUM_ERRORS

7
build-machine.py Normal file → Executable file
View File

@@ -24,12 +24,15 @@ if '-u' in sys.argv:
sys.argv.remove('-u') sys.argv.remove('-u')
extraArgs = '--target=upload' extraArgs = '--target=upload'
exitCode = 255
if len(sys.argv) == 2: if len(sys.argv) == 2:
buildMachine(sys.argv[1], addName=None, verbose=verbose, extraArgs=extraArgs) exitCode = buildMachine(sys.argv[1], addName=None, verbose=verbose, extraArgs=extraArgs)
elif len(sys.argv) == 3: elif len(sys.argv) == 3:
buildMachine(sys.argv[1], addName=sys.argv[2], verbose=verbose, extraArgs=extraArgs) exitCode = 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')
print(' -q suppresses most messages') print(' -q suppresses most messages')
print(' -u uploads to the target after compilation') print(' -u uploads to the target after compilation')
sys.exit(exitCode)

1
builder.py Normal file → Executable file
View File

@@ -30,3 +30,4 @@ def buildMachine(baseName, addName=None, verbose=True, extraArgs=None):
print(line, end='') print(line, end='')
app.wait() app.wait()
print() print()
return app.returncode

0
command.sh Normal file → Executable file
View File

243
configure-features.py Executable file
View File

@@ -0,0 +1,243 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Grbl_Esp32 configurator
# Copyright (C) 2020 Michiyasu Odaki
#
# This is useful for automated testing, to make sure you haven't broken something
#
# 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_Esp32. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os, sys, argparse, re
configDirName = r'Grbl_Esp32'
configFileName = r'config.h'
validFeatureList = [
'BLUETOOTH',
'WIFI',
'SD_CARD',
'HTTP',
'OTA',
'TELNET',
'TELNET_WELCOME_MSG',
'MDNS',
'SSDP',
'NOTIFICATIONS',
'SERIAL2SOCKET_IN',
'SERIAL2SOCKET_OUT',
'CAPTIVE_PORTAL',
'AUTHENTICATION'
]
eyecatchBeginString = 'CONFIGURE_EYECATCH_BEGIN'
eyecatchEndString = 'CONFIGURE_EYECATCH_END'
enablePrefix = 'ENABLE_'
def printValidFeatureList():
print("valid feature names:")
for n in sorted(validFeatureList):
print(" " + n)
def usage(parser):
parser.print_usage()
printValidFeatureList()
sys.exit(255)
def parseArgs(defaultConfigPath):
# Argument parser (-h is also available)
parser = argparse.ArgumentParser(description='Configure Grbl_ESP32 features')
parser.add_argument('-v', '--verbose', action='store_true')
parser.add_argument('-c', '--configfile', default=defaultConfigPath)
parser.add_argument('-e', '--enable', nargs='*'
,help='specify feature name(ex. WIFI)'
#, choices=validFeatureList
)
parser.add_argument('-d', '--disable', nargs='*'
,help='specify feature name(ex. BLUETOOTH)'
#,choices=validFeatureList
)
return parser.parse_args(), parser
def isValidFeature(feature):
if feature:
if feature.upper() in validFeatureList:
return True #valid
return False #invalid
def checkFeatureList(optname, features, verbose=False):
if features:
for n in features:
if isValidFeature(n) is True:
#if verbose:
# print("valid " + optname + " feature: " + n)
pass
else:
print("unknown " + optname + " feature: " + n)
return -1
else:
#if verbose:
# print(optname + " is not specified")
return 0
return len(features)
def resolveConflicts(high_priority, low_priority):
if low_priority:
for n in low_priority[:]:
if n in high_priority:
low_priority.remove(n)
return
def readConfig(path):
# Read config.h to memory
try:
f = open(path)
except IOError:
print("unable to open file for read: " + path)
sys.exit(255)
else:
try:
src = f.readlines()
except IOError:
print("file read error: " + path)
f.close()
sys.exit(255)
else:
f.close()
return src
def writeConfig(path, buf):
try:
f = open(path, 'w')
except IOError:
print("unable to open file for write: " + path)
sys.exit(255)
else:
try:
src = f.write(buf)
except IOError:
print("file write error: " + path)
f.close()
sys.exit(255)
else:
f.close()
def changeConfig(src, enabled, disabled, verbose=False):
dst = ""
regstart = re.compile(r'^\s*//\s*' + eyecatchBeginString)
regend = re.compile(r'^\s*//\s*' + eyecatchEndString)
state = 0;
for line in src:
if state == 0:
# out of the defines block to modify
if regstart.match(line):
state = 1
dst += line
elif state == 1:
# in the defines block to modify
if regend.match(line):
# end of block found
state = 2
dst += line
else:
dstLine = ""
if len(enabled) > 0:
for name in enabled:
s = enablePrefix + name
m = re.match(r'^s*//\s*#define\s+(' + s + r'.*)$', line)
if m:
dstLine = "#define " + m.group(1) + '\n'
break
if len(disabled) > 0:
for name in disabled:
s = enablePrefix + name
m = re.match(r'^\s*#define\s+' + s + r'.*$', line)
if m:
dstLine = "//" + line
break
if len(dstLine) != 0:
dst += dstLine
if verbose:
print(dstLine.rstrip())
else:
dst += line
if verbose:
print(line.rstrip())
elif state == 2:
dst += line
if state != 2:
print("EYECATCH pair not found. Cancel changes.")
sys.exit(255)
return dst
def main():
# Concatinate dir and file
configFilePath = os.path.join(configDirName, configFileName)
# Parse arguments
args, parser = parseArgs(configFilePath)
# Set params to local variables
verbose = args.verbose
configFilePath = args.configfile
# Copy and remove duplicates from enable/disable list
enabledFeatures = []
disabledFeatures = []
if args.enable:
enabledFeatures = sorted(set(args.enable), key=args.enable.index)
if args.disable:
disabledFeatures = sorted(set(args.disable), key=args.disable.index)
# If both enable and disable are specified, treat as enable
# (Remove items from 2nd param if same item in 1st param)
resolveConflicts(enabledFeatures, disabledFeatures)
# Verification (whether or not to use "choice" with argparse)
numEnables = checkFeatureList("-e", enabledFeatures, verbose)
numDisables = checkFeatureList("-d", disabledFeatures, verbose)
#if verbose:
# print("enables: ", numEnables)
# print(enabledFeatures)
# print("disables: ", numDisables)
# print(disabledFeatures)
# print("config file: " + configFilePath)
# Final checking about args
if numEnables < 0 or numDisables < 0 or (numEnables == 0 and numDisables == 0):
usage(parser)
# Check if the target file exists
configFilePathAbs = os.path.abspath(configFilePath)
if verbose:
print("Config path: " + configFilePathAbs)
print()
if not os.path.isfile(configFilePathAbs):
print("config file not found: " + configFilePathAbs)
sys.exit(255)
# read config file
src = readConfig(configFilePathAbs)
# Change the specified settings
dst = changeConfig(src, enabledFeatures, disabledFeatures, verbose)
# Write back
writeConfig(configFilePathAbs, dst)
sys.exit(0)
if __name__ == "__main__":
main()

View File

@@ -21,12 +21,21 @@ lib_deps_builtin =
WiFiClientSecure WiFiClientSecure
[env:nodemcu-32s] [env:nodemcu-32s]
lib_deps = TMCStepper lib_deps =
TMCStepper
arduinoWebSockets
ESP32SSPD
platform = espressif32 platform = espressif32
board = nodemcu-32s board = nodemcu-32s
framework = arduino 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 -Wno-unused-variable -Wno-unused-function build_flags =
src_filter = +<*.h> +<*.s> +<*.S> +<*.cpp> +<*.c> +<*.ino> +<src/> -<.git/> -<data/> -<test/> -<tests/> -<Custom/> ;-DMACHINE_FILENAME=test_drive.h ;Remove ";" from the beginning of this line and specify the machine file
-DCORE_DEBUG_LEVEL=0
-Wno-unused-variable
-Wno-unused-function
src_filter =
+<*.h> +<*.s> +<*.S> +<*.cpp> +<*.c> +<*.ino> +<src/>
-<.git/> -<data/> -<test/> -<tests/> -<Custom/>