Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# -----
# PLEASE DO NOT EDIT THIS FILE. EDIT printer.cfg INSTEAD.
# UPDATES WILL RESET THIS FILE. YOUR EDITS WILL BE LOST WHEN UPDATING.
# -----

[gcode_macro M729]
gcode:
{ action_emergency_stop("Use COSMOS OrcaSlicer profile (or COSMOS start/end machine gcode).") }

[gcode_macro M8213]
gcode:
{ action_emergency_stop("Use COSMOS OrcaSlicer profile (or COSMOS start/end machine gcode).") }

[gcode_macro CLEAN_NOZZLE]
gcode:
{% set global = printer['gcode_macro _global_var'] %}
{% set pre_toolhead_target = printer.extruder.target|int %}
{% set target = params.TARGET|default(global.extruder_temp.cleaning if pre_toolhead_target < global.extruder_temp.cleaning else pre_toolhead_target)|int %}
M104 S{target}
_CG28 AXIS=XY
G90

MOVE_TO_TRAY
M104 S{target}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={target} MAXIMUM={target+5}
M106 S255
# Wipe
G1 F9000
{% for wipes in range(4) %}
{% for i in range(8) %}
{% set x = 187 - (i * 2) %}
{% set y = 264 if i % 2 == 0 else 262 %}
G1 X{x} Y{y}
{% endfor %}
G1 X187
{% endfor %}
G1 Y250
# Clear command queue
M104 S{pre_toolhead_target}
M107
M400

[gcode_macro MOVE_TO_TRAY]
gcode:
_CG28 AXIS=XY

{% if printer.gcode_move.position.x > 201.5 and printer.gcode_move.position.x < 202.5 and printer.gcode_move.position.y > 263.5 and printer.gcode_move.position.y < 264.5 and "xy" in printer.toolhead.homed_axes %}
RETURN ; Already at the tray
{% endif %}

G90 ; Absolute positioning
G0 X202 F12000
G0 Y250 F12000 ; Move near to the try
G0 Y264 F1200 ; Move slowly back to the tray

M400 ; Wait for movements to complete

[gcode_macro KICK]
variable_end_kick_x: 186
gcode:
{% set global = printer['gcode_macro _global_var'] %}
{% set self = printer["gcode_macro KICK"] %}
{% set end_kick_x = self.end_kick_x|float %}
{% set retract_amount = global.retract_amount|float %}

{% if "xy" not in printer.toolhead.homed_axes %}
{action_raise_error("Printer not homed")}
{% endif %}

{% if printer.extruder.target < 180 or not printer.extruder.can_extrude %}
{action_raise_error("Extruder not hot enough to kick")}
{% endif %}

G90 ; Absolute positioning
M83 ; E relative

MOVE_TO_TRAY ; Move to the tray
G1 E-{retract_amount} F300 ; Retract slightly to reduce pressure during kick
M106 S255 ; Full blast fan to solidify plastic
G4 P2000 ; Wait 2 seconds for fan to do its work
G1 F8000 ; Set feedrate
G1 X{self.end_kick_x} ; Swipe over the v-slot (into)
G1 X193 ; Swipe over the v-slot (out of)
G1 X{self.end_kick_x} ; Swipe over the v-slot (into)
M107 ; Turn off fan

G1 Y250 F6000 ; Exit

M400 ; Wait for movements to complete

[gcode_shell_command CAMERA_LIGHT_ON]
command: v4l2-ctl -d /dev/video0 --set-ctrl backlight_compensation=1
timeout: 5
verbose: False

[gcode_shell_command CAMERA_LIGHT_OFF]
command: v4l2-ctl -d /dev/video0 --set-ctrl backlight_compensation=0
timeout: 5
verbose: False

[gcode_macro SYNC_CAMERA_LED]
variable_last_state: 0
gcode:
{% set current = printer["led case"].color_data[0][3] > 0 %}
{% set last = printer["gcode_macro SYNC_CAMERA_LED"].last_state %}

{% if current != last %}
SET_GCODE_VARIABLE MACRO=SYNC_CAMERA_LED VARIABLE=last_state VALUE={current}
{% if current %}
RUN_SHELL_COMMAND CMD=CAMERA_LIGHT_ON
{% else %}
RUN_SHELL_COMMAND CMD=CAMERA_LIGHT_OFF
{% endif %}
{% endif %}

[delayed_gcode camera_startup]
initial_duration: 1.0
gcode:
{% set settings = printer["gcode_macro _COSMOS_SETTINGS"]|default({}) %}
{% set camera_led_on = settings.camera_led_default_on|default(false)|lower == 'true' %}

{% if camera_led_on %}
RUN_SHELL_COMMAND CMD=CAMERA_LIGHT_ON
{% endif %}

[delayed_gcode sync_camera_led_loop]
initial_duration: 2.0
gcode:
{% set settings = printer["gcode_macro _COSMOS_SETTINGS"]|default({}) %}
{% set sync = settings.sync_camera_led_to_chamber_led|default(false)|lower == 'true' %}

{% if sync %}
SYNC_CAMERA_LED
UPDATE_DELAYED_GCODE ID=sync_camera_led_loop DURATION=2
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ enable_pin: !PF6
endstop_pin: tmc2209_stepper_x:virtual_endstop
microsteps: 16
full_steps_per_rotation: 200
position_endstop: 256
position_max: 256
position_endstop: 256.5
position_max: 256.5
position_min: -2
homing_speed: 80
homing_retract_dist: 20
Expand Down Expand Up @@ -387,6 +387,37 @@ tachometer_pin: PD16
pin: PB7
initial_angle: 90.0

[gcode_button case_servo_sensor]
pin: PB2
press_gcode:
UPDATE_DELAYED_GCODE ID=case_servo_timeout DURATION=0
G4 P400 ; We have no way to detect when the fan cover is fully open. Instead, the sensor triggers somewhere halfway, and around 400ms is needed to fully open it.
SET_SERVO SERVO=case_servo ANGLE=90
release_gcode:
UPDATE_DELAYED_GCODE ID=case_servo_timeout DURATION=0
SET_SERVO SERVO=case_servo ANGLE=90

[delayed_gcode case_servo_timeout]
gcode:
SET_SERVO SERVO=case_servo ANGLE=90
RESPOND TYPE=error MSG="Servo timeout: sensor did not change"

[gcode_macro EXHAUST_OPEN]
gcode:
{% if printer["gcode_button case_servo_sensor"].state == "PRESSED" %} ; Currently closed
RESPOND MSG="Opening exhaust cover"
UPDATE_DELAYED_GCODE ID=case_servo_timeout DURATION=5
SET_SERVO SERVO=case_servo ANGLE=135
{% endif %}

[gcode_macro EXHAUST_CLOSE]
gcode:
{% if printer["gcode_button case_servo_sensor"].state == "RELEASED" %} ; Currently open
RESPOND MSG="Closing exhaust cover"
UPDATE_DELAYED_GCODE ID=case_servo_timeout DURATION=5
SET_SERVO SERVO=case_servo ANGLE=45
{% endif %}

[temperature_fan mainboard]
pin: PG15
tachometer_pin: PB9
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# -----
# PLEASE DO NOT EDIT THIS FILE. EDIT printer.cfg INSTEAD.
# UPDATES WILL RESET THIS FILE. YOUR EDITS WILL BE LOST WHEN UPDATING.
# -----

[gcode_macro _global_var]
variable_always_kick_during_purge: True

[gcode_macro M6211]
gcode:
{ action_emergency_stop("Use COSMOS OrcaSlicer profile (or COSMOS start/end machine gcode).") }

[gcode_macro G180]
gcode:
{ action_emergency_stop("Use COSMOS OrcaSlicer profile (or COSMOS start/end machine gcode).") }

[gcode_macro MOVE_TO_TRAY]
gcode:
_CG28 AXIS=XY

{% if printer.gcode_move.position.x > 52 and printer.gcode_move.position.x < 53 and printer.gcode_move.position.y > 263.5 and printer.gcode_move.position.y < 264.5 and "xy" in printer.toolhead.homed_axes %}
RETURN ; Already at the tray
{% endif %}

G90 ; Absolute positioning
G0 X52.5 F20000
G0 Y255 F20000 ; Move near to the try
G0 Y264 F1200 ; Move slowly back to the tray

M400 ; Wait for movements to complete

[gcode_macro KICK]
gcode:
{% set global = printer['gcode_macro _global_var'] %}
{% set retract_amount = global.retract_amount|float %}

{% if "xy" not in printer.toolhead.homed_axes %}
{action_raise_error("Printer not homed")}
{% endif %}

{% if printer.extruder.target < 180 or not printer.extruder.can_extrude %}
{action_raise_error("Extruder not hot enough to kick")}
{% endif %}

G90 ; Absolute positioning
M83 ; E relative

MOVE_TO_TRAY ; Move to the tray
G1 E-{retract_amount} F300 ; Retract slightly to reduce pressure during kick
M106 S255 ; Full blast fan to solidify plastic
G4 P2000 ; Wait 2 seconds for fan to do its work
G1 Y258 F10000
G4 P200
G0 Y264 F1200
G1 Y255 F8000 ; Move back into print
M107

M400 ; Wait for movements to complete

[gcode_macro CLEAN_NOZZLE]
gcode:
{% set global = printer['gcode_macro _global_var'] %}
{% set pre_toolhead_target = printer.extruder.target|int %}
{% set target = params.TARGET|default(global.extruder_temp.cleaning if pre_toolhead_target < global.extruder_temp.cleaning else pre_toolhead_target)|int %}
{% set retract_amount = global.retract_amount|float %}
{% set with_retract = params.RETRACT|default('false')|lower == 'true' %}

M104 S{target}
_CG28 AXIS=XY
G90
M83

MOVE_TO_TRAY
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={target} MAXIMUM={target+5}

{% if with_retract %}
G1 E-{retract_amount} F300 ; Retract slightly to reduce pressure
{% endif %}
M106 S255 ; Full blast fan to solidify plastic
G4 P2000 ; Wait 2 seconds for fan to do its work

G1 X64 Y264 F1200 ; Ensure to be at the right position
G1 F8000

{% for _ in range(3) %}
G1 X64
G1 X80
{% endfor %}

M104 S{pre_toolhead_target}

G1 Y255 ; Exit
M107

M400 ; Wait for movements to complete
Loading
Loading