Skip to content

Commit

Permalink
Merge branch 'bugfix-2.0.x' of https://github.com/MarlinFirmware/Marlin
Browse files Browse the repository at this point in the history
… into bugfix-2.0.x
  • Loading branch information
crysxd committed Jul 21, 2020
2 parents 2790a58 + 3aecd92 commit a9201dc
Show file tree
Hide file tree
Showing 16 changed files with 325 additions and 98 deletions.
4 changes: 3 additions & 1 deletion Marlin/src/HAL/SAMD51/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
// --------------------------------------------------------------------------
// Includes
// --------------------------------------------------------------------------

#include "../../inc/MarlinConfig.h"
#include "ServoTimers.h" // for SERVO_TC

// --------------------------------------------------------------------------
// Local defines
Expand All @@ -39,7 +41,7 @@ const tTimerConfig TimerConfig[NUM_HARDWARE_TIMERS+1] = {
{ {.pTc=TC0}, TC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2)
{ {.pTc=TC1}, TC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers)
{ {.pTc=TC2}, TC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5)
{ {.pTc=TC3}, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (no interrupts used)
{ {.pTc=TC3}, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (assigned priority 1)
{ {.pTc=TC4}, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial (no interrupts used)
{ {.pTc=TC5}, TC5_IRQn, TC_PRIORITY(5) },
{ {.pTc=TC6}, TC6_IRQn, TC_PRIORITY(6) },
Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/HAL/SAMD51/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ typedef uint32_t hal_timer_t;
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)

#define TC_PRIORITY(t) (t == STEP_TIMER_NUM || t == PULSE_TIMER_NUM) ? 2 \
: (t == TEMP_TIMER_NUM) ? 6 \
#define TC_PRIORITY(t) t == SERVO_TC ? 1 \
: (t == STEP_TIMER_NUM || t == PULSE_TIMER_NUM) ? 2 \
: (t == TEMP_TIMER_NUM) ? 6 \
: 7

#define _TC_HANDLER(t) void TC##t##_Handler()
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/core/drivers.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@
#define HAS_TMC_SPI 1
#endif

//
// TMC26XX Stepper Drivers
//
#if HAS_DRIVER(TMC26X)
#define HAS_TMC26X 1
#endif

//
// L64XX Stepper Drivers
//
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/feature/touch/xpt2046.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@

#include "xpt2046.h"
#include "../../inc/MarlinConfig.h"
#include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
#if ENABLED(FSMC_GRAPHICAL_TFT)
#include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
#endif


/*
* Draw and Touch processing
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2205,12 +2205,15 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
+ ENABLED(MKS_12864OLED_SSD1306) \
+ ENABLED(U8GLIB_SH1106_EINSTART) \
+ ENABLED(OVERLORD_OLED) \
+ ENABLED(FYSETC_242_OLED_12864) \
+ ENABLED(DGUS_LCD_UI_ORIGIN) \
+ ENABLED(DGUS_LCD_UI_FYSETC) \
+ ENABLED(DGUS_LCD_UI_HIPRECY) \
+ ENABLED(MALYAN_LCD) \
+ ENABLED(TOUCH_UI_FTDI_EVE) \
+ ENABLED(FSMC_GRAPHICAL_TFT)
+ ENABLED(FSMC_GRAPHICAL_TFT) \
+ ENABLED(TFT_LVGL_UI) \
+ ENABLED(SPI_GRAPHICAL_TFT)
#error "Please select no more than one LCD controller option."
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2020-07-20"
#define STRING_DISTRIBUTION_DATE "2020-07-21"
#endif

/**
Expand Down
4 changes: 0 additions & 4 deletions Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@

#include <string.h>

#ifndef LCD_CLASS
#include <LiquidCrystal.h>
#define LCD_CLASS LiquidCrystal
#endif
extern LCD_CLASS lcd;

int lcd_glyph_height() { return 1; }
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
volatile uint16_t *p_index;
//int res;
char *cur_name;
uint16_t Color;

cur_name = strrchr(path, '/');
card.openFileRead(cur_name);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) {
#endif

#if USE_XPT2046
#ifndef XPT2046_HOR_RES 480
#ifndef XPT2046_HOR_RES
#define XPT2046_HOR_RES 480
#endif
#ifndef XPT2046_VER_RES
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2099,11 +2099,11 @@ uint32_t Stepper::block_phase_isr() {
#if ENABLED(ADAPTIVE_STEP_SMOOTHING)
uint8_t oversampling = 0; // Assume no axis smoothing (via oversampling)
// Decide if axis smoothing is possible
uint32_t max_rate = current_block->nominal_rate; // Get the maximum rate (maximum event speed)
uint32_t max_rate = current_block->nominal_rate; // Get the step event rate
while (max_rate < MIN_STEP_ISR_FREQUENCY) { // As long as more ISRs are possible...
max_rate <<= 1; // Try to double the rate
if (max_rate >= MAX_STEP_ISR_FREQUENCY_1X) break; // Don't exceed the estimated ISR limit
++oversampling; // Increase the oversampling (used for left-shift)
if (max_rate < MIN_STEP_ISR_FREQUENCY) // Don't exceed the estimated ISR limit
++oversampling; // Increase the oversampling (used for left-shift)
}
oversampling_factor = oversampling; // For all timer interval calculations
#else
Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/module/stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@
#define MAX_STEP_ISR_FREQUENCY_2X ((F_CPU) / ISR_EXECUTION_CYCLES(2))
#define MAX_STEP_ISR_FREQUENCY_1X ((F_CPU) / ISR_EXECUTION_CYCLES(1))

// The minimum allowable frequency for step smoothing will be 1/10 of the maximum nominal frequency (in Hz)
#define MIN_STEP_ISR_FREQUENCY MAX_STEP_ISR_FREQUENCY_1X
// The minimum step ISR rate used by ADAPTIVE_STEP_SMOOTHING to target 50% CPU usage
// This does not account for the possibility of multi-stepping.
// Perhaps DISABLE_MULTI_STEPPING should be required with ADAPTIVE_STEP_SMOOTHING.
#define MIN_STEP_ISR_FREQUENCY (MAX_STEP_ISR_FREQUENCY_1X / 2)

//
// Stepper class definition
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/stepper/TMC26X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//
// TMC26X Driver objects and inits
//
#if HAS_DRIVER(TMC26X)
#if HAS_TMC26X

#include "TMC26X.h"

Expand Down Expand Up @@ -141,4 +141,4 @@ void tmc26x_init_to_defaults() {
#endif
}

#endif // TMC26X
#endif // HAS_TMC26X
6 changes: 3 additions & 3 deletions Marlin/src/pins/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
#elif MB(MKS_ROBIN_MINI)
#include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini
#elif MB(MKS_ROBIN_NANO)
#include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano env:mks_robin_nano35
#include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano
#elif MB(MKS_ROBIN_LITE)
#include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite
#elif MB(BTT_SKR_MINI_V1_1)
Expand Down Expand Up @@ -541,9 +541,9 @@
#elif MB(CCROBOT_MEEB_3DP)
#include "stm32f1/pins_CCROBOT_MEEB_3DP.h" // STM32F1 env:STM32F103RC_meeb
#elif MB(CHITU3D_V5)
#include "stm32f1/pins_CHITU3D_V5.h" // STM32F1 env:chitu_f103 env:chitu_v5_gpio_init env:chitu_f103_lvgl
#include "stm32f1/pins_CHITU3D_V5.h" // STM32F1 env:chitu_f103 env:chitu_v5_gpio_init
#elif MB(CHITU3D_V6)
#include "stm32f1/pins_CHITU3D_V6.h" // STM32F1 env:chitu_f103 env:chitu_f103_lvgl
#include "stm32f1/pins_CHITU3D_V6.h" // STM32F1 env:chitu_f103
#elif MB(CREALITY_V4)
#include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RET6_creality
#elif MB(TRIGORILLA_PRO)
Expand Down
50 changes: 50 additions & 0 deletions buildroot/share/PlatformIO/scripts/common-features-dependencies.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once

/**
* The purpose of this file is just include Marlin Configuration files,
* to discover which FEATURES are enabled, without any HAL include.
* Used by common-features-dependencies.py
*/

#ifndef __MARLIN_FIRMWARE__
#define __MARLIN_FIRMWARE__
#endif

//
// Prefix header to acquire configurations
//
#include <stdint.h>

#include "../../../../Marlin/src/core/boards.h"
#include "../../../../Marlin/src/core/macros.h"
#include "../../../../Marlin/Configuration.h"

#include "../../../../Marlin/Version.h"

#include "../../../../Marlin/src/inc/Conditionals_LCD.h"

#include "../../../../Marlin/src/core/drivers.h"
#include "../../../../Marlin/Configuration_adv.h"

#include "../../../../Marlin/src/inc/Conditionals_adv.h"
160 changes: 160 additions & 0 deletions buildroot/share/PlatformIO/scripts/common-features-dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#
# common-features-dependencies.py
# Convenience script to check dependencies and add libs and sources for Marlin Enabled Features
#
import subprocess
import os
import re
try:
import configparser
except ImportError:
import ConfigParser as configparser
from platformio.managers.package import PackageManager

Import("env")

FEATURE_DEPENDENCIES = {}

def load_config():
config = configparser.ConfigParser()
config.read("platformio.ini")
items = config.items('features')
for key in items:
deps = re.sub(',\\s*', '\n', key[1]).strip().split('\n')
if not key[0].upper() in FEATURE_DEPENDENCIES:
FEATURE_DEPENDENCIES[key[0].upper()] = {
'lib_deps': []
}
for dep in deps:
parts = dep.split('=')
name = parts.pop(0)
rest = '='.join(parts)
if name == 'extra_scripts':
FEATURE_DEPENDENCIES[key[0].upper()]['extra_scripts'] = rest
elif name == 'src_filter':
FEATURE_DEPENDENCIES[key[0].upper()]['src_filter'] = rest
else:
FEATURE_DEPENDENCIES[key[0].upper()]['lib_deps'] += [dep]

def install_features_dependencies():
load_config()
for feature in FEATURE_DEPENDENCIES:
if not env.MarlinFeatureIsEnabled(feature):
continue

if 'lib_deps' in FEATURE_DEPENDENCIES[feature]:
print("Adding lib_deps for %s... " % feature)

# deps to add
deps_to_add = {}
for dep in FEATURE_DEPENDENCIES[feature]['lib_deps']:
name, _, _ = PackageManager.parse_pkg_uri(dep)
deps_to_add[name] = dep

# first check if the env already have the dep
deps = env.GetProjectOption("lib_deps")
for dep in deps:
name, _, _ = PackageManager.parse_pkg_uri(dep)
if name in deps_to_add:
del deps_to_add[name]

# check if we need ignore any lib
lib_ignore = env.GetProjectOption("lib_ignore")
for dep in deps:
name, _, _ = PackageManager.parse_pkg_uri(dep)
if name in deps_to_add:
del deps_to_add[name]

# any left?
if len(deps_to_add) <= 0:
continue

# add only the missing deps
proj = env.GetProjectConfig()
proj.set("env:" + env["PIOENV"], "lib_deps", deps + list(deps_to_add.values()))

if 'extra_scripts' in FEATURE_DEPENDENCIES[feature]:
print("Executing extra_scripts for %s... " % feature)
env.SConscript(FEATURE_DEPENDENCIES[feature]['extra_scripts'], exports="env")

if 'src_filter' in FEATURE_DEPENDENCIES[feature]:
print("Adding src_filter for %s... " % feature)
proj = env.GetProjectConfig()
src_filter = env.GetProjectOption("src_filter")

# first we need to remove the references to the same folder
my_srcs = re.findall( r'[+-](<.*?>)', FEATURE_DEPENDENCIES[feature]['src_filter'])
cur_srcs = re.findall( r'[+-](<.*?>)', src_filter[0])
for d in my_srcs:
if d in cur_srcs:
src_filter[0] = re.sub(r'[+-]' + d, '', src_filter[0])

src_filter[0] = FEATURE_DEPENDENCIES[feature]['src_filter'] + ' ' + src_filter[0]
proj.set("env:" + env["PIOENV"], "src_filter", src_filter)
env.Replace(SRC_FILTER=src_filter)

# search the current compiler, considering the OS
def search_compiler():
if env['PLATFORM'] == 'win32':
# the first path have the compiler
compiler_path = None
for path in env['ENV']['PATH'].split(';'):
if re.search(r'platformio\\packages.*\\bin', path):
compiler_path = path
break
if compiler_path == None:
print("Could not find the g++ path")
return None

print(compiler_path)
for file in os.listdir(compiler_path):
if file.endswith("g++.exe"):
return file
print("Could not find the g++")
return None
else:
return env.get('CXX')


# load marlin features
def load_marlin_features():
if "MARLIN_FEATURES" in env:
return

# procces defines
# print(env.Dump())
build_flags = env.get('BUILD_FLAGS')
build_flags = env.ParseFlagsExtended(build_flags)

cxx = search_compiler()
cmd = [cxx]

# build flags from board.json
# if 'BOARD' in env:
# cmd += [env.BoardConfig().get("build.extra_flags")]
for s in build_flags['CPPDEFINES']:
if isinstance(s, tuple):
cmd += ['-D' + s[0] + '=' + str(s[1])]
else:
cmd += ['-D' + s]
# cmd += ['-w -dM -E -x c++ Marlin/src/inc/MarlinConfigPre.h']
cmd += ['-w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-features-dependencies.h']
cmd = ' '.join(cmd)
print(cmd)
define_list = subprocess.check_output(cmd, shell=True).splitlines()
marlin_features = {}
for define in define_list:
feature = define[8:].strip().decode().split(' ')
feature, definition = feature[0], ' '.join(feature[1:])
marlin_features[feature] = definition
env["MARLIN_FEATURES"] = marlin_features

def MarlinFeatureIsEnabled(env, feature):
load_marlin_features()
return feature in env["MARLIN_FEATURES"]

# add a method for others scripts to check if a feature is enabled
env.AddMethod(MarlinFeatureIsEnabled)

# install all dependencies for features enabled in Configuration.h
install_features_dependencies()
Loading

0 comments on commit a9201dc

Please sign in to comment.