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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. #define MAX_NAME_LENGTH 39 // one place to specify the format of all the sources of names
  23. // "-" left justify, "39" minimum width of name, pad with blanks
  24. /**
  25. * This routine minimizes RAM usage by creating a FLASH resident array to
  26. * store the pin names, pin numbers and analog/digital flag.
  27. *
  28. * Creating the array in FLASH is a two pass process. The first pass puts the
  29. * name strings into FLASH. The second pass actually creates the array.
  30. *
  31. * Both passes use the same pin list. The list contains two macro names. The
  32. * actual macro definitions are changed depending on which pass is being done.
  33. *
  34. */
  35. // first pass - put the name strings into FLASH
  36. #define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const char ENTRY_NAME[] PROGMEM = { PIN_NAME };
  37. #define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER)
  38. #define REPORT_NAME_DIGITAL(COUNTER, NAME) _ADD_PIN(#NAME, COUNTER)
  39. #define REPORT_NAME_ANALOG(COUNTER, NAME) _ADD_PIN(#NAME, COUNTER)
  40. #include "pinsDebug_list.h"
  41. #line 47
  42. // manually add pins that have names that are macros which don't play well with these macros
  43. #if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY || defined(ARDUINO_ARCH_SAM))
  44. static const char RXD_NAME[] PROGMEM = { "RXD" };
  45. static const char TXD_NAME[] PROGMEM = { "TXD" };
  46. #endif
  47. /////////////////////////////////////////////////////////////////////////////
  48. // second pass - create the array
  49. #undef _ADD_PIN_2
  50. #undef _ADD_PIN
  51. #undef REPORT_NAME_DIGITAL
  52. #undef REPORT_NAME_ANALOG
  53. #define _ADD_PIN_2(ENTRY_NAME, NAME, IS_DIGITAL) { ENTRY_NAME, NAME, IS_DIGITAL },
  54. #define _ADD_PIN(NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2(entry_NAME_##COUNTER, NAME, IS_DIGITAL)
  55. #define REPORT_NAME_DIGITAL(COUNTER, NAME) _ADD_PIN(NAME, COUNTER, true)
  56. #define REPORT_NAME_ANALOG(COUNTER, NAME) _ADD_PIN(analogInputToDigitalPin(NAME), COUNTER, false)
  57. typedef struct {
  58. PGM_P const name;
  59. pin_t pin;
  60. bool is_digital;
  61. } PinInfo;
  62. const PinInfo pin_array[] PROGMEM = {
  63. /**
  64. * [pin name] [pin number] [is digital or analog] 1 = digital, 0 = analog
  65. * Each entry takes up 6 bytes in FLASH:
  66. * 2 byte pointer to location of the name string
  67. * 2 bytes containing the pin number
  68. * analog pin numbers were convereted to digital when the array was created
  69. * 2 bytes containing the digital/analog bool flag
  70. */
  71. // manually add pins ...
  72. #if SERIAL_PORT == 0
  73. #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM))
  74. { RXD_NAME, 0, true },
  75. { TXD_NAME, 1, true },
  76. #elif AVR_ATmega1284_FAMILY
  77. { RXD_NAME, 8, true },
  78. { TXD_NAME, 9, true },
  79. #endif
  80. #endif
  81. #include "pinsDebug_list.h"
  82. #line 99
  83. };
  84. #include HAL_PATH(../HAL, pinsDebug.h) // get the correct support file for this CPU
  85. #ifndef M43_NEVER_TOUCH
  86. #define M43_NEVER_TOUCH(Q) false
  87. #endif
  88. static void print_input_or_output(const bool isout) {
  89. serialprintPGM(isout ? PSTR("Output = ") : PSTR("Input = "));
  90. }
  91. // pretty report with PWM info
  92. inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = false, const char *start_string = "") {
  93. char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements
  94. bool found = false, multi_name_pin = false;
  95. for (uint8_t x = 0; x < COUNT(pin_array); x++) { // scan entire array and report all instances of this pin
  96. if (GET_ARRAY_PIN(x) == pin) {
  97. if (found) multi_name_pin = true;
  98. found = true;
  99. if (!multi_name_pin) { // report digitial and analog pin number only on the first time through
  100. sprintf_P(buffer, PSTR("%sPIN: "), start_string); // digital pin number
  101. SERIAL_ECHO(buffer);
  102. PRINT_PIN(pin);
  103. PRINT_PORT(pin);
  104. if (IS_ANALOG(pin)) {
  105. sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); // analog pin number
  106. SERIAL_ECHO(buffer);
  107. }
  108. else SERIAL_ECHO_SP(8); // add padding if not an analog pin
  109. }
  110. else {
  111. SERIAL_CHAR('.');
  112. SERIAL_ECHO_SP(MULTI_NAME_PAD + strlen(start_string)); // add padding if not the first instance found
  113. }
  114. PRINT_ARRAY_NAME(x);
  115. if (extended) {
  116. if (pin_is_protected(pin) && !ignore)
  117. SERIAL_ECHOPGM("protected ");
  118. else {
  119. #if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
  120. if (pin == 46 || pin == 47) {
  121. if (pin == 46) {
  122. print_input_or_output(IS_OUTPUT(46));
  123. SERIAL_CHAR('0' + READ(46));
  124. }
  125. else if (pin == 47) {
  126. print_input_or_output(IS_OUTPUT(47));
  127. SERIAL_CHAR('0' + READ(47));
  128. }
  129. }
  130. else
  131. #endif
  132. {
  133. if (!GET_ARRAY_IS_DIGITAL(x)) {
  134. sprintf_P(buffer, PSTR("Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)));
  135. SERIAL_ECHO(buffer);
  136. }
  137. else {
  138. if (!GET_PINMODE(pin)) {
  139. //pinMode(pin, INPUT_PULLUP); // make sure input isn't floating - stopped doing this
  140. // because this could interfere with inductive/capacitive
  141. // sensors (high impedance voltage divider) and with PT100 amplifier
  142. print_input_or_output(false);
  143. SERIAL_ECHO(digitalRead_mod(pin));
  144. }
  145. else if (pwm_status(pin)) {
  146. // do nothing
  147. }
  148. else {
  149. print_input_or_output(true);
  150. SERIAL_ECHO(digitalRead_mod(pin));
  151. }
  152. }
  153. if (!multi_name_pin && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report
  154. }
  155. }
  156. }
  157. SERIAL_EOL();
  158. } // end of IF
  159. } // end of for loop
  160. if (!found) {
  161. sprintf_P(buffer, PSTR("%sPIN: "), start_string);
  162. SERIAL_ECHO(buffer);
  163. PRINT_PIN(pin);
  164. PRINT_PORT(pin);
  165. if (IS_ANALOG(pin)) {
  166. sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); // analog pin number
  167. SERIAL_ECHO(buffer);
  168. }
  169. else
  170. SERIAL_ECHO_SP(8); // add padding if not an analog pin
  171. SERIAL_ECHOPGM("<unused/unknown>");
  172. if (extended) {
  173. #if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
  174. if (pin == 46 || pin == 47) {
  175. SERIAL_ECHO_SP(12);
  176. if (pin == 46) {
  177. print_input_or_output(IS_OUTPUT(46));
  178. SERIAL_CHAR('0' + READ(46));
  179. }
  180. else {
  181. print_input_or_output(IS_OUTPUT(47));
  182. SERIAL_CHAR('0' + READ(47));
  183. }
  184. }
  185. else
  186. #endif
  187. {
  188. if (GET_PINMODE(pin)) {
  189. SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16);
  190. print_input_or_output(true);
  191. SERIAL_ECHO(digitalRead_mod(pin));
  192. }
  193. else {
  194. if (IS_ANALOG(pin)) {
  195. sprintf_P(buffer, PSTR(" Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)));
  196. SERIAL_ECHO(buffer);
  197. SERIAL_ECHOPGM(" ");
  198. }
  199. else
  200. SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); // add padding if not an analog pin
  201. print_input_or_output(false);
  202. SERIAL_ECHO(digitalRead_mod(pin));
  203. }
  204. //if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin
  205. if (extended) pwm_details(pin); // report PWM capabilities only if doing an extended report
  206. }
  207. }
  208. SERIAL_EOL();
  209. }
  210. }