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.

M7219.cpp 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #include "../../../inc/MarlinConfigPre.h"
  23. #if ENABLED(MAX7219_GCODE)
  24. #include "../../gcode.h"
  25. #include "../../../feature/max7219.h"
  26. /**
  27. * M7219: Control the Max7219 LED matrix
  28. *
  29. * I - Initialize (clear) the matrix
  30. * F - Fill the matrix (set all bits)
  31. * P - Dump the led_line[] array values
  32. * C<column> - Set a column to the bitmask given by 'V' (Units 0-3 in portrait layout)
  33. * R<row> - Set a row to the bitmask given by 'V' (Units 0-3 in landscape layout)
  34. * X<pos> - X index of an LED to set or toggle
  35. * Y<pos> - Y index of an LED to set or toggle
  36. * V<value> - LED on/off state or row/column bitmask (8, 16, 24, or 32-bits)
  37. * ('C' / 'R' can be used to update up to 4 units at once)
  38. *
  39. * Directly set a native matrix row to the 8-bit value 'V':
  40. * D<line> - Display line (0..7)
  41. * U<unit> - Unit index (0..MAX7219_NUMBER_UNITS-1)
  42. */
  43. void GcodeSuite::M7219() {
  44. if (parser.seen('I')) {
  45. max7219.register_setup();
  46. max7219.clear();
  47. }
  48. if (parser.seen('F')) max7219.fill();
  49. const uint32_t v = parser.ulongval('V');
  50. if (parser.seenval('R')) {
  51. const uint8_t r = parser.value_byte();
  52. max7219.set_row(r, v);
  53. }
  54. else if (parser.seenval('C')) {
  55. const uint8_t c = parser.value_byte();
  56. max7219.set_column(c, v);
  57. }
  58. else if (parser.seenval('X') || parser.seenval('Y')) {
  59. const uint8_t x = parser.byteval('X'), y = parser.byteval('Y');
  60. if (parser.seenval('V'))
  61. max7219.led_set(x, y, v > 0);
  62. else
  63. max7219.led_toggle(x, y);
  64. }
  65. else if (parser.seen('D')) {
  66. const uint8_t uline = parser.value_byte() & 0x7,
  67. line = uline + (parser.byteval('U') << 3);
  68. if (line < MAX7219_LINES) {
  69. max7219.led_line[line] = v;
  70. return max7219.refresh_line(line);
  71. }
  72. }
  73. if (parser.seen('P')) {
  74. LOOP_L_N(r, MAX7219_LINES) {
  75. SERIAL_ECHOPGM("led_line[");
  76. if (r < 10) SERIAL_CHAR(' ');
  77. SERIAL_ECHO(int(r));
  78. SERIAL_ECHOPGM("]=");
  79. for (uint8_t b = 8; b--;) SERIAL_CHAR('0' + TEST(max7219.led_line[r], b));
  80. SERIAL_EOL();
  81. }
  82. }
  83. }
  84. #endif // MAX7219_GCODE