def leavetower(): gcode.issue_code(";------------------------------\n") gcode.issue_code("; P2PP DELTA LEAVE\n") gcode.issue_code("; Returning to Current Z-Height = {:.2f}; ".format( v.current_position_z)) gcode.issue_code("G1 Z{:.2f} F10810\n".format(v.current_position_z)) gcode.issue_code(";------------------------------\n")
def retract(tool, speed=-1): length = v.retract_length[tool] if speed > 0: gcode.issue_code("G1 E-{:.2f} F{:.0f}".format(v.retract_length[tool], speed)) else: gcode.issue_code("G1 E-{:.2f}".format(v.retract_length[tool])) v.retraction -= length
def largeretract(): if not v.use_firmware_retraction: gcode.issue_code("G1 E-{:.2f}\n".format(3)) v.retraction -= 3 else: gcode.issue_code("G10\n") v.retraction -= 1
def unretract(tool, speed=-1, comment=""): if v.retraction == 0: return if speed > 0: gcode.issue_code("G1 E{:.2f} F{:.0f} {}".format(-v.retraction, speed, comment)) else: gcode.issue_code("G1 E{:.2f} {}".format(-v.retraction, comment)) v.retraction = 0
def _purge_update_sequence_index(): global current_purge_form, current_purge_index current_purge_index = (current_purge_index + 1) % _purge_number_of_gcodelines() if current_purge_index == 0: if (v.purgelayer + 1) * v.layer_height < v.current_position_z - 5: current_purge_form = PURGE_EMPTY else: current_purge_form = PURGE_SOLID v.purgelayer += 1 if v.side_wipe_length > 0: gcode.issue_code("G1 Z{:.2f} F10800\n".format((v.purgelayer + 1) * v.layer_height))
def check_accessorymode_first(): if v.accessory_mode and check_first_ping_condition(): v.acc_ping_left = 20 gcode.issue_code("; ------------------------------------\n") gcode.issue_code("; --- P2PP - ACCESSORY MODE PING PART 1\n") gcode.issue_code(acc_first_pause) gcode.issue_code("; -------------------------------------\n")
def check_connected_ping(): if not v.accessory_mode and check_first_ping_condition(): v.ping_interval = v.ping_interval * v.ping_length_multiplier v.ping_interval = min(v.max_ping_interval, v.ping_interval) v.last_ping_extruder_position = v.total_material_extruded v.ping_extruder_position.append(v.last_ping_extruder_position) gcode.issue_code( "; --- P2PP - INSERT PING CODE {} after {:-10.4f}mm of extrusion".format(len(v.ping_extruder_position), v.last_ping_extruder_position)) # wait for the planning buffer to clear gcode.issue_code(v.finish_moves) # insert O31 commands format depending on device if v.palette3: gcode.issue_code("O31 L{:.2f} mm".format(v.last_ping_extruder_position + v.autoloadingoffset)) else: gcode.issue_code("O31 {}".format(hexify_float(v.last_ping_extruder_position + v.autoloadingoffset))) gcode.issue_code("; --- P2PP - END PING CODE", True)
def check_connected_ping(): if not v.accessory_mode and check_first_ping_condition(): v.ping_interval = v.ping_interval * v.ping_length_multiplier v.ping_interval = min(v.max_ping_interval, v.ping_interval) v.last_ping_extruder_position = v.total_material_extruded v.ping_extruder_position.append(v.last_ping_extruder_position) gcode.issue_code( "; --- P2PP - Added Sequence - INITIATE PING - START COMMAND after {:-10.4f}mm of extrusion \n".format( v.last_ping_extruder_position)) gcode.issue_code("G4 S0 \n") gcode.issue_code("O31 {}\n".format(hexify_float(v.last_ping_extruder_position + v.autoloadingoffset))) gcode.issue_code("; --- P2PP - Added Sequence - INITIATE PING - END\n")
def retract(tool, speed=-1): if not v.use_firmware_retraction: length = v.retract_length[tool] if speed > 0: gcode.issue_code("G1 E-{:.2f} F{:.0f}\n".format(v.retract_length[tool], speed)) else: gcode.issue_code("G1 E-{:.2f}\n".format(v.retract_length[tool])) else: gcode.issue_code("G10\n") v.retraction -= 1
def swap_pause(command): global warning if v.z_maxheight > 0: lift = min(v.current_position_z + 20, v.z_maxheight) else: lift = v.current_position_z + 20 if warning: gui.log_warning("Manual swap lift of 20 without constraint!!") gc.issue_code(";MANUAL SWAP PAUSE SEQUENCE") gc.issue_code("G1 Z{:.2f} F10800".format(lift)) gc.issue_code(command)
def unretract(tool, speed=-1): if v.retraction == 0: return if not v.use_firmware_retraction: length = max(-v.retraction, v.retract_length[tool]) if speed > 0: gcode.issue_code("G1 E{:.2f} F{:.0f}\n".format(length, speed)) else: gcode.issue_code("G1 E{:.2f}\n".format(length)) else: gcode.issue_code("G11\n") v.retraction = 0
def entertower(layer_hght): if v.cur_tower_z_delta > 0: purgeheight = layer_hght - v.cur_tower_z_delta v.max_tower_delta = max(v.cur_tower_z_delta, v.max_tower_delta) gcode.issue_code(";------------------------------\n") gcode.issue_code( "; P2PP DELTA >> TOWER {:.2f}mm\n".format(purgeheight)) purgetower.retract(v.current_tool) gcode.issue_code("G1 Z{:.2f} F10810\n".format(purgeheight)) purgetower.unretract(v.current_tool) gcode.issue_code(";------------------------------\n") if purgeheight <= 0.21: gcode.issue_code("G1 F{}\n".format(min(1200, v.wipe_feedrate))) else: gcode.issue_code("G1 F{}\n".format(v.wipe_feedrate))
def create_sidewipe_bb3d(length): # purge blobs should all be same size if v.bigbrain3d_matrix_blobs and v.bigbrain3d_last_toolchange >= 0: filin = int(v.bigbrain3d_last_toolchange / 10) filout = v.bigbrain3d_last_toolchange % 10 matidx = filin * v.colors + filout purgeblobs = int(v.wiping_info[matidx]) correction = 0 length = purgeblobs * v.mechpurge_blob_size else: purgeleft = length % v.mechpurge_blob_size purgeblobs = int(length / v.mechpurge_blob_size) if purgeleft > 1: purgeblobs += 1 correction = v.mechpurge_blob_size * purgeblobs - length if v.single_blob: purgeblobs = 1 correction = 0 issue_code(";-------------------------------", True) issue_code("; P2PP BB3DBLOBS: {:.0f} BLOB(S)".format(purgeblobs), True) issue_code(";-------------------------------", True) issue_code("; Req={:.2f}mm Act={:.2f}mm".format(length, length + correction)) issue_code("; Purge difference {:.2f}mm".format(correction)) issue_code(";-------------------------------") if v.retraction == 0: purgetower.largeretract(v.mechpurge_retract) keep_xpos = v.current_position_x keep_ypos = v.current_position_y if v.retraction > -v.mechpurge_retract: diff = -v.mechpurge_retract - v.retraction issue_code("\nG1 E{:.3f} ; retract to -{}mm".format( diff, v.mechpurge_retract)) if v.bigbrain3d_y_position is not None: issue_code( "\nG1 Y{:.3f} F8640 ; change Y position to purge equipment". format(v.bigbrain3d_y_position)) if v.current_position_z < v.mechpurge_minimalclearenceheight: issue_code( "\nG1 Z{:.3f} F8640 ; Increase Z to prevent collission with bed" .format(v.mechpurge_minimalclearenceheight)) issue_code("G1 X{:.3f} F10800 ; go near edge of bed".format( v.mechpurge_x_position - 30)) if v.manual_filament_swap: swap.swap_pause("M25") swap.swap_unpause() issue_code("{} ; wait for the print buffer to clear".format( v.finish_moves)) v.processed_gcode.append( "M907 X{} ; increase motor power".format( v.bigbrain3d_motorpower_high)) issue_code( "; -- P2PP -- Generating {} blobs for {}mm of purge".format( purgeblobs, length), True) if v.single_blob: generate_bb3d_blob(length, 0) else: for i in range(purgeblobs): generate_bb3d_blob(v.mechpurge_blob_size, i) if not v.retraction < 0: purgetower.retract(v.current_tool) if v.current_position_z < v.mechpurge_minimalclearenceheight: if keep_xpos > v.bed_max_x or keep_xpos < v.bed_origin_x: keep_xpos = (v.bed_max_x - v.bed_origin_x) / 2 if keep_ypos > v.bed_max_y or keep_ypos < v.bed_origin_y: keep_ypos = (v.bed_max_y - v.bed_origin_y) / 2 issue_code("\nG1 X{:.3f} Y{:.3f} F8640".format(keep_xpos, keep_ypos)) if not v.sidewipe_delay_zreturn: issue_code( "\nG1 Z{:.4f} F8640 ; P2PP - ZHOP - return to oroginal height" .format(v.current_position_z)) else: issue_code( "\n; G1 Z{:.4f} F8640 ; P2PP - Deferred return to Z_height". format(v.current_position_z)) resetfanspeed() v.processed_gcode.append("\nM907 X{} ; reset motor power".format( v.bigbrain3d_motorpower_normal)) issue_code("\n;-------------------------------\n", True)
def create_side_wipe(length=0): if length != 0: v.side_wipe_length = length if not v.side_wipe or v.side_wipe_length == 0: return if v.bigbrain3d_purge_enabled: create_sidewipe_bb3d(v.side_wipe_length) v.side_wipe_length = 0 elif v.blobster_purge_enabled: create_sidewipe_blobster(v.side_wipe_length) v.side_wipe_length = 0 else: issue_code(";---------------------------", True) issue_code("; P2PP SIDE WIPE: {:7.3f}mm".format(v.side_wipe_length), True) # check if the sidewipe has an additional z-hop defined, if so increase z-height with that amount if v.addzop > 0.0: issue_code( "G1 Z{} ;P2PP ZHOP SIDEWIPE".format(v.current_position_z + 1.0)) for line in v.before_sidewipe_gcode: issue_code(line) if v.retraction == 0: purgetower.retract(v.current_tool) issue_code("G1 F8640") issue_code("G1 {} Y{}".format(v.side_wipe_loc, v.sidewipe_miny)) if v.manual_filament_swap: swap.swap_pause("M25") swap.swap_unpause() delta_y = abs(v.sidewipe_maxy - v.sidewipe_miny) if v.sidewipe_maxy == v.sidewipe_miny: # no Y movement, just purge purgetower.unretract(v.current_tool) while v.side_wipe_length > 0: sweep = min(v.side_wipe_length, 50) issue_code("G1 E{:.5f} F{}".format(sweep, v.wipe_feedrate)) issue_code("G1 E-3.0000 F200") issue_code("G1 E3.0000 F200") v.side_wipe_length -= sweep else: sweep_base_speed = v.wipe_feedrate * 20 * delta_y / 150 sweep_length = 20 yrange = [v.sidewipe_maxy, v.sidewipe_miny] rangeidx = 0 movefrom = v.sidewipe_miny moveto = yrange[rangeidx] numdiffs = 20 purgetower.unretract(v.current_tool) while v.side_wipe_length > 0: sweep = min(v.side_wipe_length, sweep_length) v.side_wipe_length -= sweep_length wipe_speed = min(5000, int(sweep_base_speed / sweep)) # split this move in very short moves to allow for faster planning buffer depletion diff = (moveto - movefrom) / numdiffs for i in range(numdiffs): issue_code("G1 {} Y{:.3f} E{:.5f} F{}".format( v.side_wipe_loc, movefrom + (i + 1) * diff, sweep / numdiffs * v.sidewipe_correction, wipe_speed)) # issue_code( # "G1 {} Y{} E{:.5f} F{}\n".format(v.side_wipe_loc, moveto, sweep * v.sidewipe_correction, wipe_speed)) rangeidx += 1 movefrom = moveto moveto = yrange[rangeidx % 2] for line in v.after_sidewipe_gcode: issue_code(line) purgetower.retract(v.current_tool) issue_code("G1 F8640") issue_code(";---------------------------", True) v.side_wipe_length = 0
def generate_bb3d_blob(length, count): issue_code( "\n;---- BIGBRAIN3D SIDEWIPE BLOB {} -- purge {:.3f}mm".format( count + 1, length), True) # issue_code("M907 X{} ; set motor power\n".format(int(v.purgemotorpower))) setfanspeed(0) if v.bigbrain3d_fanoffdelay > 0: issue_code("G4 P{} ; delay to let the fan spinn down".format( v.bigbrain3d_fanoffdelay)) issue_code("G1 X{:.3f} F3000 ; go near the edge of the print".format( v.mechpurge_x_position - v.bigbrain3d_left * 10)) issue_code("G1 X{:.3f} F1000 ; go to the actual wiping position".format( v.mechpurge_x_position)) # takes 2.5 seconds if v.retraction < 0: purgetower.largeunretract() if v.mechpurge_smartfan: issue_code("G1 E{:6.3f} F{} ; Purge FAN OFF ".format( length / 4, v.mechpurge_blob_speed)) setfanspeed(32) issue_code("G1 E{:6.3f} F{} ; Purge FAN 12% ".format( length / 4, v.mechpurge_blob_speed)) setfanspeed(64) issue_code("G1 E{:6.3f} F{} ; Purge FAN 25% ".format( length / 4, v.mechpurge_blob_speed)) setfanspeed(96) issue_code("G1 E{:6.3f} F{} ; Purge FAN 37% ".format( length / 4, v.mechpurge_blob_speed)) else: issue_code("G1 E{:6.3f} F{} ; Purge Part 1 ".format( length - 8, v.mechpurge_blob_speed)) issue_code("G1 E8.000 F{} ; Purge Part 2 ".format( v.mechpurge_blob_speed / 2)) purgetower.largeretract(v.mechpurge_retract) setfanspeed(255) issue_code("G4 S{0:.0f} ; blob {0}s cooling time".format( v.mechpurge_blob_cooling_time)) issue_code( "G1 X{:.3f} F10800 ; activate flicker".format(v.mechpurge_x_position - v.bigbrain3d_left * 20)) for i in range(v.bigbrain3d_whacks): issue_code( "G4 S1 ; Mentally prep for second whack".format( v.mechpurge_x_position - v.bigbrain3d_left * 20)) issue_code("G1 X{:.3f} F3000 ; approach for second whach".format( v.mechpurge_x_position - v.bigbrain3d_left * 10)) issue_code( "G1 X{:.3f} F1000 ; final position for whack and......".format( v.mechpurge_x_position)) # takes 2.5 seconds issue_code("G1 X{:.3f} F10800 ; WHACKAAAAA!!!!".format( v.mechpurge_x_position - v.bigbrain3d_left * 20))
def generate_blobster_advanced_blob(count): issue_code("\n;---- BLOBSTER ADVANCED BLOB {}".format(count + 1), True) setfanspeed(0) if count > 0: issue_code("G4 P2000 ; Interblob wait") issue_code("G1 X{:.3f} F1000 ; go to the actual wiping position".format( v.mechpurge_x_position)) # takes 2.5 seconds issue_code("G4 P{} ; Wait for Blobster to engage before purging".format( v.blobster_engagetime)) if v.retraction < 0: purgetower.largeunretract() try: for i in range(len(v.blobster_advanced_speed)): setfanspeed(v.blobster_advanced_fan[i]) issue_code("G1 E{:6.3f} F{} ; Purge Part {} ".format( v.blobster_advanced_length[i], v.blobster_advanced_speed[i], i + 1)) except IndexError: if not v.blobsterwarning: gui.log_warning( "BLOBSTER ERROR: THIS FILE WILL NOT PRING AS EXPECTED!!!") v.blobsterwarning = True purgetower.largeretract(v.mechpurge_retract) setfanspeed(255) issue_code("G4 S{0:.0f} ; blob {0}s cooling time".format( v.mechpurge_blob_cooling_time)) issue_code( "G1 X{:.3f} F10800 ; activate flicker".format(v.mechpurge_x_position - v.bigbrain3d_left * 30))
def gcode_parseline(index): g = v.parsed_gcode[index] if g.Command == 'T': gcode_process_toolchange(int(g.Command_value), v.total_material_extruded, g.Layer) if not v.debug_leaveToolCommands: g.move_to_comment("Color Change") g.issue_command() v.toolchange_processed = True return if g.fullcommand in [ "M140", "M190", "M73", "M84", "M201", "M204"]: g.issue_command() return if g.fullcommand in [ "M104" , "M109" ]: if not v.process_temp or not g.Class in [CLS_TOOL_PURGE, CLS_TOOL_START, CLS_TOOL_UNLOAD]: g.add_comment(" Unprocessed temp ") g.issue_command() v.new_temp = g.get_parameter("S", v.current_temp) v.current_temp = v.new_temp else: v.new_temp = g.get_parameter("S", v.current_temp) if v.new_temp >= v.current_temp: g.fullcommand = "M109" v.temp2_stored_command = g.__str__(); g.move_to_comment("delayed temp rise until after purge {}-->{}".format(v.current_temp, v.new_temp)) v.current_temp = v.new_temp else: v.temp1_stored_command = g.__str__(); g.move_to_comment("delayed temp drop until after purge {}-->{}".format(v.current_temp,v.new_temp)) g.issue_command() return if not g.Class in [CLS_TOOL_PURGE, CLS_TOOL_START, CLS_TOOL_UNLOAD] and v.current_temp != v.new_temp: print(v.temp1_stored_command) gcode.issue_code(v.temp1_stored_command) v.temp1_stored_command = "" # fan speed command if g.fullcommand == "M107": g.issue_command() v.saved_fanspeed = 0 return if g.fullcommand == "M106": g.issue_command() v.saved_fanspeed = g.get_parameter("S", v.saved_fanspeed) return # flow rate changes have an effect on the filament consumption. The effect is taken into account for ping generation if g.fullcommand == "M221": v.extrusion_multiplier = float(g.get_parameter("S", v.extrusion_multiplier * 100)) / 100 g.issue_command() return # feed rate changes in the code are removed as they may interfere with the Palette P2 settings if g.fullcommand in ["M220"]: g.move_to_comment("Feed Rate Adjustments are removed") g.issue_command() return if g.is_movement_command(): if g.has_X(): v.previous_purge_keep_x = v.purge_keep_x v.purge_keep_x = g.X if g.has_Y(): v.previous_purge_keep_y = v.purge_keep_y v.purge_keep_y = g.Y v.keep_speed = g.get_parameter("F", v.keep_speed) previous_block_class = v.parsed_gcode[max(0, index - 1)].Class classupdate = g.Class != previous_block_class if classupdate and previous_block_class in [CLS_TOOL_PURGE, CLS_EMPTY]: if v.purge_count > 0: gcode.issue_code( ";>>> Total purge {:4.0f}mm3 - {:4.0f}mm <<<\n".format(purgetower.volfromlength(v.purge_count), v.purge_count)) if classupdate and g.Class in [CLS_TOOL_PURGE, CLS_EMPTY]: v.purge_count = 0 if classupdate and g.Class == CLS_BRIM and v.side_wipe and v.bigbrain3d_purge_enabled: v.side_wipe_length = v.bigbrain3d_prime * v.bigbrain3d_blob_size create_sidewipe_BigBrain3D() if not v.side_wipe: if x_coordinate_in_tower(g.X): v.keep_x = g.X if y_coordinate_in_tower(g.Y): v.keep_y = g.Y # remove M900 K0 commands during unload if g.Class == CLS_TOOL_UNLOAD: if (g.fullcommand == "G4" or (g.fullcommand in ["M900"] and g.get_parameter("K", 0) == 0)): g.move_to_comment("tool unload") ## ALL SITUATIONS ############################################## if g.Class in [CLS_TOOL_START, CLS_TOOL_UNLOAD]: if g.is_movement_command(): if v.side_wipe or v.tower_delta or v.full_purge_reduction: g.move_to_comment("tool unload") else: if g.has_Z(): g.remove_parameter("X") g.remove_parameter("Y") g.remove_parameter("F") g.remove_parameter("E") else: g.move_to_comment("tool unload") g.issue_command() return if g.Class == CLS_TOOL_PURGE and not (v.side_wipe or v.full_purge_reduction): if g.is_movement_command() and g.has_E(): _x = g.get_parameter("X", v.current_position_x) _y = g.get_parameter("Y", v.current_position_y) # removepositive extrusions while moving into the tower if not (coordinate_in_tower(_x, _y) and coordinate_in_tower(v.purge_keep_x, v.purge_keep_y)) and g.E > 0: g.remove_parameter("E") if v.side_wipe: _x = g.get_parameter("X", v.current_position_x) _y = g.get_parameter("Y", v.current_position_y) if not coordinate_on_bed(_x, _y): g.remove_parameter("X") g.remove_parameter("Y") # top off the purge speed in the tower during tower delta or during no tower processing if not v.full_purge_reduction and not v.side_wipe and g.is_movement_command() and g.has_E() and g.has_parameter( "F"): f = int(g.get_parameter("F", 0)) if f > v.purgetopspeed: g.update_parameter("F", v.purgetopspeed) g.add_comment(" prugespeed topped") ## SIDEWIPE / FULLPURGEREDUCTION / TOWER DELTA ############################################### if v.pathprocessing: if g.Class == CLS_TONORMAL: if not g.is_comment(): g.move_to_comment("post block processing") g.issue_command() return # remove any commands that are part of the purge tower and still perofrm actions WITHIN the tower if g.is_movement_command() and g.Class in [CLS_ENDPURGE, CLS_ENDGRID] and g.has_X() and g.has_Y(): if coordinate_in_tower(g.X, g.Y): g.remove_parameter("X") g.remove_parameter("Y") ################################### # sepcific for FULL_PURGE_REDUCTION ################################### if v.full_purge_reduction: if g.Class == CLS_BRIM_END: create_tower_gcode() purgetower.purge_generate_brim() ################################### # sepcific for SIDEWIPE ################################### if v.side_wipe: # side wipe does not need a brim if g.Class == CLS_BRIM: g.move_to_comment("side wipe - removed") g.issue_command() return ####################################### # specific for TOWER DELTA ####################################### # changed for version 4.09.0 moves in tower were going all wrong. if not v.side_wipe and classupdate and g.Class == CLS_TOOL_PURGE: g.issue_command() gcode.issue_code("G1 X{} Y{} F8640;\n".format(v.keep_x, v.keep_y)) v.current_position_x = v.keep_x v.current_position_x = v.keep_y if v.tower_delta: if classupdate and g.Class == CLS_TOOL_PURGE: entertower(g.Layer * v.layer_height + v.first_layer_height) return if classupdate and previous_block_class == CLS_TOOL_PURGE: leavetower() ################################################################ # EMPTY GRID SKIPPING CHECK FOR SIDE WIPE/TOWER DELTA/FULLPURGE ################################################################ if g.Class == CLS_EMPTY and "EMPTY GRID START" in g.get_comment(): if g.Layer < len(v.skippable_layer) and v.skippable_layer[g.Layer]: v.towerskipped = True remove_previous_move_in_tower() if v.tower_delta: v. cur_tower_z_delta += v.layer_height gcode.issue_code(";-------------------------------------\n") gcode.issue_code("; GRID SKIP --TOWER DELTA {:6.2f}mm\n".format(v.cur_tower_z_delta)) gcode.issue_code(";-------------------------------------\n") else: if "EMPTY GRID START" in g.get_comment() and not v.side_wipe: entertower(g.Layer * v.layer_height + v.first_layer_height) # changing from EMPTY to NORMAL ############################### if (previous_block_class == CLS_ENDGRID) and (g.Class == CLS_NORMAL): v.towerskipped = False if v.towerskipped: if not g.is_comment(): g.move_to_comment("tower skipped") g.issue_command() return else: if classupdate and g.Class in [CLS_TOOL_PURGE, CLS_EMPTY]: if v.acc_ping_left <= 0: pings.check_accessorymode_first() v.enterpurge = True if v.enterpurge and g.is_movement_command(): v.enterpurge = False if g.has_X(): _x = v.previous_purge_keep_x else: _x = v.purge_keep_x if g.has_Y(): _y = v.previous_purge_keep_y else: _y = v.purge_keep_y if not coordinate_in_tower(_x, _y): _x = v.purge_keep_x _y = v.purge_keep_y if v.retraction == 0: purgetower.retract(v.current_tool, 3000) gcode.issue_code( "G1 X{:.3f} Y{:.3f} F8640; P2PP Inserted to realign\n".format(v.purge_keep_x, v.purge_keep_y)) v.current_position_x = _x v.current_position_x = _y if v.temp2_stored_command != "": gcode.issue_code(v.temp2_stored_command) v.temp2_stored_command = "" g.remove_parameter("E") if g.get_parameter("X") == _x: g.remove_parameter("X") if len(g.Parameters) == 0: g.move_to_comment("-useless command-") if v.tower_delta: if g.has_E() and g.Class in [CLS_TOOL_UNLOAD, CLS_TOOL_PURGE]: if not inrange(g.X, v.wipe_tower_info['minx'], v.wipe_tower_info['maxx']): g.remove_parameter("E") if not inrange(g.Y, v.wipe_tower_info['miny'], v.wipe_tower_info['maxy']): g.remove_parameter("E") # process movement commands ########################### if not g.has_E(): g.E = 0 if v.full_purge_reduction and g.Class == CLS_NORMAL and classupdate: purgetower.purge_generate_sequence() if g.is_movement_command(): if v.expect_retract and g.has_X() or g.has_Y(): if not v.retraction < 0: if not g.has_E and g.E < 0: purgetower.retract(v.current_tool) v.expect_retract = False if v.retract_move and g.is_retract_command(): # This is going to break stuff, G10 cannot take X and Y, what to do? if v.retract_x: g.update_parameter("X", v.retract_x) else: g.remove_parameter("X") if v.retract_y: g.update_parameter("Y", v.retract_y) else: g.remove_parameter("Y") v.retract_move = False v.current_position_x = g.get_parameter("X", v.current_position_x) v.current_position_y = g.get_parameter("Y", v.current_position_y) v.current_position_z = g.get_parameter("Z", v.current_position_z) if g.Class == CLS_BRIM and v.full_purge_reduction: g.move_to_comment("replaced by P2PP brim code") g.remove_parameter("E") if v.side_wipe or v.full_purge_reduction: if g.Class in [CLS_TOOL_PURGE, CLS_ENDPURGE, CLS_EMPTY]: if g.Layer < len(v.skippable_layer) and v.skippable_layer[g.Layer]: g.move_to_comment("skipped purge") else: v.side_wipe_length += g.E g.move_to_comment("side wipe/full purge") if v.toolchange_processed: if v.side_wipe and g.Class == CLS_NORMAL and classupdate: if v.bigbrain3d_purge_enabled: create_sidewipe_BigBrain3D() else: create_side_wipe() v.toolchange_processed = False if g.Class == CLS_NORMAL: gcode.GCodeCommand(";TOOLCHANGE PROCESSED").issue_command() v.toolchange_processed = False # check here issue with unretract ################################# # g.Comment = " ; - {}".format(v.total_material_extruded) if g.is_retract_command(): if v.retraction <= - (v.retract_length[v.current_tool] - 0.02): g.move_to_comment("Double Retract") else: if g.has_E(): v.retraction += g.E else: v.retraction -= 1 if g.is_unretract_command(): if g.has_E(): g.update_parameter("E", min(-v.retraction, g.E)) v.retraction += g.E else: v.retraction = 0 if (g.has_X() or g.has_Y()) and (g.has_E() and g.E > 0) and v.retraction < 0 and abs(v.retraction) > 0.01: gcode.issue_code(";fixup retracts\n") purgetower.unretract(v.current_tool) # v.retracted = False g.issue_command() ### PING PROCESSING ################### if v.accessory_mode: pings.check_accessorymode_second(g.E) if (g.has_E() and g.E > 0) and v.side_wipe_length == 0: pings.check_connected_ping() v.previous_position_x = v.current_position_x v.previous_position_y = v.current_position_y
def largeretract(value=-3): gcode.issue_code("G1 E-{:.2f} F1200".format(value)) v.retraction -= value
def purge_generate_sequence(): global last_posx, last_posy if last_posx is None: last_posx = v.purge_sequence_x if last_posy is None: last_posy = v.purge_sequence_y if not v.side_wipe_length > 0: return actual = 0 expected = v.side_wipe_length gcode.issue_code("; --------------------------------------------------\n") gcode.issue_code("; --- P2PP WIPE SEQUENCE START FOR {:5.2f}mm\n".format(v.side_wipe_length)) gcode.issue_code( "; --- DELTA = {:.2f}\n".format(v.current_position_z - (v.purgelayer + 1) * v.layer_height)) if v.previous_tool != -1: index = v.previous_tool * 4 + v.current_tool if v.side_wipe_length > v.wiping_info[index]: v.side_wipe_length = v.wiping_info[index] gcode.issue_code( "; --- CORRECTED PURGE TO TRANSITION LENGTH {:.2f}mm\n".format(v.wiping_info[index])) gcode.issue_code("; --------------------------------------------------\n") v.max_tower_delta = max(v.max_tower_delta, v.current_position_z - (v.purgelayer + 1) * v.layer_height) v.min_tower_delta = min(v.min_tower_delta, v.current_position_z - (v.purgelayer + 1) * v.layer_height) if last_posx and last_posy: gcode.issue_code(";retraction {}".format(v.retraction)) if v.retraction == 0: retract(v.current_tool) gcode.issue_code("G1 X{} Y{} F8640 \n".format(last_posx, last_posy)) gcode.issue_code("G1 Z{:.2f} F10800\n".format((v.purgelayer + 1) * v.layer_height)) unretract(v.current_tool) # generate wipe code while v.side_wipe_length > 0: next_command = _purge_get_nextcommand_in_sequence() last_posx = if_defined(next_command.X, last_posx) last_posy = if_defined(next_command.Y, last_posy) v.side_wipe_length -= if_defined(next_command.E, 0) actual += if_defined(next_command.E, 0) next_command.issue_command_speed(getwipespeed()) _purge_update_sequence_index() # return to print height if v.retraction == 0: v.expect_retract = True gcode.issue_code( "G1 Z{:.2f} F10800\n".format(max(v.current_position_z + 0.6, (v.purgelayer + 1) * v.layer_height) + 0.6)) gcode.issue_code("; -------------------------------------\n") gcode.issue_code("; --- P2PP WIPE SEQUENCE END DONE\n") gcode.issue_code("; -------------------------------------\n") # if we extruded more we need to account for that in the total count v.side_wipe_length = 0 v.retract_x = last_posx v.retract_y = last_posy v.expect_retrct = True
def create_sidewipe_BigBrain3D(): if not v.side_wipe or v.side_wipe_length == 0: return # purge blobs should all be same size purgeleft = v.side_wipe_length % v.bigbrain3d_blob_size purgeblobs = int(v.side_wipe_length / v.bigbrain3d_blob_size) if purgeleft > 1: purgeblobs += 1 keepe = v.total_material_extruded correction = v.bigbrain3d_blob_size * purgeblobs - v.side_wipe_length issue_code(";-------------------------------\n") issue_code("; P2PP BB3DBLOBS: {:.0f} BLOBS\n".format(purgeblobs)) issue_code(";-------------------------------\n") issue_code("; Req={:.2f}mm Act={:.2f}mm\n".format( v.side_wipe_length, v.side_wipe_length + correction)) issue_code("; Purge difference {:.2f}mm\n".format(correction)) issue_code(";-------------------------------\n") if v.retraction == 0: purgetower.largeretract() keep_xpos = v.current_position_x keep_ypos = v.current_position_y if (v.current_position_z < 20): issue_code( "\nG1 Z20.000 F8640 ; Increase Z to prevent collission with bed\n" ) issue_code("G1 X{:.3f} F10800 ; go near edge of bed\n".format( v.bigbrain3d_x_position - 30)) issue_code("G4 S0 ; wait for the print buffer to clear\n") issue_code("M907 X{} ; increase motor power\n".format( v.bigbrain3d_motorpower_high)) issue_code("; Generating {} blobs for {}mm of purge".format( purgeblobs, v.side_wipe_length)) for i in range(purgeblobs): generate_blob(v.bigbrain3d_blob_size, i) if (v.current_position_z < 20): if v.retraction != 0: purgetower.retract(v.current_tool) issue_code("\nG1 X{:.3f} Y{:.3f} F8640".format(keep_xpos, keep_ypos)) issue_code( "\nG1 Z{:.4f} F8640 ; Reset correct Z height to continue print\n" .format(v.current_position_z)) resetfanspeed() issue_code("\nM907 X{} ; reset motor power\n".format( v.bigbrain3d_motorpower_normal)) issue_code("\n;-------------------------------\n\n") v.side_wipe_length = 0
def purge_generate_sequence(): global last_posx, last_posy if last_posx is None: last_posx = v.purge_sequence_x if last_posy is None: last_posy = v.purge_sequence_y if not v.side_wipe_length > 0: return actual = 0 gcode.issue_code("; --------------------------------------------------", True) gcode.issue_code("; --- P2PP WIPE SEQUENCE START FOR {:5.2f}mm".format(v.side_wipe_length), True) gcode.issue_code( "; --- DELTA = {:.2f}".format(v.current_position_z - (v.purgelayer + 1) * v.layer_height), True) # # if v.previous_tool != -1: # index = v.previous_tool * 4 + v.current_tool # if v.side_wipe_length > v.wiping_info[index]: # v.side_wipe_length = v.wiping_info[index] # gcode.issue_code( # "; --- CORRECTED PURGE TO TRANSITION LENGTH {:.2f}mm\n".format(v.wiping_info[index])) # gcode.issue_code("; --------------------------------------------------\n") v.max_tower_delta = max(v.max_tower_delta, v.current_position_z - (v.purgelayer + 1) * v.layer_height) v.min_tower_delta = min(v.min_tower_delta, v.current_position_z - (v.purgelayer + 1) * v.layer_height) if last_posx and last_posy: # gcode.issue_code(";retraction {}".format(v.retraction)) if v.retraction == 0: retract(v.current_tool) gcode.issue_code("G1 X{} Y{} F8640".format(last_posx, last_posy)) if v.manual_filament_swap: swap.swap_pause("M25") # no need to unpause as the reauired Z-move is part of the remaining sequence gcode.issue_code("G1 Z{:.2f} F10800".format((v.purgelayer + 1) * v.layer_height)) unretract(v.current_tool) # p2pp_process_file wipe code while v.side_wipe_length > 0: next_command = _purge_get_nextcommand_in_sequence() last_posx = if_defined(next_command[gcode.X], last_posx) last_posy = if_defined(next_command[gcode.Y], last_posy) v.side_wipe_length -= if_defined(next_command[gcode.E], 0) actual += if_defined(next_command[gcode.E], 0) gcode.issue_command(next_command, getwipespeed()) _purge_update_sequence_index() # return to print height retract(v.current_tool) if v.retraction == 0: v.expect_retract = True gcode.issue_code( "G1 Z{:.2f} F10800\n".format(max(v.current_position_z + 0.6, (v.purgelayer + 1) * v.layer_height) + 0.6)) gcode.issue_code("; -------------------------------------", True) gcode.issue_code("; --- P2PP WIPE SEQUENCE END DONE", True) gcode.issue_code("; -------------------------------------", True) # if we extruded more we need to account for that in the total count v.side_wipe_length = 0 v.retract_x = last_posx v.retract_y = last_posy v.expect_retract = True
def create_sidewipe_BigBrain3D(): if not v.side_wipe or v.side_wipe_length == 0: return # purge blobs should all be same size purgeleft = v.side_wipe_length % v.bigbrain3d_blob_size purgeblobs = int(v.side_wipe_length / v.bigbrain3d_blob_size) if purgeleft > 1: purgeblobs += 1 correction = v.bigbrain3d_blob_size - purgeleft else: correction = -purgeleft issue_code(";-------------------------------\n") issue_code("; P2PP BB3DBLOBS: {:.0f} BLOBS\n".format(purgeblobs)) issue_code(";-------------------------------\n") issue_code("; Req={:.2f}mm Act={:.2f}mm\n".format( v.side_wipe_length, v.side_wipe_length + correction)) issue_code("; Purge difference {:.2f}mm\n".format(correction)) issue_code(";-------------------------------\n") v.total_material_extruded += correction * v.extrusion_multiplier * v.extrusion_multiplier_correction v.material_extruded_per_color[ v. current_tool] += correction * v.extrusion_multiplier * v.extrusion_multiplier_correction if v.retraction == 0: purgetower.retract(v.current_tool) if (v.current_position_z < 25): issue_code( "\nG1 Z25.000 F8640 ; Increase Z to prevent collission with bed\n" ) issue_code("G1 X{:.3f} F10800 ; go near edge of bed\n".format( v.bigbrain3d_x_position - 30)) issue_code("G4 S0 ; wait for the print buffer to clear\n") issue_code("M907 X{} ; increase motor power\n".format( v.bigbrain3d_motorpower_high)) for i in range(purgeblobs): generate_blob(v.bigbrain3d_blob_size, i) # NOT NEEDED # if (v.current_position_z < 25): # issue_code("\nG1 Z{:.4f} F8640 ; Reset correct Z height to continue print\n".format(v.current_position_z)) resetfanspeed() issue_code("\nM907 X{} ; reset motor power\n".format( v.bigbrain3d_motorpower_normal)) issue_code("\n;-------------------------------\n\n") v.side_wipe_length = 0
def generate_blob(length, count): issue_code( "\n;---- BIGBRAIN3D SIDEWIPE BLOB {} -- purge {:.3f}mm\n".format( count + 1, length)) # issue_code("M907 X{} ; set motor power\n".format(int(v.purgemotorpower))) issue_code("G1 X{:.3f} F3000 ; go near the edge of the print\n".format( v.bigbrain3d_x_position - 10)) issue_code( "G1 X{:.3f} F1000 ; go to the actual wiping position\n".format( v.bigbrain3d_x_position)) # takes 2.5 seconds setfanspeed(0) if v.retraction < 0: purgetower.unretract(v.current_tool, 1200) if v.bigbrain3d_smartfan: issue_code("G1 E{:6.3f} F200 ; Purge FAN OFF \n".format(length / 4)) setfanspeed(64) issue_code("G1 E{:6.3f} F200 ; Purge FAN 25% \n".format(length / 4)) setfanspeed(128) issue_code("G1 E{:6.3f} F200 ; Purge FAN 50% \n".format(length / 4)) setfanspeed(192) issue_code("G1 E{:6.3f} F200 ; Purge FAN 75% \n".format(length / 4)) else: issue_code( "G1 E{:6.3f} F200 ; UNRETRACT/PURGE/RETRACT \n".format(length)) purgetower.retract(v.current_tool, 1200) setfanspeed(255) issue_code("G4 S{0:.0f} ; blob {0}s cooling time\n".format( v.bigbrain3d_blob_cooling_time)) issue_code("G1 X{:.3f} F10800 ; activate flicker\n".format( v.bigbrain3d_x_position - 20)) issue_code("G4 S1 ; Mentally prep for second whack\n".format( v.bigbrain3d_x_position - 20)) issue_code("G1 X{:.3f} F3000 ; approach for second whach\n".format( v.bigbrain3d_x_position - 10)) issue_code( "G1 X{:.3f} F1000 ; final position for whack and......\n".format( v.bigbrain3d_x_position)) # takes 2.5 seconds issue_code("G1 X{:.3f} F10800 ; WHACKAAAAA!!!!\n".format( v.bigbrain3d_x_position - 20))
def create_side_wipe(): if not v.side_wipe or v.side_wipe_length == 0: return issue_code(";---------------------------\n") issue_code("; P2PP SIDE WIPE: {:7.3f}mm\n".format(v.side_wipe_length)) for line in v.before_sidewipe_gcode: issue_code(line + "\n") if v.retraction == 0: purgetower.retract(v.current_tool) issue_code("G1 F8640\n") issue_code("G0 {} Y{}\n".format(v.side_wipe_loc, v.sidewipe_miny)) sweep_base_speed = v.wipe_feedrate * 20 * abs(v.sidewipe_maxy - v.sidewipe_miny) / 150 sweep_length = 20 yrange = [v.sidewipe_maxy, v.sidewipe_miny] rangeidx = 0 moveto = yrange[rangeidx] purgetower.unretract(v.current_tool) while v.side_wipe_length > 0: sweep = min(v.side_wipe_length, sweep_length) v.side_wipe_length -= sweep_length wipe_speed = min(5000, int(sweep_base_speed / sweep)) issue_code("G1 {} Y{} E{:.5f} F{}\n".format( v.side_wipe_loc, moveto, sweep * v.sidewipe_correction, wipe_speed)) rangeidx += 1 moveto = yrange[rangeidx % 2] for line in v.after_sidewipe_gcode: issue_code(line + "\n") purgetower.retract(v.current_tool) issue_code("G1 F8640\n") issue_code(";---------------------------\n") v.side_wipe_length = 0
def gcode_parseline(index): g = v.parsedgcode[index] block_class = v.gcodeclass[index] previous_block_class = v.gcodeclass[max(0, index - 1)] classupdate = block_class != previous_block_class if g.Command == 'T': gcode_process_toolchange(int(g.Command_value), v.total_material_extruded, g.Layer) g.move_to_comment("Color Change") g.issue_command() return if g.fullcommand in [ "M104", "M109", "M140", "M190", "M73", "M84", "M201", "M204" ]: g.issue_command() return # fan speed command if g.fullcommand == "M107": g.issue_command() v.saved_fanspeed = 0 return if g.fullcommand == "M106": g.issue_command() v.saved_fanspeed = g.get_parameter("S", v.saved_fanspeed) return if block_class == CLS_TOOL_UNLOAD and g.fullcommand in [ "M900" ] and g.get_parameter("K", 0) == 0: g.move_to_comment("tool unload") if g.fullcommand in ["M220"]: g.move_to_comment("Flow Rate Adjustments are removed") g.issue_command() return if g.fullcommand == "M221": v.extrusion_multiplier = float( g.get_parameter("S", v.extrusion_multiplier * 100)) / 100 g.issue_command() return if g.is_movement_command(): if g.has_X(): v.previous_purge_keep_x = v.purge_keep_x v.purge_keep_x = g.X if g.has_Y(): v.previous_purge_keep_y = v.purge_keep_y v.purge_keep_y = g.Y ## ALL SITUATIONS ############################################## if block_class in [CLS_TOOL_START, CLS_TOOL_UNLOAD]: if g.fullcommand == "G4": g.move_to_comment("tool unload") if g.is_movement_command(): if g.has_Z(): g.remove_parameter("X") g.remove_parameter("Y") g.remove_parameter("F") g.remove_parameter("E") else: g.move_to_comment("tool unload") g.issue_command() return if block_class == CLS_TOOL_PURGE and not (v.side_wipe or v.full_purge_reduction): if g.is_movement_command(): _x = g.get_parameter("X", v.current_position_x) _y = g.get_parameter("Y", v.current_position_y) if not (coordinate_in_tower(_x, _y) and coordinate_in_tower(v.purge_keep_x, v.purge_keep_y)): g.remove_parameter("E") if not v.side_wipe: if g.has_X(): if v.wipe_tower_info['minx'] <= g.X <= v.wipe_tower_info['maxx']: v.keep_x = g.X if g.has_Y(): if v.wipe_tower_info['miny'] <= g.Y <= v.wipe_tower_info['maxy']: v.keep_y = g.Y elif not x_on_bed(g.X): g.remove_parameter("X") ## SIDEWIPE / FULLPURGEREDUCTION / TOWER DELTA ############################################### if v.pathprocessing: if block_class == CLS_TONORMAL: if not g.is_comment(): g.move_to_comment("post block processing") g.issue_command() return if flagset(v.parsecomment[index], SPEC_INTOWER): if coordinate_in_tower(g.X, g.Y): g.remove_parameter("X") g.remove_parameter("Y") # sepcific for FULL_PURGE_REDUCTION if v.full_purge_reduction: # get information about the purge tower dimensions if block_class == CLS_BRIM and not (g.has_X() and g.has_Y()): if g.has_X(): purgetower.purge_width = min( purgetower.purge_width, abs(g.X - v.previous_position_x)) if g.has_Y(): purgetower.purge_height = min( purgetower.purge_height, abs(g.Y - v.previous_position_y)) if block_class == CLS_BRIM_END: # generate a purge tower alternative _x = v.wipe_tower_info['minx'] + 4 * v.extrusion_width _y = v.wipe_tower_info['miny'] + 4 * v.extrusion_width _w = v.wipe_tower_info['maxx'] - v.wipe_tower_info[ 'minx'] - 8 * v.extrusion_width _h = v.wipe_tower_info['maxy'] - v.wipe_tower_info[ 'miny'] - 8 * v.extrusion_width purgetower.purge_create_layers(_x, _y, _w, _h) # generate og items for the new purge tower gui.create_logitem( " Purge Tower :Loc X{:.2f} Y{:.2f} W{:.2f} H{:.2f}". format(_x, _y, _w, _h)) gui.create_logitem( " Layer Length Solid={:.2f}mm Sparse={:.2f}mm".format( purgetower.sequence_length_solid, purgetower.sequence_length_empty)) # issue the new purge tower for i in range(len(purgetower.brimlayer)): purgetower.brimlayer[i].issue_command() if i == 1 and v.retraction: purgetower.unretract(v.current_tool) # set the flag to update the post-session retraction move section v.retract_move = True v.retract_x = purgetower.last_brim_x v.retract_y = purgetower.last_brim_y # correct the amount of extrusion for the brim # sepcific for SIDEWIPE if v.side_wipe: # side wipe does not need a brim if block_class == CLS_BRIM: if not g.is_comment(): g.move_to_comment("side wipe - removed") g.issue_command() return # entering the purge tower with a delta ######################################## if v.tower_delta: if classupdate: if block_class == CLS_TOOL_PURGE: g.issue_command() gcode.issue_code("G1 X{} Y{} ;\n".format( v.keep_x, v.keep_y)) v.current_position_x = v.keep_x v.current_position_x = v.keep_y entertower(g.Layer * v.layer_height) return # going into an empty grid -- check if it should be consolidated ################################################################ if classupdate and block_class in [CLS_FIRST_EMPTY, CLS_EMPTY]: if v.skippable_layer[v.layernumber[index]]: v.towerskipped = True # print("Skipped: {:.3f} now at delta {:.3f}".format(v.current_position_z- v.retract_lift[v.current_tool]+v.layer_height,v.cur_tower_z_delta+v.layer_height)) remove_previous_move_in_tower() if v.tower_delta and "CP EMPTY GRID START" in g.Comment: v.cur_tower_z_delta += v.layer_height gcode.issue_code( ";-------------------------------------\n") gcode.issue_code( "; GRID SKIP --TOWER DELTA {:6.2f}mm\n".format( v.cur_tower_z_delta)) gcode.issue_code( ";-------------------------------------\n") # changing from EMPTY to NORMAL ############################### if (previous_block_class == CLS_ENDGRID) and (block_class == CLS_NORMAL): v.towerskipped = False if v.towerskipped: if not g.is_comment(): g.move_to_comment("tower skipped") g.issue_command() return else: if classupdate and block_class in [CLS_TOOL_PURGE, CLS_EMPTY]: if v.acc_ping_left <= 0: pings.check_accessorymode_first() v.enterpurge = True if v.enterpurge and g.is_movement_command(): v.enterpurge = False if g.has_X(): _x = v.previous_purge_keep_x else: _x = v.purge_keep_x if g.has_Y(): _y = v.previous_purge_keep_y else: _y = v.purge_keep_y if not coordinate_in_tower(_x, _y): _x = v.purge_keep_x _y = v.purge_keep_y gcode.issue_code( "G1 X{:.3f} Y{:.3f}; P2PP Inserted to realign\n".format( v.purge_keep_x, v.purge_keep_y)) v.current_position_x = _x v.current_position_x = _y g.remove_parameter("E") if g.get_parameter("X") == _x: g.remove_parameter("X") if len(g.Parameters) == 0: g.move_to_comment("-useless command-") if v.tower_delta: if g.has_E() and block_class in [CLS_TOOL_UNLOAD, CLS_TOOL_PURGE]: if not inrange(g.X, v.wipe_tower_info['minx'], v.wipe_tower_info['maxx']): g.remove_parameter("E") if not inrange(g.Y, v.wipe_tower_info['miny'], v.wipe_tower_info['maxy']): g.remove_parameter("E") # process movement commands ########################### if not g.has_E(): g.E = 0 if v.full_purge_reduction and block_class == CLS_NORMAL and classupdate: purgetower.purge_generate_sequence() if g.is_movement_command(): if v.expect_retract and g.has_X() or g.has_Y(): if not v.retraction < 0: if not g.has_E and g.E < 0: purgetower.retract(v.current_tool) v.expect_retract = False if v.retract_move and g.is_retract_command(): # This is going to break stuff, G10 cannot take X and Y, what to do? if v.retract_x: g.update_parameter("X", v.retract_x) else: g.remove_parameter("X") if v.retract_y: g.update_parameter("Y", v.retract_y) else: g.remove_parameter("Y") v.retract_move = False v.current_position_x = g.get_parameter("X", v.current_position_x) v.current_position_y = g.get_parameter("Y", v.current_position_y) v.current_position_z = g.get_parameter("Z", v.current_position_z) if block_class == CLS_BRIM and v.full_purge_reduction: g.move_to_comment("replaced by P2PP brim code") g.remove_parameter("E") if v.side_wipe or v.full_purge_reduction: if block_class in [ CLS_TOOL_PURGE, CLS_ENDPURGE, CLS_EMPTY, CLS_FIRST_EMPTY ]: if v.skippable_layer[g.Layer]: g.move_to_comment("skipped purge") else: v.side_wipe_length += g.E g.move_to_comment("side wipe/full purge") if v.side_wipe and block_class == CLS_NORMAL and classupdate: if v.bigbrain3d_purge_enabled: create_sidewipe_BigBrain3D() else: create_side_wipe() # check here issue with unretract ################################# # g.Comment = " ; - {}".format(v.total_material_extruded) if g.is_retract_command(): if g.has_E(): v.retraction += g.E else: v.retraction -= 1 if g.is_unretract_command(): if g.has_E(): v.retraction = min(0, v.retraction + g.E) else: v.retraction = 0 if (g.has_X() or g.has_Y()) and (g.has_E() and g.E > 0) and v.retraction < 0 and abs( v.retraction) > 0.01: gcode.issue_code(";fixup retracts\n") purgetower.unretract(v.current_tool) # v.retracted = False g.issue_command() ### PING PROCESSING ################### if v.accessory_mode: pings.check_accessorymode_second(g.E) if (g.has_E() and g.E > 0) and v.side_wipe_length == 0: pings.check_connected_ping() v.previous_position_x = v.current_position_x v.previous_position_y = v.current_position_y
def setfanspeed(n): if n == 0: issue_code("M107 ; Turn FAN OFF") else: issue_code("M106 S{} ; Set FAN Power".format(n))
def largeunretract(): if v.retraction != 0: gcode.issue_code("G1 E{:.2f} F2400".format(-v.retraction)) v.retraction = 0
def generate_blobster_blob(length, count): issue_code( "\n;---- BLOBSTER SIDEWIPE BLOB {} -- purge {:.3f}mm".format( count + 1, length), True) setfanspeed(0) if count > 0: issue_code("G4 P2000 ; Interblob wait") issue_code("G1 X{:.3f} F1000 ; go to the actual wiping position".format( v.mechpurge_x_position)) # takes 2.5 seconds issue_code("G4 P{} ; Wait for Blobster to engage before purging".format( v.blobster_engagetime)) if v.retraction < 0: purgetower.largeunretract() if v.mechpurge_smartfan: issue_code("G1 E{:6.3f} F{} ; Purge FAN OFF ".format( length / 4, v.mechpurge_blob_speed)) setfanspeed(32) issue_code("G1 E{:6.3f} F{} ; Purge FAN 12% ".format( length / 4, v.mechpurge_blob_speed)) setfanspeed(64) issue_code("G1 E{:6.3f} F{} ; Purge FAN 25% ".format( length / 4, v.mechpurge_blob_speed)) setfanspeed(96) issue_code("G1 E{:6.3f} F{} ; Purge FAN 37% ".format( length / 4, v.mechpurge_blob_speed)) else: issue_code("G1 E{:6.3f} F{} ; Purge Part 1 ".format( length - 8, v.mechpurge_blob_speed)) issue_code("G1 E8.000 F{} ; Purge Part 2 ".format( v.mechpurge_blob_speed / 2)) purgetower.largeretract(v.mechpurge_retract) setfanspeed(255) issue_code("G4 S{0:.0f} ; blob {0}s cooling time".format( v.mechpurge_blob_cooling_time)) issue_code( "G1 X{:.3f} F10800 ; activate flicker".format(v.mechpurge_x_position - v.bigbrain3d_left * 30))
def check_accessorymode_second(e): nextline = None if v.accessory_mode and (v.acc_ping_left > 0): if v.acc_ping_left >= e: v.acc_ping_left -= e else: proc = v.acc_ping_left / e int_x = interpollate(v.previous_position_x, v.current_position_x, proc) int_y = interpollate(v.previous_position_y, v.current_position_y, proc) to_z = v.current_position_z gcode.issue_code("G1 X{:.4f} Y{:.4f} Z{:.4f} E{:.4f}\n".format(int_x, int_y, to_z, v.acc_ping_left)) e -= v.acc_ping_left v.acc_ping_left = 0 nextline = "G1 X{:.4f} Y{:.4f} E{:.4f}\n".format(v.current_position_x, v.current_position_y, e) if v.acc_ping_left <= 0.1: gcode.issue_code("; -------------------------------------\n") gcode.issue_code("; --- P2PP - ACCESSORY MODE PING PART 2\n") gcode.issue_code(acc_second_pause) gcode.issue_code("; -------------------------------------\n") v.ping_interval = v.ping_interval * v.ping_length_multiplier v.ping_interval = min(v.max_ping_interval, v.ping_interval) v.last_ping_extruder_position = v.total_material_extruded v.ping_extruder_position.append(v.total_material_extruded - 20 + v.acc_ping_left) v.ping_extrusion_between_pause.append(20 - v.acc_ping_left) v.acc_ping_left = 0 if nextline: gcode.issue_code(nextline)
def entertower(layer_hght): purgeheight = layer_hght - v.cur_tower_z_delta if v.current_position_z != purgeheight: v.max_tower_delta = max(v.cur_tower_z_delta, v.max_tower_delta) gcode.issue_code(";------------------------------\n") gcode.issue_code("; P2PP DELTA ENTER\n") gcode.issue_code( "; Current Z-Height = {:.2f}; Tower height = {:.2f}; delta = {:.2f} [ {} ]".format(v.current_position_z, purgeheight, v.current_position_z - purgeheight, layer_hght)) if v.retraction >= 0: purgetower.retract(v.current_tool) gcode.issue_code( "G1 Z{:.2f} F10810\n".format(purgeheight)) # purgetower.unretract(v.current_tool) gcode.issue_code(";------------------------------\n") if purgeheight <= 0.21: gcode.issue_code("G1 F{}\n".format(min(1200, v.wipe_feedrate))) else: gcode.issue_code("G1 F{}\n".format(v.wipe_feedrate))