def __init__(self, loader_changer, robosm, name, **kwargs): super(FilamentWizard, self).__init__(**kwargs) # first screen defined in .kv file self.sm = robosm self.name = name #name of initial screen self.load_or_change = loader_changer #check if the printer is printing current_data = roboprinter.printer_instance._printer.get_current_data() self.is_printing = current_data['state']['flags']['printing'] self.is_paused = current_data['state']['flags']['paused'] self.tmp_event = None self.s_event = None self.E_Position = None if self.is_printing or self.is_paused: #get the E Position pos = pconsole.get_position() while not pos: pos = pconsole.get_position() self.E_Position = pos[3] self.first_screen(**kwargs) self.poll_temp() #populates self.temp
def warn_and_restart(self): pos = pconsole.get_position() while not pos: pos = pconsole.get_position() drop = self.drop_amount - float(pos[2]) Logger.info("Dropping to: " + str(drop)) roboprinter.printer_instance._printer.commands('M400')#Wait for all previous commands to finish (Clear the buffer) ################################################################################################################# #Get off of the endstop so the Z axis works... #get bed dimensions bed_x = roboprinter.printer_instance._settings.global_get(['printerProfiles','defaultProfile', 'volume','width']) bed_y = roboprinter.printer_instance._settings.global_get(['printerProfiles','defaultProfile', 'volume','depth']) #calculate final positions bed_x = float(bed_x) / 2.0 bed_y = float(bed_y) / 2.0 roboprinter.printer_instance._printer.commands('G1 X' + str(bed_x) + ' Y' + str(bed_y) +' F10000') ################################################################################################################# roboprinter.printer_instance._printer.commands('G1 Z'+ str(drop) + ' F5000') roboprinter.printer_instance._printer.commands('G1 X'+ str(self.start_pos_x) + ' Y'+ str(self.start_pos_y) + ' F5000') # go to first corner layout = Button_Screen(roboprinter.lang.pack['FT_ZOffset_Wizard']['Warn_Restart']['Body'] , self.restart) title = roboprinter.lang.pack['FT_ZOffset_Wizard']['Warn_Restart']['Title'] name = 'line_restart' back_destination = roboprinter.robo_screen() roboprinter.back_screen( name=name, title=title, back_destination=back_destination, content=layout )
def _capture_zpos(self): """gets position from pconsole. :returns: integer""" Logger.info("ZCapture: Init") p = pconsole.get_position() while p == False: p = pconsole.get_position() Logger.info("ZCapture: {}".format(p)) return p[2]
def restart(self): roboprinter.printer_instance._printer.commands('M400')#Wait for all previous commands to finish (Clear the buffer) roboprinter.printer_instance._printer.commands('G1 X'+ str(self.start_pos_x) + ' Y'+ str(self.start_pos_y) + ' F5000') # go to first corner roboprinter.printer_instance._printer.commands('G1 Z5') self.x = self.start_pos_x #update position pconsole.get_position() pconsole.get_position() self.user_set_mode()
def position_callback(self, dt): temps = roboprinter.printer_instance._printer.get_current_temperatures( ) pos = pconsole.get_position() if pos != False: xpos = int(float(pos[0])) ypos = int(float(pos[1])) zpos = int(float(pos[2])) extruder_one_temp = 105 #find the temperature if 'tool0' in temps.keys(): extruder_one_temp = temps['tool0']['actual'] Logger.info("Counter is at: " + str(self.counter)) #check the extruder physical position if self.counter > 25 and xpos == self.old_xpos and ypos == self.old_ypos and zpos == self.old_zpos: if self.sm.current == 'zoffset[1]': if extruder_one_temp < 100: Logger.info('Succesfully found position') self.third_screen() return False else: self.temperature_wait_screen() return False else: Logger.info( 'User went to a different screen Unscheduling self.') #turn off fan roboprinter.printer_instance._printer.commands('M106 S0') return False #if finding the position fails it will wait 30 seconds and continue self.counter += 1 if self.counter > 60: if self.sm.current == 'zoffset[1]': Logger.info( 'could not find position, but continuing anyway') if extruder_one_temp < 100: self.third_screen() return False else: self.temperature_wait_screen() return False else: Logger.info( 'User went to a different screen Unscheduling self.') #turn off fan roboprinter.printer_instance._printer.commands('M106 S0') return False #position tracking self.old_xpos = xpos self.old_ypos = ypos self.old_zpos = zpos
def make_line(self): if not self.line_lock: #Lock the button down for a better user experience self.line_lock = True Logger.info("Locked!") Clock.schedule_once(self.unlock, 18.00) pos = pconsole.get_position() while not pos: pos = pconsole.get_position() Logger.info("self.x is at: " + str(self.x) + " position x is at: " + str(pos[0])) if self.mode == "L2R": if float(pos[0]) < self.max_x_travel: self._line() else: self.warn_and_restart() elif self.mode == "R2L": if float(pos[0]) > self.max_x_travel: self._line() else: self.warn_and_restart()
def check_position(self, dt): ready = pconsole.busy Logger.info(ready) if not ready: self.countz = pconsole.get_position() if self.countz: Logger.info("Count Z: " + str(self.countz[6]) + " last Count Z: " + str(self.last_countz)) if int(self.countz[6]) == int(self.last_countz): #go to the next screen Logger.info("GO TO NEXT SCREEN! ###########") self.callback() return False self.last_countz = self.countz[6] else: Logger.info("Pconsole is not ready")