evening_daylight.cfg modified - 18/04/25 - 09:37:22
This commit is contained in:
1 parent
e125ff84bb
commit
22535a8cda
1 file changed
+12
-9
@@ -1,5 +1,6 @@
|
||||
[gcode_macro EVENING_DAYLIGHT]
|
||||
description: Fade in daylight between 4:30pm and 6:00pm
|
||||
description: Fade in daylight between 4:30pm and 6:00pm, only respond if brightness changes
|
||||
variable_last_brightness: -1.0
|
||||
gcode:
|
||||
{% set hour = now().hour %}
|
||||
{% set minute = now().minute %}
|
||||
@@ -8,17 +9,19 @@ gcode:
|
||||
{% set fade_end = 18 * 60 %}
|
||||
|
||||
{% if total_minutes < fade_start %}
|
||||
SET_PIN PIN=daylight VALUE=0
|
||||
RESPOND MSG="🌑 Daylight: OFF (before 4:30pm)"
|
||||
{% set target = 0.0 %}
|
||||
{% elif total_minutes >= fade_end %}
|
||||
SET_PIN PIN=daylight VALUE=1
|
||||
RESPOND MSG="🌕 Daylight: ON 100% (after 6pm)"
|
||||
{% set target = 1.0 %}
|
||||
{% else %}
|
||||
{% set progress = (total_minutes - fade_start) / (fade_end - fade_start) %}
|
||||
{% set brightness = progress %}
|
||||
SET_PIN PIN=daylight VALUE={{ brightness|round(3) }}
|
||||
{% set target = ((total_minutes - fade_start) / (fade_end - fade_start)) %}
|
||||
{% endif %}
|
||||
|
||||
{% set rounded_target = (target * 100)|int / 100.0 %}
|
||||
{% 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 = "🌗 Daylight: " ~ (brightness * 100)|int|string ~ "% (" ~ time_display ~ ")" %}
|
||||
{% set fade_msg = "🌗 Daylight: " ~ (rounded_target * 100)|int|string ~ "% (" ~ time_display ~ ")" %}
|
||||
RESPOND MSG="{fade_msg}"
|
||||
{% endif %}
|
||||
Reference in new issue
Block a user