Skip to content

Commit

Permalink
Merge pull request #101 from AstroPrint/confirm-bed-clear
Browse files Browse the repository at this point in the history
Confirm bed clear
  • Loading branch information
CoDanny authored Nov 30, 2020
2 parents d1772c3 + 1af4c67 commit bdb9b40
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 7 deletions.
19 changes: 14 additions & 5 deletions octoprint_astroprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,18 @@ def capabilities(self):
capabilities = ['remotePrint', # Indicates whether this device supports starting a print job remotely
'multiExtruders', # Support for multiple extruders
'allowPrintFile', # Support for printing a printfile not belonging to any design
'acceptPrintJobId', # Accept created print job from cloud,
'cleanState' # Support bed not clean state
'acceptPrintJobId' # Accept created print job from cloud,
]
if self._settings.get(["check_clear_bed"]) :
capabilities.append('cleanState') # Support bed not clean state
return capabilities

def on_startup(self, host, port, *args, **kwargs):
self._logger.info("Starting AstoPrint Plugin")
self.register_printer_listener()
self.db = AstroprintDB(self)
if not self._settings.get(['check_clear_bed']):
self.set_bed_clear(True)

## Move old mysql database data to new yaml file for logged users
oldDbFile = os.path.join(self.get_plugin_data_folder(),"octoprint_astroprint.db")
Expand Down Expand Up @@ -184,7 +187,10 @@ def get_printer(self):

@property
def isBedClear(self):
return self._bed_clear
if self._settings.get(['check_clear_bed']):
return self._bed_clear
else:
return True

def set_bed_clear(self, clear, sendUpdate = False):
if clear != self._bed_clear:
Expand Down Expand Up @@ -261,6 +267,7 @@ def get_settings_defaults(self):
filament = {'name' : None, 'color' : None},
camera = False,
bedClear = True,
check_clear_bed = True,
#Adittional printer settings
max_nozzle_temp = 280, #only for being set by AstroPrintCloud, it wont affect octoprint settings
max_bed_temp = 140,
Expand Down Expand Up @@ -370,15 +377,17 @@ def on_event(self, event, payload):

elif event == Events.PRINT_CANCELLED or event == Events.PRINT_FAILED:
self.send_event("canPrint", True)
self.set_bed_clear(False)
if self._settings.get(['check_clear_bed']):
self.set_bed_clear(False)
if self.user and self.astroprintCloud.currentPrintingJob:
self.astroprintCloud.updatePrintJob("failed", self.materialCounter.totalConsumedFilament)
self.astroprintCloud.currentPrintingJob = None
self.cameraManager.stop_timelapse()
self._analyzed_job_layers = None

elif event == Events.PRINT_DONE:
self.set_bed_clear(False)
if self._settings.get(['check_clear_bed']):
self.set_bed_clear(False)
if self.user and self.astroprintCloud.currentPrintingJob:
self.astroprintCloud.updatePrintJob("success", self.materialCounter.totalConsumedFilament)
self.astroprintCloud.currentPrintingJob = None
Expand Down
3 changes: 2 additions & 1 deletion octoprint_astroprint/boxrouter/handlers/requesthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,6 @@ def photo(self, data, clientId, done):
})

def set_bed_clear(self, clear, _, done):
self.plugin.set_bed_clear(clear)
if self._settings.get(['check_clear_bed']):
self.plugin.set_bed_clear(clear)
done(None)
60 changes: 60 additions & 0 deletions octoprint_astroprint/static/css/astroprint.css
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,63 @@
margin-left: 10px;
color: rgba(0, 135, 205, 0.3);
}

.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}

.switch input {
opacity: 0;
width: 0;
height: 0;
}

.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}

.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}

input:checked + .slider {
background-color: #2196F3;
}

input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
border-radius: 34px;
}

.slider.round:before {
border-radius: 50%;
}
7 changes: 7 additions & 0 deletions octoprint_astroprint/templates/astroprint_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@
<span class="add-on">°C</span>
</div>
</div>
<div>
<label>Confirm bed clear: </label>
<label class="switch">
<input type="checkbox" data-bind="checked: settings.settings.plugins.astroprint.check_clear_bed">
<span class="slider round"></span>
</label>
</div>
</div>
<div data-bind="ifnot: settings.settings.api.allowCrossOrigin">
<h3>Remote Control Options</h3>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "AstroPrint"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.6.2"
plugin_version = "1.6.3"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit bdb9b40

Please sign in to comment.