My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 __SERIAL_H__
  23. #define __SERIAL_H__
  24. #include "../inc/MarlinConfig.h"
  25. #if HAS_ABL && ENABLED(DEBUG_LEVELING_FEATURE)
  26. #include "../libs/vector_3.h"
  27. #endif
  28. /**
  29. * Define debug bit-masks
  30. */
  31. enum DebugFlags {
  32. DEBUG_NONE = 0,
  33. DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed
  34. DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output
  35. DEBUG_ERRORS = _BV(2), ///< Not implemented
  36. DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands
  37. DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
  38. DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling
  39. DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling
  40. DEBUG_ALL = 0xFF
  41. };
  42. #if ENABLED(EMERGENCY_PARSER)
  43. enum e_parser_state {
  44. state_RESET,
  45. state_N,
  46. state_M,
  47. state_M1,
  48. state_M10,
  49. state_M108,
  50. state_M11,
  51. state_M112,
  52. state_M4,
  53. state_M41,
  54. state_M410,
  55. state_IGNORE // to '\n'
  56. };
  57. #endif
  58. //todo: HAL: breaks encapsulation
  59. // For AVR only, define a serial interface based on configuration
  60. #ifdef __AVR__
  61. #ifdef USBCON
  62. #include <HardwareSerial.h>
  63. #if ENABLED(BLUETOOTH)
  64. #define MYSERIAL bluetoothSerial
  65. #else
  66. #define MYSERIAL Serial
  67. #endif // BLUETOOTH
  68. #else
  69. #include "../HAL/HAL_AVR/MarlinSerial.h"
  70. #define MYSERIAL customizedSerial
  71. #endif
  72. #endif
  73. #ifdef ARDUINO_ARCH_SAM
  74. // To pull the Serial port definitions and overrides
  75. #include "../HAL/HAL_DUE/MarlinSerial_Due.h"
  76. #endif
  77. extern uint8_t marlin_debug_flags;
  78. #define DEBUGGING(F) (marlin_debug_flags & (DEBUG_## F))
  79. extern const char echomagic[] PROGMEM;
  80. extern const char errormagic[] PROGMEM;
  81. #define SERIAL_CHAR(x) ((void)MYSERIAL.write(x))
  82. #define SERIAL_EOL() SERIAL_CHAR('\n')
  83. #define SERIAL_PROTOCOLCHAR(x) SERIAL_CHAR(x)
  84. #define SERIAL_PROTOCOL(x) (MYSERIAL.print(x))
  85. #define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y))
  86. #define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x)))
  87. #define SERIAL_PROTOCOLLN(x) do{ MYSERIAL.print(x); SERIAL_EOL(); }while(0)
  88. #define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x "\n")))
  89. #define SERIAL_PROTOCOLPAIR(pre, value) (serial_echopair_P(PSTR(pre),(value)))
  90. #define SERIAL_PROTOCOLLNPAIR(pre, value) do{ SERIAL_PROTOCOLPAIR(pre, value); SERIAL_EOL(); }while(0)
  91. #define SERIAL_ECHO_START() (serialprintPGM(echomagic))
  92. #define SERIAL_ECHO(x) SERIAL_PROTOCOL(x)
  93. #define SERIAL_ECHOPGM(x) SERIAL_PROTOCOLPGM(x)
  94. #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
  95. #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
  96. #define SERIAL_ECHOPAIR(pre,value) SERIAL_PROTOCOLPAIR(pre, value)
  97. #define SERIAL_ECHOLNPAIR(pre, value) SERIAL_PROTOCOLLNPAIR(pre, value)
  98. #define SERIAL_ECHO_F(x,y) SERIAL_PROTOCOL_F(x,y)
  99. #define SERIAL_ERROR_START() (serialprintPGM(errormagic))
  100. #define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
  101. #define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
  102. #define SERIAL_ERRORLN(x) SERIAL_PROTOCOLLN(x)
  103. #define SERIAL_ERRORLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
  104. // These macros compensate for float imprecision
  105. #define SERIAL_PROTOCOLPAIR_F(pre, value) SERIAL_PROTOCOLPAIR(pre, FIXFLOAT(value))
  106. #define SERIAL_PROTOCOLLNPAIR_F(pre, value) SERIAL_PROTOCOLLNPAIR(pre, FIXFLOAT(value))
  107. #define SERIAL_ECHOPAIR_F(pre,value) SERIAL_ECHOPAIR(pre, FIXFLOAT(value))
  108. #define SERIAL_ECHOLNPAIR_F(pre, value) SERIAL_ECHOLNPAIR(pre, FIXFLOAT(value))
  109. void serial_echopair_P(const char* s_P, const char *v);
  110. void serial_echopair_P(const char* s_P, char v);
  111. void serial_echopair_P(const char* s_P, int v);
  112. void serial_echopair_P(const char* s_P, long v);
  113. void serial_echopair_P(const char* s_P, float v);
  114. void serial_echopair_P(const char* s_P, double v);
  115. void serial_echopair_P(const char* s_P, unsigned int v);
  116. void serial_echopair_P(const char* s_P, unsigned long v);
  117. FORCE_INLINE void serial_echopair_P(const char* s_P, uint8_t v) { serial_echopair_P(s_P, (int)v); }
  118. FORCE_INLINE void serial_echopair_P(const char* s_P, bool v) { serial_echopair_P(s_P, (int)v); }
  119. FORCE_INLINE void serial_echopair_P(const char* s_P, void *v) { serial_echopair_P(s_P, (unsigned long)v); }
  120. void serial_spaces(uint8_t count);
  121. #define SERIAL_ECHO_SP(C) serial_spaces(C)
  122. #define SERIAL_ERROR_SP(C) serial_spaces(C)
  123. #define SERIAL_PROTOCOL_SP(C) serial_spaces(C)
  124. //
  125. // Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
  126. //
  127. void serialprintPGM(const char* str);
  128. #if ENABLED(DEBUG_LEVELING_FEATURE)
  129. void print_xyz(const char* prefix, const char* suffix, const float x, const float y, const float z);
  130. void print_xyz(const char* prefix, const char* suffix, const float xyz[]);
  131. #if HAS_ABL
  132. void print_xyz(const char* prefix, const char* suffix, const vector_3 &xyz);
  133. #endif
  134. #define DEBUG_POS(SUFFIX,VAR) do { \
  135. print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); }while(0)
  136. #endif
  137. #endif // __SERIAL_H__