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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../../inc/MarlinConfig.h"
  23. #if ENABLED(EXPERIMENTAL_I2CBUS)
  24. #include "../../gcode.h"
  25. #include "../../../MarlinCore.h" // for i2c
  26. /**
  27. * M260: Send data to a I2C slave device
  28. *
  29. * This is a PoC, the formatting and arguments for the GCODE will
  30. * change to be more compatible, the current proposal is:
  31. *
  32. * M260 A<slave device address base 10> ; Sets the I2C slave address the data will be sent to
  33. *
  34. * M260 B<byte-1 value in base 10>
  35. * M260 B<byte-2 value in base 10>
  36. * M260 B<byte-3 value in base 10>
  37. *
  38. * M260 S1 ; Send the buffered data and reset the buffer
  39. * M260 R1 ; Reset the buffer without sending data
  40. */
  41. void GcodeSuite::M260() {
  42. // Set the target address
  43. if (parser.seen('A')) i2c.address(parser.value_byte());
  44. // Add a new byte to the buffer
  45. if (parser.seen('B')) i2c.addbyte(parser.value_byte());
  46. // Flush the buffer to the bus
  47. if (parser.seen('S')) i2c.send();
  48. // Reset and rewind the buffer
  49. else if (parser.seen('R')) i2c.reset();
  50. }
  51. /**
  52. * M261: Request X bytes from I2C slave device
  53. *
  54. * Usage: M261 A<slave device address base 10> B<number of bytes>
  55. */
  56. void GcodeSuite::M261() {
  57. if (parser.seen('A')) i2c.address(parser.value_byte());
  58. uint8_t bytes = parser.byteval('B', 1);
  59. if (i2c.addr && bytes && bytes <= TWIBUS_BUFFER_SIZE)
  60. i2c.relay(bytes);
  61. else
  62. SERIAL_ERROR_MSG("Bad i2c request");
  63. }
  64. #endif