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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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. /**
  24. * This module is off by default, but can be enabled to facilitate the display of
  25. * extra debug information during code development.
  26. *
  27. * Just connect up 5V and GND to give it power, then connect up the pins assigned
  28. * in Configuration_adv.h. For example, on the Re-ARM you could use:
  29. *
  30. * #define MAX7219_CLK_PIN 77
  31. * #define MAX7219_DIN_PIN 78
  32. * #define MAX7219_LOAD_PIN 79
  33. *
  34. * max7219.init() is called automatically at startup, and then there are a number of
  35. * support functions available to control the LEDs in the 8x8 grid.
  36. *
  37. * If you are using the Max7219 matrix for firmware debug purposes in time sensitive
  38. * areas of the code, please be aware that the orientation (rotation) of the display can
  39. * affect the speed. The Max7219 can update a single column fairly fast. It is much
  40. * faster to do a Max7219_Set_Column() with a rotation of 90 or 270 degrees than to do
  41. * a Max7219_Set_Row(). The opposite is true for rotations of 0 or 180 degrees.
  42. */
  43. #ifndef MAX7219_ROTATE
  44. #define MAX7219_ROTATE 0
  45. #endif
  46. #define _ROT ((MAX7219_ROTATE + 360) % 360)
  47. #ifndef MAX7219_NUMBER_UNITS
  48. #define MAX7219_NUMBER_UNITS 1
  49. #endif
  50. #define MAX7219_LINES (8 * (MAX7219_NUMBER_UNITS))
  51. //
  52. // MAX7219 registers
  53. //
  54. #define max7219_reg_noop 0x00
  55. #define max7219_reg_digit0 0x01
  56. #define max7219_reg_digit1 0x02
  57. #define max7219_reg_digit2 0x03
  58. #define max7219_reg_digit3 0x04
  59. #define max7219_reg_digit4 0x05
  60. #define max7219_reg_digit5 0x06
  61. #define max7219_reg_digit6 0x07
  62. #define max7219_reg_digit7 0x08
  63. #define max7219_reg_decodeMode 0x09
  64. #define max7219_reg_intensity 0x0A
  65. #define max7219_reg_scanLimit 0x0B
  66. #define max7219_reg_shutdown 0x0C
  67. #define max7219_reg_displayTest 0x0F
  68. class Max7219 {
  69. public:
  70. static uint8_t led_line[MAX7219_LINES];
  71. Max7219() {}
  72. static void init();
  73. static void register_setup();
  74. static void putbyte(uint8_t data);
  75. static void pulse_load();
  76. // Set a single register (e.g., a whole native row)
  77. static void send(const uint8_t reg, const uint8_t data);
  78. // Refresh all units
  79. static inline void refresh() { for (uint8_t i = 0; i < 8; i++) refresh_line(i); }
  80. // Suspend / resume updates to the LED unit
  81. // Use these methods to speed up multiple changes
  82. // or to apply updates from interrupt context.
  83. static inline void suspend() { suspended++; }
  84. static inline void resume() { suspended--; suspended |= 0x80; }
  85. // Update a single native line on all units
  86. static void refresh_line(const uint8_t line);
  87. // Update a single native line on just one unit
  88. static void refresh_unit_line(const uint8_t line);
  89. // Set a single LED by XY coordinate
  90. static void led_set(const uint8_t x, const uint8_t y, const bool on);
  91. static void led_on(const uint8_t x, const uint8_t y);
  92. static void led_off(const uint8_t x, const uint8_t y);
  93. static void led_toggle(const uint8_t x, const uint8_t y);
  94. // Set all LEDs in a single column
  95. static void set_column(const uint8_t col, const uint32_t val);
  96. static void clear_column(const uint8_t col);
  97. // Set all LEDs in a single row
  98. static void set_row(const uint8_t row, const uint32_t val);
  99. static void clear_row(const uint8_t row);
  100. // 16 and 32 bit versions of Row and Column functions
  101. // Multiple rows and columns will be used to display the value if
  102. // the array of matrix LED's is too narrow to accomplish the goal
  103. static void set_rows_16bits(const uint8_t y, uint32_t val);
  104. static void set_rows_32bits(const uint8_t y, uint32_t val);
  105. static void set_columns_16bits(const uint8_t x, uint32_t val);
  106. static void set_columns_32bits(const uint8_t x, uint32_t val);
  107. // Quickly clear the whole matrix
  108. static void clear();
  109. // Quickly fill the whole matrix
  110. static void fill();
  111. // Apply custom code to update the matrix
  112. static void idle_tasks();
  113. private:
  114. static uint8_t suspended;
  115. static void error(const char * const func, const int32_t v1, const int32_t v2=-1);
  116. static void noop();
  117. static void set(const uint8_t line, const uint8_t bits);
  118. static void send_row(const uint8_t row);
  119. static void send_column(const uint8_t col);
  120. static void mark16(const uint8_t y, const uint8_t v1, const uint8_t v2);
  121. static void range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const uint8_t oh, const uint8_t nh);
  122. static void quantity16(const uint8_t y, const uint8_t ov, const uint8_t nv);
  123. #ifdef MAX7219_INIT_TEST
  124. static void test_pattern();
  125. static void run_test_pattern();
  126. static void start_test_pattern();
  127. #endif
  128. };
  129. extern Max7219 max7219;