My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. #ifndef MACROS_H
  23. #define MACROS_H
  24. // Macros to make a string from a macro
  25. #define STRINGIFY_(M) #M
  26. #define STRINGIFY(M) STRINGIFY_(M)
  27. // Macros for bit masks
  28. #define TEST(n,b) (((n)&_BV(b))!=0)
  29. #define SBI(n,b) (n |= _BV(b))
  30. #define CBI(n,b) (n &= ~_BV(b))
  31. #define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (_BV(b))
  32. // Macros for maths shortcuts
  33. #define RADIANS(d) ((d)*M_PI/180.0)
  34. #define DEGREES(r) ((r)*180.0/M_PI)
  35. // Macros to contrain values
  36. #define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
  37. #define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
  38. // Macros to support option testing
  39. #define _CAT(a, ...) a ## __VA_ARGS__
  40. #define SWITCH_ENABLED_false 0
  41. #define SWITCH_ENABLED_true 1
  42. #define SWITCH_ENABLED_0 0
  43. #define SWITCH_ENABLED_1 1
  44. #define SWITCH_ENABLED_ 1
  45. #define ENABLED(b) _CAT(SWITCH_ENABLED_, b)
  46. #define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b))
  47. #define NUMERIC(a) ((a) >= '0' && '9' >= (a))
  48. #define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-')
  49. #define COUNT(a) (sizeof(a)/sizeof(*a))
  50. // Macros for adding
  51. #define INC_0 1
  52. #define INC_1 2
  53. #define INC_2 3
  54. #define INC_3 4
  55. #define INC_4 5
  56. #define INC_5 6
  57. #define INC_6 7
  58. #define INC_7 8
  59. #define INC_8 9
  60. #define INCREMENT_(n) INC_ ##n
  61. #define INCREMENT(n) INCREMENT_(n)
  62. // Macros for subtracting
  63. #define DEC_1 0
  64. #define DEC_2 1
  65. #define DEC_3 2
  66. #define DEC_4 3
  67. #define DEC_5 4
  68. #define DEC_6 5
  69. #define DEC_7 6
  70. #define DEC_8 7
  71. #define DEC_9 8
  72. #define DECREMENT_(n) DEC_ ##n
  73. #define DECREMENT(n) DECREMENT_(n)
  74. #define PIN_EXISTS(PN) (defined(PN ##_PIN) && PN ##_PIN >= 0)
  75. #define PENDING(NOW,SOON) ((long)(NOW-(SOON))<0)
  76. #define ELAPSED(NOW,SOON) (!PENDING(NOW,SOON))
  77. #define NOOP do{}while(0)
  78. #endif //__MACROS_H