Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/20140
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Nov 18, 2020
2 parents 5331c11 + 5768ee0 commit be6df82
Show file tree
Hide file tree
Showing 129 changed files with 1,680 additions and 1,249 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,4 @@ jobs:

- name: Run ${{ matrix.test-platform }} Tests
run: |
# Inline tests script
chmod +x buildroot/bin/*
chmod +x buildroot/tests/*
export PATH=./buildroot/bin/:./buildroot/tests/:${PATH}
run_tests . ${{ matrix.test-platform }}
make tests-single-ci TEST_TARGET=${{ matrix.test-platform }}
56 changes: 56 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
help:
@echo "Tasks for local development:"
@echo "* tests-single-ci: Run a single test from inside the CI"
@echo "* tests-single-local: Run a single test locally"
@echo "* tests-single-local-docker: Run a single test locally, using docker-compose"
@echo "* tests-all-local: Run all tests locally"
@echo "* tests-all-local-docker: Run all tests locally, using docker-compose"
@echo "* setup-local-docker: Setup local docker-compose"
@echo ""
@echo "Options for testing:"
@echo " TEST_TARGET Set when running tests-single-*, to select the"
@echo " test. If you set it to ALL it will run all "
@echo " tests, but some of them are broken: use "
@echo " tests-all-* instead to run only the ones that "
@echo " run on GitHub CI"
@echo " ONLY_TEST Limit tests to only those that contain this, or"
@echo " the index of the test (1-based)"
@echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value"
@echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:"
@echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!"
.PHONY: help

tests-single-ci:
export GIT_RESET_HARD=true
$(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET)
.PHONY: tests-single-ci

tests-single-local:
@if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local" ; return 1; fi
chmod +x buildroot/bin/*
chmod +x buildroot/tests/*
export PATH=./buildroot/bin/:./buildroot/tests/:${PATH} \
&& export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
&& run_tests . $(TEST_TARGET) "$(ONLY_TEST)"
.PHONY: tests-single-local

tests-single-local-docker:
@if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
docker-compose run --rm marlin $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)"
.PHONY: tests-single-local-docker

tests-all-local:
chmod +x buildroot/bin/*
chmod +x buildroot/tests/*
export PATH=./buildroot/bin/:./buildroot/tests/:${PATH} \
&& export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
&& for TEST_TARGET in $$(./get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
.PHONY: tests-all-local

tests-all-local-docker:
docker-compose run --rm marlin $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
.PHONY: tests-all-local-docker

setup-local-docker:
docker-compose build
.PHONY: setup-local-docker
8 changes: 4 additions & 4 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2358,10 +2358,10 @@

#define TOUCH_SCREEN_CALIBRATION

//#define XPT2046_X_CALIBRATION 12316
//#define XPT2046_Y_CALIBRATION -8981
//#define XPT2046_X_OFFSET -43
//#define XPT2046_Y_OFFSET 257
//#define TOUCH_CALIBRATION_X 12316
//#define TOUCH_CALIBRATION_Y -8981
//#define TOUCH_OFFSET_X -43
//#define TOUCH_OFFSET_Y 257

#if ENABLED(TFT_COLOR_UI)
//#define SINGLE_TOUCH_NAVIGATION
Expand Down
6 changes: 5 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@

// Default x offset in duplication mode (typically set to half print bed width)
#define DEFAULT_DUPLICATION_X_OFFSET 100

// Default action to execute following M605 mode change commands. Typically G28X to apply new mode.
//#define EVENT_GCODE_IDEX_AFTER_MODECHANGE "G28X"
#endif

// Activate a solenoid on the active extruder with M380. Disable all with M381.
Expand Down Expand Up @@ -1082,6 +1085,7 @@
//#define PROBE_OFFSET_WIZARD
#if ENABLED(PROBE_OFFSET_WIZARD)
#define PROBE_OFFSET_START -4.0 // Estimated nozzle-to-probe Z offset, plus a little extra
//#define PROBE_OFFSET_WIZARD_XY_POS XY_CENTER // Set a convenient position to do the measurement
#endif
#endif

Expand Down Expand Up @@ -3444,7 +3448,7 @@
#define GANTRY_CALIBRATION_FEEDRATE 500 // Feedrate for correction move
//#define GANTRY_CALIBRATION_TO_MIN // Enable to calibrate Z in the MIN direction

//#define GANTRY_CALIBRATION_SAFE_POSITION { X_CENTER, Y_CENTER } // Safe position for nozzle
//#define GANTRY_CALIBRATION_SAFE_POSITION XY_CENTER // Safe position for nozzle
//#define GANTRY_CALIBRATION_XY_PARK_FEEDRATE 3000 // XY Park Feedrate - MMM
//#define GANTRY_CALIBRATION_COMMANDS_PRE ""
#define GANTRY_CALIBRATION_COMMANDS_POST "G28" // G28 highly recommended to ensure an accurate position
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/tft/xpt2046.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "../../../inc/MarlinConfig.h"

#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046
#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS

#include "xpt2046.h"
#include <SPI.h>
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/HAL/STM32F1/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ SPIClass::SPIClass(uint32_t spi_num) {
_currentSetting->state = SPI_STATE_IDLE;
}

SPIClass::SPIClass(int8_t mosi, int8_t miso, int8_t sclk, int8_t ssel) {
SPIClass::SPIClass(int8_t mosi, int8_t miso, int8_t sclk, int8_t ssel) : SPIClass(1) {
#if BOARD_NR_SPI >= 1
if (mosi == BOARD_SPI1_MOSI_PIN) SPIClass(1);
if (mosi == BOARD_SPI1_MOSI_PIN) setModule(1);
#endif
#if BOARD_NR_SPI >= 2
if (mosi == BOARD_SPI2_MOSI_PIN) SPIClass(2);
if (mosi == BOARD_SPI2_MOSI_PIN) setModule(2);
#endif
#if BOARD_NR_SPI >= 3
if (mosi == BOARD_SPI3_MOSI_PIN) SPIClass(3);
if (mosi == BOARD_SPI3_MOSI_PIN) setModule(3);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/tft/xpt2046.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "../../../inc/MarlinConfig.h"

#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046
#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS

#include "xpt2046.h"
#include <SPI.h>
Expand Down
8 changes: 6 additions & 2 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#include "sd/cardreader.h"

#include "lcd/marlinui.h"
#if HAS_TOUCH_XPT2046
#if HAS_TOUCH_BUTTONS
#include "lcd/touch/touch_buttons.h"
#endif

Expand Down Expand Up @@ -1109,7 +1109,7 @@ void setup() {
SETUP_RUN(ethernet.init());
#endif

#if HAS_TOUCH_XPT2046
#if HAS_TOUCH_BUTTONS
SETUP_RUN(touch.init());
#endif

Expand Down Expand Up @@ -1307,6 +1307,10 @@ void setup() {
SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided
#endif

#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI)
ui.check_touch_calibration();
#endif

marlin_state = MF_RUNNING;

SETUP_LOG("setup() completed.");
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/core/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
#define BOARD_BTT_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_MKS_SGEN_L_V2 2509 // MKS SGEN_L V2 (Power outputs: Hotend0, Hotend1, Bed, Fan)
#define BOARD_BTT_SKR_E3_TURBO 2510 // BigTreeTech SKR E3 Turbo (Power outputs: Hotend0, Hotend1, Bed, Fan0, Fan1)
#define BOARD_FLY_CDY 2511 // FLY_CDY (Power outputs: Hotend0, Hotend1, Hotend2, Bed, Fan0, Fan1, Fan2)

//
// SAM3X8E ARM Cortex M3
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/feature/bedlevel/abl/abl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ void print_bilinear_leveling_grid() {
#define LINEAR_EXTRAPOLATION(E, I) ((E) * 2 - (I))
float bed_level_virt_coord(const uint8_t x, const uint8_t y) {
uint8_t ep = 0, ip = 1;
if (x > GRID_MAX_POINTS_X + 1 || y > GRID_MAX_POINTS_Y + 1) {
// The requested point requires extrapolating two points beyond the mesh.
// These values are only requested for the edges of the mesh, which are always an actual mesh point,
// and do not require interpolation. When interpolation is not needed, this "Mesh + 2" point is
// cancelled out in bed_level_virt_cmr and does not impact the result. Return 0.0 rather than
// making this function more complex by extrapolating two points.
return 0.0;
}
if (!x || x == ABL_TEMP_POINTS_X - 1) {
if (x) {
ep = GRID_MAX_POINTS_X - 1;
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/feature/leds/printer_event_leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ PrinterEventLEDs printerEventLEDs;
uint8_t PrinterEventLEDs::old_intensity = 0;

inline uint8_t pel_intensity(const float &start, const float &current, const float &target) {
if (uint16_t(start) == uint16_t(target)) return 255;
return (uint8_t)map(constrain(current, start, target), start, target, 0.f, 255.f);
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/G26.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ inline bool turn_on_heaters() {
inline bool prime_nozzle() {

const feedRate_t fr_slow_e = planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0f;
#if HAS_LCD_MENU && !HAS_TOUCH_XPT2046 // ui.button_pressed issue with touchscreen
#if HAS_LCD_MENU && !HAS_TOUCH_BUTTONS // ui.button_pressed issue with touchscreen
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
float Total_Prime = 0.0;
#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/control/M605.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
}
idex_set_parked(false);
set_duplication_enabled(false);

#ifdef EVENT_GCODE_IDEX_AFTER_MODECHANGE
gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_IDEX_AFTER_MODECHANGE));
#endif
}
else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default
dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
* Will still block Gcodes if M511 is disabled, in which case the printer should be unlocked via LCD Menu
*/
#if ENABLED(PASSWORD_FEATURE)
if (password.is_locked && !(parser.command_letter == 'M' && parser.codenum == 511)) {
if (password.is_locked && !parser.is_command('M', 511)) {
SERIAL_ECHO_MSG(STR_PRINTER_LOCKED);
return;
}
Expand Down
13 changes: 11 additions & 2 deletions Marlin/src/gcode/lcd/M995.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,23 @@
#if ENABLED(TOUCH_SCREEN_CALIBRATION)

#include "../gcode.h"
#include "../../lcd/menu/menu.h"

#if ENABLED(TFT_LVGL_UI)
#include "../../lcd/extui/lib/mks_ui/draw_touch_calibration.h"
#else
#include "../../lcd/menu/menu.h"
#endif

/**
* M995: Touch screen calibration for TFT display
*/
void GcodeSuite::M995() {

ui.goto_screen(touch_screen_calibration);
#if ENABLED(TFT_LVGL_UI)
lv_draw_touch_calibration_screen();
#else
ui.goto_screen(touch_screen_calibration);
#endif

}

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ char *GCodeParser::command_ptr,
*GCodeParser::string_arg,
*GCodeParser::value_ptr;
char GCodeParser::command_letter;
int GCodeParser::codenum;
uint16_t GCodeParser::codenum;

#if ENABLED(USE_GCODE_SUBCODES)
uint8_t GCodeParser::subcode;
Expand Down Expand Up @@ -270,7 +270,7 @@ void GCodeParser::parse(char *p) {

// Special handling for M32 [P] !/path/to/file.g#
// The path must be the last parameter
if (param == '!' && letter == 'M' && codenum == 32) {
if (param == '!' && is_command('M', 32)) {
string_arg = p; // Name starts after '!'
char * const lb = strchr(p, '#'); // Already seen '#' as SD char (to pause buffering)
if (lb) *lb = '\0'; // Safe to mark the end of the filename
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/gcode/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class GCodeParser {
static char *command_ptr, // The command, so it can be echoed
*string_arg, // string of command line
command_letter; // G, M, or T
static int codenum; // 123
static uint16_t codenum; // 123
#if ENABLED(USE_GCODE_SUBCODES)
static uint8_t subcode; // .1
#endif
Expand Down Expand Up @@ -244,6 +244,9 @@ class GCodeParser {
static bool chain();
#endif

// Test whether the parsed command matches the input
static inline bool is_command(const char ltr, const uint16_t num) { return command_letter == ltr && codenum == num; }

// The code value pointer was set
FORCE_INLINE static bool has_value() { return !!value_ptr; }

Expand Down
13 changes: 8 additions & 5 deletions Marlin/src/gcode/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,14 @@ inline void process_stream_char(const char c, uint8_t &sis, char (&buff)[MAX_CMD
* keep sensor readings going and watchdog alive.
*/
inline bool process_line_done(uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind) {
sis = PS_NORMAL;
buff[ind] = 0;
if (ind) { ind = 0; return false; }
thermalManager.manage_heater();
return true;
sis = PS_NORMAL; // "Normal" Serial Input State
buff[ind] = '\0'; // Of course, I'm a Terminator.
const bool is_empty = (ind == 0); // An empty line?
if (is_empty)
thermalManager.manage_heater(); // Keep sensors satisfied
else
ind = 0; // Start a new line
return is_empty; // Inform the caller
}

/**
Expand Down
20 changes: 18 additions & 2 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,24 @@
// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
#undef TOUCH_SCREEN
#undef TOUCH_SCREEN_CALIBRATION
#if !HAS_TFT_LVGL_UI
#define HAS_TOUCH_XPT2046 1
#define HAS_TOUCH_BUTTONS 1
#endif
#endif

// XPT2046_** Compatibility
#if !(defined(TOUCH_CALIBRATION_X) || defined(TOUCH_CALIBRATION_Y) || defined(TOUCH_OFFSET_X) || defined(TOUCH_OFFSET_Y) || defined(TOUCH_ORIENTATION))
#if defined(XPT2046_X_CALIBRATION) && defined(XPT2046_Y_CALIBRATION) && defined(XPT2046_X_OFFSET) && defined(XPT2046_Y_OFFSET)
#define TOUCH_CALIBRATION_X XPT2046_X_CALIBRATION
#define TOUCH_CALIBRATION_Y XPT2046_Y_CALIBRATION
#define TOUCH_OFFSET_X XPT2046_X_OFFSET
#define TOUCH_OFFSET_Y XPT2046_Y_OFFSET
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#else
#define TOUCH_CALIBRATION_X 0
#define TOUCH_CALIBRATION_Y 0
#define TOUCH_OFFSET_X 0
#define TOUCH_OFFSET_Y 0
#define TOUCH_ORIENTATION TOUCH_ORIENTATION_NONE
#endif
#endif
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@

// Touch Screen or "Touch Buttons" need XPT2046 pins
// but they use different components
#if EITHER(HAS_TFT_XPT2046, HAS_TOUCH_XPT2046)
#if EITHER(HAS_TFT_XPT2046, HAS_TOUCH_BUTTONS)
#define NEED_TOUCH_PINS 1
#endif

Expand Down
Loading

0 comments on commit be6df82

Please sign in to comment.