Skip to content

Commit af6dac3

Browse files
committed
πŸ§‘β€πŸ’» Other code patches
1 parent 108f0b0 commit af6dac3

File tree

123 files changed

+2872
-2091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+2872
-2091
lines changed

β€ŽMarlin/src/core/drivers.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
#define HAS_TMC220x 1
121121
#endif
122122

123+
#if HAS_DRIVER(TMC26X)
124+
#define HAS_TMC26X 1
125+
#endif
126+
123127
#define AXIS_IS_TMC(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
124128
|| AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) \
125129
|| AXIS_DRIVER_TYPE(A,TMC2660) \
@@ -184,10 +188,3 @@
184188
#if ANY_AXIS_HAS(SPI)
185189
#define HAS_TMC_SPI 1
186190
#endif
187-
188-
//
189-
// TMC26XX Stepper Drivers
190-
//
191-
#if HAS_DRIVER(TMC26X)
192-
#define HAS_TMC26X 1
193-
#endif

β€ŽMarlin/src/core/language.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,12 @@
323323
//
324324
// Endstop Names used by Endstops::report_states
325325
//
326-
#define STR_X_MIN "x_min"
327-
#define STR_X_MAX "x_max"
328-
#define STR_X2_MIN "x2_min"
329-
#define STR_X2_MAX "x2_max"
326+
#if HAS_X_AXIS
327+
#define STR_X_MIN "x_min"
328+
#define STR_X_MAX "x_max"
329+
#define STR_X2_MIN "x2_min"
330+
#define STR_X2_MAX "x2_max"
331+
#endif
330332

331333
#if HAS_Y_AXIS
332334
#define STR_Y_MIN "y_min"

β€ŽMarlin/src/core/macros.h

+55-3
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,12 @@
263263
// Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc.
264264
#define PLUS_TERN0(O,A) _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '<nul>'
265265
#define MINUS_TERN0(O,A) _TERN(_ENA_1(O),,- (A)) // OPTION ? '- (A)' : '<nul>'
266+
#define MUL_TERN1(O,A) _TERN(_ENA_1(O),,* (A)) // OPTION ? '* (A)' : '<nul>'
267+
#define DIV_TERN1(O,A) _TERN(_ENA_1(O),,/ (A)) // OPTION ? '/ (A)' : '<nul>'
266268
#define SUM_TERN(O,B,A) ((B) PLUS_TERN0(O,A)) // ((B) (OPTION ? '+ (A)' : '<nul>'))
267269
#define DIFF_TERN(O,B,A) ((B) MINUS_TERN0(O,A)) // ((B) (OPTION ? '- (A)' : '<nul>'))
270+
#define MUL_TERN(O,B,A) ((B) MUL_TERN1(O,A)) // ((B) (OPTION ? '* (A)' : '<nul>'))
271+
#define DIV_TERN(O,B,A) ((B) DIV_TERN1(O,A)) // ((B) (OPTION ? '/ (A)' : '<nul>'))
268272

269273
#define IF_ENABLED TERN_
270274
#define IF_DISABLED(O,A) TERN(O,,A)
@@ -434,6 +438,8 @@
434438
extern "C++" {
435439

436440
// C++11 solution that is standards compliant. Return type is deduced automatically
441+
template <class N> static constexpr N _MIN(const N val) { return val; }
442+
template <class N> static constexpr N _MAX(const N val) { return val; }
437443
template <class L, class R> static constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
438444
return lhs < rhs ? lhs : rhs;
439445
}
@@ -453,9 +459,9 @@
453459
FORCE_INLINE constexpr T operator|(T x, T y) { return static_cast<T>(static_cast<int>(x) | static_cast<int>(y)); } \
454460
FORCE_INLINE constexpr T operator^(T x, T y) { return static_cast<T>(static_cast<int>(x) ^ static_cast<int>(y)); } \
455461
FORCE_INLINE constexpr T operator~(T x) { return static_cast<T>(~static_cast<int>(x)); } \
456-
FORCE_INLINE T & operator&=(T &x, T y) { return x &= y; } \
457-
FORCE_INLINE T & operator|=(T &x, T y) { return x |= y; } \
458-
FORCE_INLINE T & operator^=(T &x, T y) { return x ^= y; }
462+
FORCE_INLINE T & operator&=(T &x, T y) { x = x & y; return x; } \
463+
FORCE_INLINE T & operator|=(T &x, T y) { x = x | y; return x; } \
464+
FORCE_INLINE T & operator^=(T &x, T y) { x = x ^ y; return x; }
459465

460466
// C++11 solution that is standard compliant. <type_traits> is not available on all platform
461467
namespace Private {
@@ -467,6 +473,39 @@
467473

468474
template <typename T, typename ... Args> struct first_type_of { typedef T type; };
469475
template <typename T> struct first_type_of<T> { typedef T type; };
476+
477+
// remove const/volatile type qualifiers
478+
template<typename T> struct remove_const { typedef T type; };
479+
template<typename T> struct remove_const<T const> { typedef T type; };
480+
481+
template<typename T> struct remove_volatile { typedef T type; };
482+
template<typename T> struct remove_volatile<T volatile> { typedef T type; };
483+
484+
template<typename T> struct remove_cv { typedef typename remove_const<typename remove_volatile<T>::type>::type type; };
485+
486+
// test if type is integral
487+
template<typename> struct _is_integral { enum { value = false }; };
488+
template<> struct _is_integral<unsigned char> { enum { value = true }; };
489+
template<> struct _is_integral<unsigned short> { enum { value = true }; };
490+
template<> struct _is_integral<unsigned int> { enum { value = true }; };
491+
template<> struct _is_integral<unsigned long> { enum { value = true }; };
492+
template<> struct _is_integral<unsigned long long> { enum { value = true }; };
493+
template<> struct _is_integral<char> { enum { value = true }; };
494+
template<> struct _is_integral<short> { enum { value = true }; };
495+
template<> struct _is_integral<int> { enum { value = true }; };
496+
template<> struct _is_integral<long> { enum { value = true }; };
497+
template<> struct _is_integral<long long> { enum { value = true }; };
498+
template<typename T> struct is_integral : public _is_integral<typename remove_cv<T>::type> {};
499+
}
500+
501+
// enum type check and regression to its underlying integral.
502+
namespace Private {
503+
template<typename T> struct is_enum { enum { value = __is_enum(T) }; };
504+
505+
template<typename T, bool = is_enum<T>::value> struct _underlying_type { using type = __underlying_type(T); };
506+
template<typename T> struct _underlying_type<T, false> { };
507+
508+
template<typename T> struct underlying_type : public _underlying_type<T> { };
470509
}
471510

472511
// C++11 solution using SFINAE to detect the existence of a member in a class at compile time.
@@ -726,6 +765,19 @@
726765
#define RREPEAT2_S(S,N,OP,V...) EVAL1024(_RREPEAT2(S,SUB##S(N),OP,V))
727766
#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V)
728767

768+
// Emit a list of N OP(I) items with ascending counter.
769+
#define _REPLIST(_RPT_I,_RPT_N,_RPT_OP) \
770+
_RPT_OP(_RPT_I) \
771+
IF_ELSE(SUB1(_RPT_N)) \
772+
( , DEFER2(__REPLIST)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
773+
( /* Do nothing */ )
774+
#define __REPLIST() _REPLIST
775+
776+
// Repeat a macro, comma-separated, passing S...N-1.
777+
#define REPLIST_S(S,N,OP) EVAL(_REPLIST(S,SUB##S(N),OP))
778+
#define REPLIST(N,OP) REPLIST_S(0,N,OP)
779+
#define REPLIST_1(N,OP) REPLIST_S(1,INCREMENT(N),OP)
780+
729781
// Call OP(A) with each item as an argument
730782
#define _MAP(_MAP_OP,A,V...) \
731783
_MAP_OP(A) \

β€ŽMarlin/src/core/multi_language.h

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ typedef const char Language_Str[];
6464

6565
#if NUM_LANGUAGES > 1
6666
#define HAS_MULTI_LANGUAGE 1
67+
#if HAS_MARLINUI_MENU
68+
#define HAS_MENU_MULTI_LANGUAGE 1
69+
#endif
6770
#define GET_TEXT(MSG) ( \
6871
ui.language == 4 ? GET_LANG(LCD_LANGUAGE_5)::MSG : \
6972
ui.language == 3 ? GET_LANG(LCD_LANGUAGE_4)::MSG : \

β€ŽMarlin/src/core/serial.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
#include "../feature/ethernet.h"
2828
#endif
2929

30-
uint8_t marlin_debug_flags = MARLIN_DEBUG_NONE;
30+
// Echo commands to the terminal by default in dev mode
31+
uint8_t marlin_debug_flags = TERN(MARLIN_DEV_MODE, MARLIN_DEBUG_ECHO, MARLIN_DEBUG_NONE);
3132

3233
// Commonly-used strings in serial output
3334
PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C");

β€ŽMarlin/src/core/serial.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ extern uint8_t marlin_debug_flags;
125125
#define SERIAL_IMPL SERIAL_LEAF_1
126126
#endif
127127

128-
#define SERIAL_OUT(WHAT, V...) (void)SERIAL_IMPL.WHAT(V)
129-
130128
#define PORT_REDIRECT(p) _PORT_REDIRECT(1,p)
131129
#define PORT_RESTORE() _PORT_RESTORE(1)
132130
#define SERIAL_PORTMASK(P) SerialMask::from(P)
@@ -149,10 +147,8 @@ template <typename T>
149147
void SERIAL_ECHO(T x) { SERIAL_IMPL.print(x); }
150148

151149
// Wrapper for ECHO commands to interpret a char
152-
typedef struct SerialChar { char c; SerialChar(char n) : c(n) { } } serial_char_t;
153150
inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); }
154-
#define AS_CHAR(C) serial_char_t(C)
155-
#define AS_DIGIT(C) AS_CHAR('0' + (C))
151+
#define AS_DIGIT(n) C('0' + (n))
156152

157153
template <typename T>
158154
void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); }

β€ŽMarlin/src/core/serial_base.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include "../inc/MarlinConfigPre.h"
2525

26+
#include <stddef.h> // for size_t
27+
2628
#if ENABLED(EMERGENCY_PARSER)
2729
#include "../feature/e_parser.h"
2830
#endif

0 commit comments

Comments
Β (0)