c_evening_daylight.cfg modified - 19/04/25 - 00:31:02

This commit is contained in:
pi committed 2025-04-19 00:31:06 +01:00
1 parent 90a0b05753
commit edff0bf999
1 file changed
+19 -5
@@ -1,11 +1,26 @@
[gcode_shell_command GET_TIME]
command: /path/to/get_time.sh
timeout: 2.0
return_value: True
[gcode_macro FETCH_TIME]
gcode:
RUN_SHELL_COMMAND GET_TIME
{% set parts = shell_command_output.split(" ") %}
SET_GCODE_VARIABLE MACRO=EVENING_DAYLIGHT VARIABLE=hour VALUE={{ parts[0]|int }}
SET_GCODE_VARIABLE MACRO=EVENING_DAYLIGHT VARIABLE=minute VALUE={{ parts[1]|int }}
[gcode_macro CHECK_AND_FADE_LIGHT]
gcode:
FETCH_TIME
EVENING_DAYLIGHT
[gcode_macro EVENING_DAYLIGHT]
description: 24hr day/night lighting with fade-in/out and no log spam
variable_hour: 0
variable_minute: 0
variable_last_brightness: -1.0
gcode:
{% set hour = printer["system_time"].hour %}
{% set minute = printer["system_time"].minute %}
{% set total_minutes = hour * 60 + minute %}
{% set fade_out_start = 7 * 60 %}
{% set fade_out_end = 8 * 60 %}
{% set fade_in_start = 16 * 60 + 30 %}
@@ -30,7 +45,6 @@ gcode:
{% if rounded_target != last_brightness %}
SET_PIN PIN=daylight VALUE={rounded_target}
SET_GCODE_VARIABLE MACRO=EVENING_DAYLIGHT VARIABLE=last_brightness VALUE={rounded_target}
{% set time_display = hour|string ~ ":" ~ ("%02d"|format(minute)) %}
{% set fade_msg = "💡 Brightness: " ~ (rounded_target * 100)|int|string ~ "% at " ~ time_display %}
RESPOND MSG="{fade_msg}"