5
5
import octoprint .util
6
6
import flask
7
7
import json
8
+ import yaml
9
+ import os
8
10
import time
9
11
from io import BytesIO
10
12
from octoprint .server .util .flask import restricted_access
@@ -53,27 +55,24 @@ def _update_driver_settings(self):
53
55
54
56
# part of SettingsPlugin
55
57
def get_settings_defaults (self ):
58
+ base = os .path .dirname (__file__ )
59
+ with open (os .path .join (base , "data/printer_profiles.yaml" ), "r" ) as f :
60
+ self ._printer_profiles = yaml .safe_load (f .read ())['PrinterProfile' ]
61
+ with open (os .path .join (base , "data/gcode_scripts.yaml" ), "r" ) as f :
62
+ self ._gcode_scripts = yaml .safe_load (f .read ())['GScript' ]
63
+
56
64
d = {}
57
65
d [QUEUE_KEY ] = "[]"
58
- d [CLEARING_SCRIPT_KEY ] = (
59
- "M17 ;enable steppers\n "
60
- "G91 ; Set relative for lift\n "
61
- "G0 Z10 ; lift z by 10\n "
62
- "G90 ;back to absolute positioning\n "
63
- "M190 R25 ; set bed to 25 and wait for cooldown\n "
64
- "G0 X200 Y235 ;move to back corner\n "
65
- "G0 X110 Y235 ;move to mid bed aft\n "
66
- "G0 Z1 ;come down to 1MM from bed\n "
67
- "G0 Y0 ;wipe forward\n "
68
- "G0 Y235 ;wipe aft\n "
69
- "G28 ; home"
70
- )
71
- d [FINISHED_SCRIPT_KEY ] = (
72
- "M18 ; disable steppers\n "
73
- "M104 T0 S0 ; extruder heater off\n "
74
- "M140 S0 ; heated bed heater off\n "
75
- "M300 S880 P300 ; beep to show its finished"
76
- )
66
+ d [CLEARING_SCRIPT_KEY ] = ""
67
+ d [FINISHED_SCRIPT_KEY ] = ""
68
+
69
+ for s in self ._gcode_scripts :
70
+ name = s ['name' ]
71
+ gcode = s ['gcode' ]
72
+ if name == "Pause" :
73
+ d [CLEARING_SCRIPT_KEY ] = gcode
74
+ elif name == "Generic Off" :
75
+ d [FINISHED_SCRIPT_KEY ] = gcode
77
76
d [RESTART_MAX_RETRIES_KEY ] = 3
78
77
d [RESTART_ON_PAUSE_KEY ] = False
79
78
d [RESTART_MAX_TIME_KEY ] = 60 * 60
@@ -441,25 +440,15 @@ def reset(self):
441
440
# part of TemplatePlugin
442
441
def get_template_vars (self ):
443
442
return dict (
444
- cp_enabled = (self .d .active if hasattr (self , "d" ) else False ),
445
- cp_bed_clearing_script = self ._settings .get ([CLEARING_SCRIPT_KEY ]),
446
- cp_queue_finished = self ._settings .get ([FINISHED_SCRIPT_KEY ]),
447
- cp_restart_on_pause_enabled = self ._settings .get_boolean (
448
- [RESTART_ON_PAUSE_KEY ]
449
- ),
450
- cp_restart_on_pause_max_seconds = self ._settings .get_int (
451
- [RESTART_MAX_TIME_KEY ]
452
- ),
453
- cp_restart_on_pause_max_restarts = self ._settings .get_int (
454
- [RESTART_MAX_RETRIES_KEY ]
455
- ),
443
+ printer_profiles = self ._printer_profiles ,
444
+ gcode_scripts = self ._gcode_scripts
456
445
)
457
446
458
447
def get_template_configs (self ):
459
448
return [
460
449
dict (
461
450
type = "settings" ,
462
- custom_bindings = False ,
451
+ custom_bindings = True ,
463
452
template = "continuousprint_settings.jinja2" ,
464
453
),
465
454
dict (
@@ -480,6 +469,7 @@ def get_assets(self):
480
469
"js/continuousprint_queueset.js" ,
481
470
"js/continuousprint_job.js" ,
482
471
"js/continuousprint_viewmodel.js" ,
472
+ "js/continuousprint_settings.js" ,
483
473
"js/continuousprint.js" ,
484
474
],
485
475
css = ["css/continuousprint.css" ],
0 commit comments