12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001 |
-
-
-
-
- #define EXTRUSION_MULTIPLIER 1.0
- #define RETRACTION_MULTIPLIER 1.0
- #define NOZZLE 0.3
- #define FILAMENT 1.75
- #define LAYER_HEIGHT 0.2
- #define PRIME_LENGTH 10.0
- #define BED_TEMP 60.0
- #define HOTEND_TEMP 205.0
- #define OOOOZE_AMOUNT 0.3
-
- #include "Marlin.h"
- #include "Configuration.h"
- #include "planner.h"
- #include "stepper.h"
- #include "temperature.h"
- #include "UBL.h"
- #include "ultralcd.h"
-
- #if ENABLED(AUTO_BED_LEVELING_UBL)
-
- #define SIZE_OF_INTERSECTION_CIRCLES 5
- #define SIZE_OF_CROSS_HAIRS 3
-
-
-
-
-
- extern int UBL_has_control_of_LCD_Panel;
- extern float feedrate;
-
- extern Planner planner;
-
- extern char lcd_status_message[];
-
- extern float destination[];
- extern void set_destination_to_current();
- extern void set_current_to_destination();
- extern float code_value_float();
- extern bool code_value_bool();
- extern bool code_has_value();
- extern void lcd_init();
- #define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]))
- bool prepare_move_to_destination_cartesian();
- void line_to_destination();
- void line_to_destination(float );
- void gcode_G28();
- void sync_plan_position_e();
- void un_retract_filament();
- void retract_filament();
- void look_for_lines_to_connect();
- bool parse_G26_parameters();
- void move_to(const float&, const float&, const float&, const float&) ;
- void print_line_from_here_to_there(float sx, float sy, float sz, float ex, float ey, float ez);
- bool turn_on_heaters();
- bool prime_nozzle();
- void chirp_at_user();
-
- static uint16_t circle_flags[16], horizontal_mesh_line_flags[16], vertical_mesh_line_flags[16], Continue_with_closest = 0;
- float G26_E_AXIS_feedrate = 0.020,
- Random_Deviation = 0.0,
- Layer_Height = LAYER_HEIGHT;
-
- bool G26_retracted = false;
-
-
-
- #if ENABLED(ULTRA_LCD)
- void lcd_setstatus(const char* message, bool persist);
- #endif
-
- float valid_trig_angle(float);
- mesh_index_pair find_closest_circle_to_print(float, float);
- void debug_current_and_destination(char *title);
- void UBL_line_to_destination(const float&, const float&, const float&, const float&, const float&, uint8_t);
-
-
- static float E_Pos_Delta,
- Extrusion_Multiplier = EXTRUSION_MULTIPLIER,
- Retraction_Multiplier = RETRACTION_MULTIPLIER,
- Nozzle = NOZZLE,
- Filament = FILAMENT,
- Prime_Length = PRIME_LENGTH,
- X_Pos, Y_Pos,
- bed_temp = BED_TEMP,
- hotend_temp = HOTEND_TEMP,
- Ooooze_Amount = OOOOZE_AMOUNT;
-
- int8_t Prime_Flag = 0;
-
- bool Keep_Heaters_On = false,
- G26_Debug_flag = false;
-
-
-
- void bit_clear(uint16_t bits[16], uint8_t x, uint8_t y) { CBI(bits[y], x); }
- void bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { SBI(bits[y], x); }
- bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { return TEST(bits[y], x); }
-
-
-
- void gcode_G26() {
- float circle_x, circle_y, x, y, xe, ye, tmp,
- start_angle, end_angle;
- int i, xi, yi, lcd_init_counter = 0;
- mesh_index_pair location;
-
- if (axis_unhomed_error(true, true, true))
- gcode_G28();
-
- if (parse_G26_parameters()) return;
-
- if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
- do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
- stepper.synchronize();
- set_current_to_destination();
- }
-
- if (turn_on_heaters())
- goto LEAVE;
-
- axis_relative_modes[E_AXIS] = false;
-
- current_position[E_AXIS] = 0.0;
- sync_plan_position_e();
-
- if (Prime_Flag && prime_nozzle())
- goto LEAVE;
-
-
-
-
-
- ZERO(circle_flags);
- ZERO(horizontal_mesh_line_flags);
- ZERO(vertical_mesh_line_flags);
-
-
-
-
- set_destination_to_current();
- destination[Z_AXIS] = Layer_Height;
- move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
- move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], Ooooze_Amount);
-
- UBL_has_control_of_LCD_Panel = 1;
- debug_current_and_destination((char *)"Starting G26 Mesh Validation Pattern.");
-
- do {
- if (G29_lcd_clicked()) {
- strcpy(lcd_status_message, "Mesh Validation Stopped.");
- while (G29_lcd_clicked()) idle();
- #if ENABLED(ULTRA_LCD)
- lcd_setstatus("Mesh Validation Stopped.", true);
- lcd_quick_feedback();
- #endif
- goto LEAVE;
- }
-
- if (Continue_with_closest)
- location = find_closest_circle_to_print(current_position[X_AXIS], current_position[Y_AXIS]);
- else
- location = find_closest_circle_to_print(X_Pos, Y_Pos);
-
- if (location.x_index >= 0 && location.y_index >= 0) {
- circle_x = blm.map_x_index_to_bed_location(location.x_index);
- circle_y = blm.map_y_index_to_bed_location(location.y_index);
-
-
- #ifdef DELTA
- if (HYPOT2(circle_x, circle_y) > sq(DELTA_PRINTABLE_RADIUS)) {
- SERIAL_PROTOCOLLNPGM("?Error: Attempt to print outside of DELTA_PRINTABLE_RADIUS.");
- goto LEAVE;
- }
- #endif
-
- if (circle_x < X_MIN_POS || circle_x > X_MAX_POS || circle_y < Y_MIN_POS || circle_y > Y_MAX_POS) {
- SERIAL_PROTOCOLLNPGM("?Error: Attempt to print off the bed.");
- goto LEAVE;
- }
-
- xi = location.x_index;
- yi = location.y_index;
-
- if (G26_Debug_flag) {
- SERIAL_ECHOPGM(" Doing circle at: (xi=");
- SERIAL_ECHO(xi);
- SERIAL_ECHOPGM(", yi=");
- SERIAL_ECHO(yi);
- SERIAL_ECHOLNPGM(")");
- }
-
- start_angle = 0.0;
- end_angle = 360.0;
- if (xi == 0) {
- start_angle = -90.0;
- end_angle = 90.0;
- if (yi == 0)
- start_angle = 0.0;
- else if (yi == UBL_MESH_NUM_Y_POINTS - 1)
- end_angle = 0.0;
- }
- else if (xi == UBL_MESH_NUM_X_POINTS - 1) {
- start_angle = 90.0;
- end_angle = 270.0;
- if (yi == 0)
- end_angle = 180.0;
- else if (yi == UBL_MESH_NUM_Y_POINTS - 1)
- start_angle = 180.0;
- }
- else if (yi == 0) {
- start_angle = 0.0;
- end_angle = 180.0;
- }
- else if (yi == UBL_MESH_NUM_Y_POINTS - 1) {
- start_angle = 180.0;
- end_angle = 360.0;
- }
-
-
-
- float sin_table[360 / 30 + 1], cos_table[360 / 30 + 1];
- int tmp_div_30;
- for (i = 0; i <= 360 / 30; i++) {
- cos_table[i] = SIZE_OF_INTERSECTION_CIRCLES * cos(RADIANS(valid_trig_angle(i * 30.0)));
- sin_table[i] = SIZE_OF_INTERSECTION_CIRCLES * sin(RADIANS(valid_trig_angle(i * 30.0)));
- }
-
- for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
- tmp_div_30 = tmp / 30.0;
- if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
-
- x = circle_x + cos_table[tmp_div_30];
- y = circle_y + sin_table[tmp_div_30];
-
- if (tmp_div_30 > 11) tmp_div_30 -= 360 / 30;
- xe = circle_x + cos_table[tmp_div_30 + 1];
- ye = circle_y + sin_table[tmp_div_30 + 1];
- #ifdef DELTA
- if (HYPOT2(x, y) > sq(DELTA_PRINTABLE_RADIUS))
- continue;
- #else
- x = constrain(x, X_MIN_POS + 1, X_MAX_POS - 1);
- y = constrain(y, Y_MIN_POS + 1, Y_MAX_POS - 1);
- xe = constrain(xe, X_MIN_POS + 1, X_MAX_POS - 1);
- ye = constrain(ye, Y_MIN_POS + 1, Y_MAX_POS - 1);
- #endif
-
- if (G26_Debug_flag) {
- char ccc, *cptr, seg_msg[50], seg_num[10];
- strcpy(seg_msg, " segment: ");
- strcpy(seg_num, " \n");
- cptr = (char *) "01234567890ABCDEF????????";
- ccc = cptr[tmp_div_30];
- seg_num[1] = ccc;
- strcat(seg_msg, seg_num);
- debug_current_and_destination(seg_msg);
- }
-
- print_line_from_here_to_there(x, y, Layer_Height, xe, ye, Layer_Height);
- }
- lcd_init_counter++;
- if (lcd_init_counter > 10) {
- lcd_init_counter = 0;
- lcd_init();
- }
-
- debug_current_and_destination((char *)"Looking for lines to connect.");
- look_for_lines_to_connect();
- debug_current_and_destination((char *)"Done with line connect.");
- }
-
- debug_current_and_destination((char *)"Done with current circle.");
-
- }
- while (location.x_index >= 0 && location.y_index >= 0) ;
-
- LEAVE:
-
- retract_filament();
- destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;
-
- debug_current_and_destination((char *)"ready to do Z-Raise.");
- move_to( destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0);
- debug_current_and_destination((char *)"done doing Z-Raise.");
-
- destination[X_AXIS] = X_Pos;
- destination[Y_AXIS] = Y_Pos;
- destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;
-
- move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0);
- debug_current_and_destination((char *)"done doing X/Y move.");
-
- UBL_has_control_of_LCD_Panel = 0;
-
- if (!Keep_Heaters_On) {
- #if HAS_TEMP_BED
- thermalManager.setTargetBed(0.0);
- #endif
- thermalManager.setTargetHotend(0.0, 0);
- }
- lcd_init();
- }
-
-
- float valid_trig_angle(float d) {
- while (d > 360.0) d -= 360.0;
- while (d < 0.0) d += 360.0;
- return d;
- }
-
- mesh_index_pair find_closest_circle_to_print( float X, float Y) {
- float f, mx, my, dx, dy, closest = 99999.99;
- mesh_index_pair return_val;
-
- return_val.x_index = return_val.y_index = -1;
-
- for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
- for (uint8_t j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
- if (!is_bit_set(circle_flags, i, j)) {
- mx = blm.map_x_index_to_bed_location(i);
- my = blm.map_y_index_to_bed_location(j);
-
- dx = X - mx;
- dy = Y - my;
- f = HYPOT(dx, dy);
-
- dx = X_Pos - mx;
- dy = Y_Pos - my;
- f += HYPOT(dx, dy) / 15.0;
-
-
-
-
- if (Random_Deviation > 1.0)
- f += random(0.0, Random_Deviation);
-
- if (f < closest) {
- closest = f;
- return_val.x_index = i;
- return_val.y_index = j;
- return_val.distance= closest;
- }
- }
- }
- }
- bit_set(circle_flags, return_val.x_index, return_val.y_index);
- return return_val;
- }
-
- void look_for_lines_to_connect() {
- float sx, sy, ex, ey;
-
- for (uint8_t i = 0; i < UBL_MESH_NUM_X_POINTS; i++) {
- for (uint8_t j = 0; j < UBL_MESH_NUM_Y_POINTS; j++) {
-
- if (i < UBL_MESH_NUM_X_POINTS) {
-
-
- if (is_bit_set(circle_flags, i, j) && is_bit_set(circle_flags, i + 1, j)) {
- if (!is_bit_set(horizontal_mesh_line_flags, i, j)) {
-
-
-
-
-
- sx = blm.map_x_index_to_bed_location(i);
- sx = sx + SIZE_OF_INTERSECTION_CIRCLES - SIZE_OF_CROSS_HAIRS;
- sy = blm.map_y_index_to_bed_location(j);
-
- ex = blm.map_x_index_to_bed_location(i + 1);
- ex = ex - SIZE_OF_INTERSECTION_CIRCLES + SIZE_OF_CROSS_HAIRS;
- ey = sy;
-
- sx = constrain(sx, X_MIN_POS + 1, X_MAX_POS - 1);
- sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
- ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
- ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
-
- if (G26_Debug_flag) {
- SERIAL_ECHOPGM(" Connecting with horizontal line (sx=");
- SERIAL_ECHO(sx);
- SERIAL_ECHOPGM(", sy=");
- SERIAL_ECHO(sy);
- SERIAL_ECHOPGM(") -> (ex=");
- SERIAL_ECHO(ex);
- SERIAL_ECHOPGM(", ey=");
- SERIAL_ECHO(ey);
- SERIAL_ECHOLNPGM(")");
- debug_current_and_destination((char *)"Connecting horizontal line.");
- }
-
- print_line_from_here_to_there(sx, sy, Layer_Height, ex, ey, Layer_Height);
- bit_set(horizontal_mesh_line_flags, i, j);
- }
- }
-
- if (j < UBL_MESH_NUM_Y_POINTS) {
-
-
- if (is_bit_set(circle_flags, i, j) && is_bit_set(circle_flags, i, j + 1)) {
- if (!is_bit_set( vertical_mesh_line_flags, i, j)) {
-
-
-
-
- sx = blm.map_x_index_to_bed_location(i);
- sy = blm.map_y_index_to_bed_location(j);
- sy = sy + SIZE_OF_INTERSECTION_CIRCLES - SIZE_OF_CROSS_HAIRS;
-
- ex = sx;
- ey = blm.map_y_index_to_bed_location(j + 1);
- ey = ey - SIZE_OF_INTERSECTION_CIRCLES + SIZE_OF_CROSS_HAIRS;
-
- sx = constrain(sx, X_MIN_POS + 1, X_MAX_POS - 1);
- sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
- ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
- ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
-
- if (G26_Debug_flag) {
- SERIAL_ECHOPGM(" Connecting with vertical line (sx=");
- SERIAL_ECHO(sx);
- SERIAL_ECHOPGM(", sy=");
- SERIAL_ECHO(sy);
- SERIAL_ECHOPGM(") -> (ex=");
- SERIAL_ECHO(ex);
- SERIAL_ECHOPGM(", ey=");
- SERIAL_ECHO(ey);
- SERIAL_ECHOLNPGM(")");
- debug_current_and_destination((char *)"Connecting vertical line.");
- }
- print_line_from_here_to_there(sx, sy, Layer_Height, ex, ey, Layer_Height);
- bit_set( vertical_mesh_line_flags, i, j);
- }
- }
- }
- }
- }
- }
- }
-
- void debug_current_and_destination(char *title) {
- float dx, dy, de, xy_dist, fpmm;
-
-
-
- if (*title != '!' && !G26_Debug_flag) return;
-
- dx = current_position[X_AXIS] - destination[X_AXIS];
- dy = current_position[Y_AXIS] - destination[Y_AXIS];
- de = destination[E_AXIS] - current_position[E_AXIS];
- if (de == 0.0) return;
-
- xy_dist = HYPOT(dx, dy);
- if (xy_dist == 0.0) {
- return;
-
-
-
- }
- else {
- SERIAL_ECHOPGM(" fpmm=");
- fpmm = de / xy_dist;
- SERIAL_PROTOCOL_F(fpmm, 6);
- }
-
- SERIAL_ECHOPGM(" current=( ");
- SERIAL_PROTOCOL_F(current_position[X_AXIS], 6);
- SERIAL_ECHOPGM(", ");
- SERIAL_PROTOCOL_F(current_position[Y_AXIS], 6);
- SERIAL_ECHOPGM(", ");
- SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6);
- SERIAL_ECHOPGM(", ");
- SERIAL_PROTOCOL_F(current_position[E_AXIS], 6);
- SERIAL_ECHOPGM(" ) destination=( ");
- if (current_position[X_AXIS] == destination[X_AXIS])
- SERIAL_ECHOPGM("-------------");
- else
- SERIAL_PROTOCOL_F(destination[X_AXIS], 6);
-
- SERIAL_ECHOPGM(", ");
-
- if (current_position[Y_AXIS] == destination[Y_AXIS])
- SERIAL_ECHOPGM("-------------");
- else
- SERIAL_PROTOCOL_F(destination[Y_AXIS], 6);
-
- SERIAL_ECHOPGM(", ");
-
- if (current_position[Z_AXIS] == destination[Z_AXIS])
- SERIAL_ECHOPGM("-------------");
- else
- SERIAL_PROTOCOL_F(destination[Z_AXIS], 6);
-
- SERIAL_ECHOPGM(", ");
-
- if (current_position[E_AXIS] == destination[E_AXIS])
- SERIAL_ECHOPGM("-------------");
- else
- SERIAL_PROTOCOL_F(destination[E_AXIS], 6);
-
- SERIAL_ECHOPGM(" ) ");
- SERIAL_ECHO(title);
- SERIAL_EOL;
-
- SET_INPUT_PULLUP(66);
-
-
-
-
-
- }
-
- void move_to(const float &x, const float &y, const float &z, const float &e_delta) {
- float feed_value;
- static float last_z = -999.99;
-
- bool has_XY_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]);
-
- if (G26_Debug_flag) {
- SERIAL_ECHOPAIR("in move_to() has_XY_component:", (int)has_XY_component);
- SERIAL_EOL;
- }
-
- if (z != last_z) {
-
- if (G26_Debug_flag) {
- SERIAL_ECHOPAIR("in move_to() changing Z to ", (int)z);
- SERIAL_EOL;
- }
- last_z = z;
- feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0);
-
- destination[X_AXIS] = current_position[X_AXIS];
- destination[Y_AXIS] = current_position[Y_AXIS];
- destination[Z_AXIS] = z;
- destination[E_AXIS] = current_position[E_AXIS];
-
- UBL_line_to_destination(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feed_value, 0);
-
- stepper.synchronize();
- set_destination_to_current();
-
- if (G26_Debug_flag)
- debug_current_and_destination((char *)" in move_to() done with Z move");
- }
-
-
-
- feed_value = has_XY_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
-
- if (G26_Debug_flag) {
- SERIAL_ECHOPAIR("in move_to() feed_value for XY:", feed_value);
- SERIAL_EOL;
- }
-
- destination[X_AXIS] = x;
- destination[Y_AXIS] = y;
- destination[E_AXIS] += e_delta;
-
- if (G26_Debug_flag)
- debug_current_and_destination((char *)" in move_to() doing last move");
-
- UBL_line_to_destination(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feed_value, 0);
-
- if (G26_Debug_flag)
- debug_current_and_destination((char *)" in move_to() after last move");
-
- stepper.synchronize();
- set_destination_to_current();
- }
-
- void retract_filament() {
- if (!G26_retracted) {
- G26_retracted = true;
- if (G26_Debug_flag) SERIAL_ECHOLNPGM(" Decided to do retract.");
- move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], -1.0 * Retraction_Multiplier);
- if (G26_Debug_flag) SERIAL_ECHOLNPGM(" Retraction done.");
- }
- }
-
- void un_retract_filament() {
- if (G26_retracted) {
- move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 1.2 * Retraction_Multiplier);
- G26_retracted = false;
- if (G26_Debug_flag) SERIAL_ECHOLNPGM(" unretract done.");
- }
- }
-
-
-
- void print_line_from_here_to_there( float sx, float sy, float sz, float ex, float ey, float ez) {
- float dx, dy, dx_s, dy_s, dx_e, dy_e, dist_start, dist_end, Line_Length;
-
- dx_s = current_position[X_AXIS] - sx;
- dy_s = current_position[Y_AXIS] - sy;
- dist_start = HYPOT2(dx_s, dy_s);
-
- dx_e = current_position[X_AXIS] - ex;
- dy_e = current_position[Y_AXIS] - ey;
- dist_end = HYPOT2(dx_e, dy_e);
-
- dx = ex - sx;
- dy = ey - sy;
- Line_Length = HYPOT(dx, dy);
-
-
-
-
-
- if (dist_end < dist_start && (SIZE_OF_INTERSECTION_CIRCLES) < abs(Line_Length)) {
- if (G26_Debug_flag)
- SERIAL_ECHOLNPGM(" Reversing start and end of print_line_from_here_to_there()");
- print_line_from_here_to_there(ex, ey, ez, sx, sy, sz);
- return;
- }
-
-
-
- if (dist_start > 2.0) {
- retract_filament();
- if (G26_Debug_flag)
- SERIAL_ECHOLNPGM(" filament retracted.");
- }
- move_to(sx, sy, sz, 0.0);
-
- E_Pos_Delta = Line_Length * G26_E_AXIS_feedrate * Extrusion_Multiplier;
-
- un_retract_filament();
- if (G26_Debug_flag) {
- SERIAL_ECHOLNPGM(" doing printing move.");
- debug_current_and_destination((char *)"doing final move_to() inside print_line_from_here_to_there()");
- }
- move_to(ex, ey, ez, E_Pos_Delta);
- }
-
-
-
- bool parse_G26_parameters() {
-
- Extrusion_Multiplier = EXTRUSION_MULTIPLIER;
- Retraction_Multiplier = RETRACTION_MULTIPLIER;
- Nozzle = NOZZLE;
- Filament = FILAMENT;
- Layer_Height = LAYER_HEIGHT;
- Prime_Length = PRIME_LENGTH;
- bed_temp = BED_TEMP;
- hotend_temp = HOTEND_TEMP;
- Ooooze_Amount = OOOOZE_AMOUNT;
- Prime_Flag = 0;
- Keep_Heaters_On = false;
-
- if (code_seen('B')) {
- bed_temp = code_value_float();
- if (bed_temp < 15.0 || bed_temp > 140.0) {
- SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
- return UBL_ERR;
- }
- }
-
- if (code_seen('C')) Continue_with_closest++;
-
- if (code_seen('L')) {
- Layer_Height = code_value_float();
- if (Layer_Height<0.0 || Layer_Height>2.0) {
- SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
- return UBL_ERR;
- }
- }
-
- if (code_seen('Q')) {
- if (code_has_value()) {
- Retraction_Multiplier = code_value_float();
- if (Retraction_Multiplier<.05 || Retraction_Multiplier>15.0) {
- SERIAL_PROTOCOLLNPGM("?Specified Retraction Multiplier not plausible.");
- return UBL_ERR;
- }
- }
- else {
- SERIAL_PROTOCOLLNPGM("?Retraction Multiplier must be specified.");
- return UBL_ERR;
- }
- }
-
- if (code_seen('N')) {
- Nozzle = code_value_float();
- if (Nozzle < 0.1 || Nozzle > 1.0) {
- SERIAL_PROTOCOLLNPGM("?Specified nozzle size not plausible.");
- return UBL_ERR;
- }
- }
-
- if (code_seen('K')) Keep_Heaters_On++;
-
- if (code_seen('O') && code_has_value())
- Ooooze_Amount = code_value_float();
-
- if (code_seen('P')) {
- if (!code_has_value())
- Prime_Flag = -1;
- else {
- Prime_Flag++;
- Prime_Length = code_value_float();
- if (Prime_Length < 0.0 || Prime_Length > 25.0) {
- SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible.");
- return UBL_ERR;
- }
- }
- }
-
- if (code_seen('F')) {
- Filament = code_value_float();
- if (Filament < 1.0 || Filament > 4.0) {
- SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
- return UBL_ERR;
- }
- }
- Extrusion_Multiplier *= sq(1.75) / sq(Filament);
-
-
- Extrusion_Multiplier *= Filament * sq(Nozzle) / sq(0.3);
-
- if (code_seen('H')) {
- hotend_temp = code_value_float();
- if (hotend_temp < 165.0 || hotend_temp > 280.0) {
- SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
- return UBL_ERR;
- }
- }
-
- if (code_seen('R')) {
- randomSeed(millis());
- Random_Deviation = code_has_value() ? code_value_float() : 50.0;
- }
-
- X_Pos = current_position[X_AXIS];
- Y_Pos = current_position[Y_AXIS];
-
- if (code_seen('X')) {
- X_Pos = code_value_float();
- if (X_Pos < X_MIN_POS || X_Pos > X_MAX_POS) {
- SERIAL_PROTOCOLLNPGM("?Specified X coordinate not plausible.");
- return UBL_ERR;
- }
- }
- else
-
- if (code_seen('Y')) {
- Y_Pos = code_value_float();
- if (Y_Pos < Y_MIN_POS || Y_Pos > Y_MAX_POS) {
- SERIAL_PROTOCOLLNPGM("?Specified Y coordinate not plausible.");
- return UBL_ERR;
- }
- }
-
-
-
- blm.state.active = !code_seen('D');
-
- return UBL_OK;
- }
-
-
-
- bool turn_on_heaters() {
- #if HAS_TEMP_BED
- #if ENABLED(ULTRA_LCD)
- if (bed_temp > 25) {
- lcd_setstatus("G26 Heating Bed.", true);
- lcd_quick_feedback();
- #endif
- UBL_has_control_of_LCD_Panel++;
- thermalManager.setTargetBed(bed_temp);
- while (abs(thermalManager.degBed() - bed_temp) > 3) {
- if (G29_lcd_clicked()) {
- strcpy(lcd_status_message, "Leaving G26");
- while (G29_lcd_clicked()) idle();
- lcd_setstatus("Leaving G26", true);
- return UBL_ERR;
- }
- idle();
- }
- #if ENABLED(ULTRA_LCD)
- }
- lcd_setstatus("G26 Heating Nozzle.", true);
- lcd_quick_feedback();
- #endif
- #endif
-
-
- thermalManager.setTargetHotend(hotend_temp, 0);
- while (abs(thermalManager.degHotend(0) - hotend_temp) > 3) {
- if (G29_lcd_clicked()) {
- strcpy(lcd_status_message, "Leaving G26");
- while (G29_lcd_clicked()) idle();
- lcd_setstatus("Leaving G26", true);
- return UBL_ERR;
- }
- idle();
- }
-
- #if ENABLED(ULTRA_LCD)
- lcd_setstatus("", true);
- lcd_quick_feedback();
- #endif
- return UBL_OK;
- }
-
-
-
- bool prime_nozzle() {
- float Total_Prime = 0.0;
-
- if (Prime_Flag == -1) {
- lcd_setstatus("User Controled Prime", true);
- chirp_at_user();
-
- set_destination_to_current();
-
- un_retract_filament();
-
-
-
- UBL_has_control_of_LCD_Panel++;
- while (!G29_lcd_clicked()) {
- chirp_at_user();
- destination[E_AXIS] += 0.25;
- #ifdef PREVENT_LENGTHY_EXTRUDE
- Total_Prime += 0.25;
- if (Total_Prime >= EXTRUDE_MAXLENGTH) return UBL_ERR;
- #endif
- UBL_line_to_destination(
- destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS],
-
- planner.max_feedrate_mm_s[E_AXIS] / 15.0, 0
- );
-
- stepper.synchronize();
-
-
-
- set_destination_to_current();
- idle();
- }
-
- strcpy(lcd_status_message, "Done Priming");
-
-
- while (G29_lcd_clicked()) idle();
-
- #if ENABLED(ULTRA_LCD)
- UBL_has_control_of_LCD_Panel = 0;
- lcd_setstatus("Done Priming", true);
- lcd_quick_feedback();
- #endif
- }
- else {
- #if ENABLED(ULTRA_LCD)
- lcd_setstatus("Fixed Length Prime.", true);
- lcd_quick_feedback();
- #endif
- set_destination_to_current();
- destination[E_AXIS] += Prime_Length;
- UBL_line_to_destination(
- destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS],
-
- planner.max_feedrate_mm_s[E_AXIS] / 15.0, 0
- );
- stepper.synchronize();
- set_destination_to_current();
- retract_filament();
- }
- return UBL_OK;
- }
-
- #endif
|