My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

minmax.h 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. #undef MIN
  24. #undef MAX
  25. // Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
  26. #define _NUM_ARGS(_0,_24_,_23,_22,_21,_20,_19,_18,_17,_16,_15,_14,_13,_12,_11,_10,_9,_8,_7,_6,_5,_4,_3,_2,_1,N,...) N
  27. #define NUM_ARGS(V...) _NUM_ARGS(0,V,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
  28. #ifdef __cplusplus
  29. #ifndef _MINMAX_H_
  30. #define _MINMAX_H_
  31. extern "C++" {
  32. // C++11 solution that is standards compliant. Return type is deduced automatically
  33. template <class L, class R> static inline constexpr auto MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
  34. return lhs < rhs ? lhs : rhs;
  35. }
  36. template <class L, class R> static inline constexpr auto MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
  37. return lhs > rhs ? lhs : rhs;
  38. }
  39. template<class T, class ... Ts> static inline constexpr const T MIN(T V, Ts... Vs) { return MIN(V, MIN(Vs...)); }
  40. template<class T, class ... Ts> static inline constexpr const T MAX(T V, Ts... Vs) { return MAX(V, MAX(Vs...)); }
  41. }
  42. #endif
  43. #else
  44. #define MIN_2(a,b) ((a)<(b)?(a):(b))
  45. #define MIN_3(a,...) MIN_2(a,MIN_2(__VA_ARGS__))
  46. #define MIN_4(a,...) MIN_2(a,MIN_3(__VA_ARGS__))
  47. #define MIN_5(a,...) MIN_2(a,MIN_4(__VA_ARGS__))
  48. #define MIN_6(a,...) MIN_2(a,MIN_5(__VA_ARGS__))
  49. #define MIN_7(a,...) MIN_2(a,MIN_6(__VA_ARGS__))
  50. #define MIN_8(a,...) MIN_2(a,MIN_7(__VA_ARGS__))
  51. #define MIN_9(a,...) MIN_2(a,MIN_8(__VA_ARGS__))
  52. #define MIN_10(a,...) MIN_2(a,MIN_9(__VA_ARGS__))
  53. #define __MIN_N(N, ...) MIN_##N(__VA_ARGS__)
  54. #define _MIN_N(N, ...) __MIN_N(N,__VA_ARGS__)
  55. #define MIN(...) _MIN_N(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
  56. #define MAX_2(a,b) ((a)>(b)?(a):(b))
  57. #define MAX_3(a,...) MAX_2(a,MAX_2(__VA_ARGS__))
  58. #define MAX_4(a,...) MAX_2(a,MAX_3(__VA_ARGS__))
  59. #define MAX_5(a,...) MAX_2(a,MAX_4(__VA_ARGS__))
  60. #define MAX_6(a,...) MAX_2(a,MAX_5(__VA_ARGS__))
  61. #define MAX_7(a,...) MAX_2(a,MAX_6(__VA_ARGS__))
  62. #define MAX_8(a,...) MAX_2(a,MAX_7(__VA_ARGS__))
  63. #define MAX_9(a,...) MAX_2(a,MAX_8(__VA_ARGS__))
  64. #define MAX_10(a,...) MAX_2(a,MAX_9(__VA_ARGS__))
  65. #define __MAX_N(N, ...) MAX_##N(__VA_ARGS__)
  66. #define _MAX_N(N, ...) __MAX_N(N,__VA_ARGS__)
  67. #define MAX(...) _MAX_N(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
  68. #endif