Skip to content

Commit

Permalink
HEAT_SOAK bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rootiest committed Sep 14, 2023
1 parent f9ae057 commit fa4c8d1
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 40 deletions.
Empty file modified extras/tool_swap/tool_swap.sh
100755 → 100644
Empty file.
58 changes: 22 additions & 36 deletions macros/HEAT_SOAK.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[respond]

[gcode_macro HEAT_SOAK]
description: heats the bed for a while

Expand All @@ -8,36 +10,29 @@ variable_stage: None ## heating -> soaking -> done -> None
variable_check_interval: 10
variable_soak_time_remaining: 0
variable_total_time_elapsed: 0

variable_output: 118
gcode:
{% set printcfg = printer["gcode_macro _printcfg"] %} {% set TARGET = params.TARGET | default(110) | float %}
{% set soak_macro = printer["gcode_macro HEAT_SOAK"] %} {% set TARGET = params.TARGET | default(110) | float %}
{% set DURATION = (params.DURATION | default(10) | int) * 60 %} ## minutes to seconds

SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=target_temp VALUE={ TARGET }
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=stage VALUE="'heating'"
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=soak_time_remaining VALUE={ DURATION }
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=total_time_elapsed VALUE=0

;; fire up the heater
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={ TARGET }

;; Do the lights
STATUS_SOAKING


#STATUS_SOAKING
;; run the fans to circulate air
_FAN_SOAK

;; home the printer
G28
;; put the bed and nozzle where they're a safe distance apart
HOME_IF_NEEDED
PARKBED_MID

#PARKBED_MID
M84 ;; turn off steppers

;; Do the lights (again)
STATUS_SOAKING
M{printcfg.output|int} Soaking...

#STATUS_SOAKING
M{soak_macro.output|int} Soaking...
UPDATE_DELAYED_GCODE ID=heat_soaker DURATION={ check_interval }

[gcode_macro CANCEL_HEAT_SOAK]
Expand All @@ -50,17 +45,14 @@ gcode:
; ## debug
; { action_respond_info( printer['gcode_macro HEAT_SOAK'] | tojson )}
gcode:
{% set printcfg = printer["gcode_macro _printcfg"] %} {% set heat_soak = printer['gcode_macro HEAT_SOAK'] %}

{% set soak_macro = printer["gcode_macro HEAT_SOAK"] %} {% set heat_soak = printer['gcode_macro HEAT_SOAK'] %}
## update total time elapsed
{% set total_time_elapsed = heat_soak.total_time_elapsed + heat_soak.check_interval %}
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=total_time_elapsed VALUE={ total_time_elapsed }

{% set stage = heat_soak.stage %}
{% if stage == "heating" and printer.heater_bed.temperature >= heat_soak.target_temp %}
{% set stage = "soaking" %}
{% endif %}

{% if stage == "soaking" %}
## update soak countdown
{% set soak_time_remaining = [heat_soak.soak_time_remaining - heat_soak.check_interval, 0] | max %}
Expand All @@ -70,58 +62,52 @@ gcode:
{% set stage = "done" %}
{% endif %}
{% endif %}

SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=stage VALUE="'{ stage }'"

{% if stage in ("done", "cancel") %}
STATUS_READY
#STATUS_READY
_FAN_SOAK_OFF
{% if stage == "cancel" %}
{% set stage = "done" %}
TURN_OFF_HEATERS
M107 ; turn off fan
M{printcfg.output|int} { "soak cancelled after ~%.1fm" | format(total_time_elapsed / 60.0) }
game_over_tune
M{soak_macro.output|int} { "soak cancelled after ~%.1fm" | format(total_time_elapsed / 60.0) }
#game_over_tune
{% else %}
M{printcfg.output|int} { "soak complete after %.1fm" | format(total_time_elapsed / 60.0) }
zelda_end_tune
M{soak_macro.output|int} { "soak complete after %.1fm" | format(total_time_elapsed / 60.0) }
#zelda_end_tune
{% endif %}

## reset all state vars, except stage, which may be queried via the api
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=target_temp VALUE=0
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=soak_time_remaining VALUE=0
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=total_time_elapsed VALUE=0

{% else %}
{% set BED_TARGET = printer.heater_bed.target|float %}
{% set BED_TEMP = printer.heater_bed.temperature|float %}
{% set BED_PROGRESS = (BED_TEMP / BED_TARGET) * 255 %}
WLED_CONTROL INTENSITY={BED_PROGRESS}
#WLED_CONTROL INTENSITY={BED_PROGRESS}
{% if total_time_elapsed % 90 == 0 %}
## output status periodically
{% if stage == "heating" %}
M{printcfg.output|int} { "heating -- %.1fm elapsed" | format(total_time_elapsed / 60.0) }
M{soak_macro.output|int} { "heating -- %.1fm elapsed" | format(total_time_elapsed / 60.0) }
{% elif stage == "soaking" %}
M{printcfg.output|int} { "soaking -- %.1fm remaining" | format(soak_time_remaining / 60.0) }
M{soak_macro.output|int} { "soaking -- %.1fm remaining" | format(soak_time_remaining / 60.0) }
{% endif %}
{% endif %}

## trigger ourselves again
UPDATE_DELAYED_GCODE ID=heat_soaker DURATION={ heat_soak.check_interval }

## dwell for 1ms to prevent from going idle
G4 P1

{% endif %}

[gcode_macro _FAN_SOAK]
gcode:
#NEVERMORE_LOW
BED_FAN_ON
#BED_FAN_ON
#PI_FAN_ON
#SYSTEM_FAN_ON

[gcode_macro _FAN_SOAK_OFF]
gcode:
NEVERMORE_OFF
BED_FAN_OFF
#NEVERMORE_OFF
#BED_FAN_OFF
Empty file modified scripts/clean_backups.sh
100755 → 100644
Empty file.
Empty file modified scripts/datetime.sh
100755 → 100644
Empty file.
Empty file modified scripts/fix_os_stuff.sh
100755 → 100644
Empty file.
Empty file modified scripts/fix_scripts.sh
100755 → 100644
Empty file.
Empty file modified scripts/git_backup.sh
100755 → 100644
Empty file.
Empty file modified scripts/invert_file.sh
100755 → 100644
Empty file.
Empty file modified scripts/kamp_patch.sh
100755 → 100644
Empty file.
Empty file modified scripts/mcu_timing.sh
100755 → 100644
Empty file.
56 changes: 52 additions & 4 deletions scripts/move_files.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash
# Copyright (C) 2023 Chris Laprade (chris@rootiest.com)
#
#
# This file is part of config.
#
#
# config is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# config is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with config. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -68,3 +68,51 @@ done
# Provide summary
num_files=$(echo "$matching_files" | wc -w)
echo "Moved $num_files file(s) from $1 to $2."













#! /bin/bash

# Find current directory
current_dir=$(pwd)

# Define the matching pattern
pattern="printer-\d{8}_\d{6}\.cfg"

# Define backup directory
backup_dir="$current_dir/backup"

# Create backup directory if it doesn't exist
if [ ! -d "$backup_dir" ]; then
echo "Backup folder does not exist. Creating backup folder..."
mkdir -p "$backup_dir"
fi

# Search using regex for recursivelly files matching the regex pattern in all subdirectories of the current directory
matching_files=$(find "$current_dir" -type f -wholename "/$pattern")
# skip any files in the backup directory
matching_files=$(echo "$matching_files" | grep -v "$backup_dir")

if [ -z "$matching_files" ]; then
echo "No files matching the regex were found in the source folder."
exit 0
fi

for file in $matching_files; do
# Move the files to the "backup" folder
mv "$file" "$backup_dir"
done

# Provide summary
num_files=$(echo "$matching_files" | wc -w)
echo "Moved $num_files file(s) from $current_dir to $backup_dir"
Empty file modified scripts/restart_ks.sh
100755 → 100644
Empty file.

0 comments on commit fa4c8d1

Please sign in to comment.