Advertisement
Guest User

dagoma m600

a guest
Jan 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. /**
  2. * M600: Pause for filament change
  3. *
  4. * E[distance] - Retract the filament this far (negative value)
  5. * Z[distance] - Move the Z axis by this distance
  6. * X[position] - Move to this X position, with Y
  7. * Y[position] - Move to this Y position, with X
  8. * L[distance] - Retract distance for removal (manual reload)
  9. * P[pin] - Pin to wait for, if not specified use lcd button
  10. * - Pin can be A, B or C respectively for X, Y and Z endstops.
  11. * S[0|1] - If Pin, state to wait for, if not specified use LOW
  12. *
  13. * Default values are used for omitted arguments.
  14. *
  15. */
  16. inline void gcode_M600() {
  17.  
  18. SERIAL_ECHOLNPGM( "Pause for filament change" );
  19.  
  20. if (cant_enter_M600_or_D600()) return;
  21.  
  22. #if ENABLED(SUMMON_PRINT_PAUSE)
  23. // Simulate direct call M600
  24. print_pause_summoned = true;
  25. #endif
  26.  
  27. float lastpos[NUM_AXIS];
  28. float previous_feedrate;
  29.  
  30. for (int i = 0; i < NUM_AXIS; i++)
  31. lastpos[i] = destination[i] = current_position[i];
  32.  
  33. previous_feedrate = feedrate;
  34.  
  35. //finish moves
  36. // st_synchronize();
  37.  
  38. //retract by E
  39. if (code_seen('E')) destination[E_AXIS] += code_value();
  40. #ifdef FILAMENTCHANGE_FIRSTRETRACT
  41. else destination[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT;
  42. #endif
  43.  
  44. SET_FEEDRATE_FOR_EXTRUDER_MOVE;
  45. RUNPLAN;
  46.  
  47. //lift Z
  48. #if ENABLED(DELTA_EXTRA)
  49. float z_destination = destination[Z_AXIS];
  50. if (code_seen('Z')) z_destination += code_value();
  51. #ifdef FILAMENTCHANGE_ZADD
  52. else z_destination += FILAMENTCHANGE_ZADD;
  53. #endif
  54. NOMORE(z_destination, (Z_MAX_POS-25.0));
  55. if (z_destination > destination[Z_AXIS]) {
  56. destination[Z_AXIS] = z_destination;
  57. }
  58. #else
  59. if (code_seen('Z')) destination[Z_AXIS] += code_value();
  60. #ifdef FILAMENTCHANGE_ZADD
  61. else destination[Z_AXIS] += FILAMENTCHANGE_ZADD;
  62. #endif
  63. #endif
  64.  
  65. SET_FEEDRATE_FOR_MOVE;
  66. RUNPLAN;
  67.  
  68. //move xy
  69. if (code_seen('X')) destination[X_AXIS] = code_value();
  70. #ifdef FILAMENTCHANGE_XPOS
  71. else destination[X_AXIS] = FILAMENTCHANGE_XPOS;
  72. #endif
  73.  
  74. if (code_seen('Y')) destination[Y_AXIS] = code_value();
  75. #ifdef FILAMENTCHANGE_YPOS
  76. else destination[Y_AXIS] = FILAMENTCHANGE_YPOS;
  77. #endif
  78.  
  79. SET_FEEDRATE_FOR_MOVE;
  80. RUNPLAN;
  81.  
  82. if (code_seen('L')) destination[E_AXIS] += code_value();
  83. #ifdef FILAMENTCHANGE_FINALRETRACT
  84. else destination[E_AXIS] += FILAMENTCHANGE_FINALRETRACT;
  85. #endif
  86.  
  87. SET_FEEDRATE_FOR_EXTRUDER_MOVE;
  88. RUNPLAN;
  89.  
  90. // validate planned all moves
  91. st_synchronize();
  92.  
  93. // DAGOMA added
  94. // Determine exit/pin state after moving away
  95. int pin_number = -1;
  96. int target = -1;
  97. if (code_seen('P')) {
  98. char nextChar = *(seen_pointer + 1);
  99. if (nextChar == 'A') {
  100. pin_number = X_MIN_PIN;
  101. }
  102. else if (nextChar == 'B') {
  103. pin_number = Y_MAX_PIN;
  104. }
  105. else if (nextChar == 'C') {
  106. pin_number = Z_MIN_PIN;
  107. }
  108. else {
  109. pin_number = code_value();
  110. }
  111.  
  112. int pin_state = code_seen('S') ? code_value() : -1; // required pin state - default is inverted
  113.  
  114. if (pin_state >= -1 && pin_state <= 1) {
  115.  
  116. // DAGOMA - byPass sensitive pin
  117. /*
  118. for (uint8_t i = 0; i < COUNT(sensitive_pins); i++) {
  119. if (sensitive_pins[i] == pin_number) {
  120. pin_number = -1;
  121. break;
  122. }
  123. }
  124. */
  125. if (pin_number > -1) {
  126. target = LOW;
  127.  
  128. //pinMode(pin_number, INPUT);
  129.  
  130. switch (pin_state) {
  131. case 1:
  132. target = HIGH;
  133. break;
  134.  
  135. case 0:
  136. target = LOW;
  137. break;
  138.  
  139. case -1:
  140. target = !digitalRead(pin_number);
  141. break;
  142. }
  143. } // pin_number > -1
  144. } // pin_state -1 0 1
  145. } // code_seen('P')
  146. // END DAGOMA added
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement