Edit esp-astroclockstepper1.yaml
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-astroclockstepper.yaml
|
||||
#:########################################################################################:#
|
||||
# VERSIONS:
|
||||
# V1.1 2026-06-22 Added onboard D1 Mini LED flash on each motor step
|
||||
# V1.0 2026-06-22 Initial Version
|
||||
#:########################################################################################:#
|
||||
# HARDWARE:
|
||||
@@ -31,6 +32,10 @@
|
||||
# - Uses built-in 103 pull-up resistors, 10k ohm
|
||||
# - Buttons should pull the GPIO pin to GND when pressed
|
||||
# - Pull-ups must go to 3.3V, not 5V
|
||||
#
|
||||
# Onboard Step LED:
|
||||
# - GPIO2 / D4
|
||||
# - Active-low on most D1 Mini boards
|
||||
#:########################################################################################:#
|
||||
# OPERATION NOTES:
|
||||
# - Normal rotation starts automatically after boot.
|
||||
@@ -42,6 +47,7 @@
|
||||
# - Web template switches mimic held physical buttons.
|
||||
# - Manual movement only applies while a physical button or web switch is held/on.
|
||||
# - Position counter wraps back to zero after one full rotation.
|
||||
# - Onboard D1 Mini LED flashes briefly every time a motor step is issued.
|
||||
#:########################################################################################:#
|
||||
# OFFLINE NOTES:
|
||||
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE
|
||||
@@ -73,7 +79,7 @@ substitutions:
|
||||
|
||||
# Project Naming
|
||||
project_name: "zorruno.Astronomical Clock Stepper"
|
||||
project_version: "v1.0"
|
||||
project_version: "v1.1"
|
||||
|
||||
# Passwords & Secrets (Unfortunately, you cannot use substitutions inside secret names)
|
||||
api_key: !secret esp-api_key
|
||||
@@ -112,6 +118,10 @@ substitutions:
|
||||
# Coil Release
|
||||
coil_release_ms: "500"
|
||||
|
||||
# Step LED
|
||||
onboard_step_led_pin: GPIO2
|
||||
step_led_flash_ms: "25"
|
||||
|
||||
# Stepper Output Pins
|
||||
stepper_in1_pin: GPIO14
|
||||
stepper_in2_pin: GPIO12
|
||||
@@ -194,6 +204,7 @@ esphome:
|
||||
on_boot:
|
||||
priority: -100
|
||||
then:
|
||||
- output.turn_off: onboard_step_led
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "Astronomical Clock Stepper started. Normal rotation is %s days per full revolution."
|
||||
@@ -261,6 +272,16 @@ globals:
|
||||
restore_value: no
|
||||
initial_value: "false"
|
||||
|
||||
- id: step_led_is_on
|
||||
type: bool
|
||||
restore_value: no
|
||||
initial_value: "false"
|
||||
|
||||
- id: step_led_started_ms
|
||||
type: uint32_t
|
||||
restore_value: no
|
||||
initial_value: "0"
|
||||
|
||||
# 0 = Normal
|
||||
# 1 = Fast Forward
|
||||
# 2 = Slow Forward
|
||||
@@ -316,7 +337,7 @@ globals:
|
||||
|
||||
#:########################################################################################:#
|
||||
# OUTPUT:
|
||||
# Stepper driver GPIO outputs
|
||||
# Stepper driver GPIO outputs and onboard step LED
|
||||
# https://esphome.io/components/output/gpio.html
|
||||
#:########################################################################################:#
|
||||
output:
|
||||
@@ -336,6 +357,13 @@ output:
|
||||
id: stepper_in4
|
||||
pin: ${stepper_in4_pin}
|
||||
|
||||
# D1 Mini onboard LED is usually GPIO2 / D4 and active-low
|
||||
- platform: gpio
|
||||
id: onboard_step_led
|
||||
pin:
|
||||
number: ${onboard_step_led_pin}
|
||||
inverted: true
|
||||
|
||||
|
||||
#:########################################################################################:#
|
||||
# SWITCH:
|
||||
@@ -637,6 +665,7 @@ interval:
|
||||
(${manual_slow_rotation_seconds} * 1000.0) / ${steps_per_rotation};
|
||||
|
||||
const uint32_t COIL_RELEASE_MS = ${coil_release_ms};
|
||||
const uint32_t STEP_LED_FLASH_MS = ${step_led_flash_ms};
|
||||
|
||||
auto all_coils_off = [&]() {
|
||||
id(stepper_in1).turn_off();
|
||||
@@ -646,6 +675,12 @@ interval:
|
||||
id(coils_are_on) = false;
|
||||
};
|
||||
|
||||
auto flash_step_led = [&](uint32_t now_ms) {
|
||||
id(onboard_step_led).turn_on();
|
||||
id(step_led_started_ms) = now_ms;
|
||||
id(step_led_is_on) = true;
|
||||
};
|
||||
|
||||
auto set_coils_for_phase = [&](int phase) {
|
||||
const bool sequence[8][4] = {
|
||||
{true, false, false, false},
|
||||
@@ -698,6 +733,7 @@ interval:
|
||||
|
||||
set_coils_for_phase(id(current_phase_index));
|
||||
id(last_step_ms) = now_ms;
|
||||
flash_step_led(now_ms);
|
||||
};
|
||||
|
||||
const bool fast_forward_active =
|
||||
@@ -772,6 +808,14 @@ interval:
|
||||
all_coils_off();
|
||||
}
|
||||
|
||||
if (
|
||||
id(step_led_is_on) &&
|
||||
((uint32_t) (now_ms - id(step_led_started_ms)) >= STEP_LED_FLASH_MS)
|
||||
) {
|
||||
id(onboard_step_led).turn_off();
|
||||
id(step_led_is_on) = false;
|
||||
}
|
||||
|
||||
|
||||
#:########################################################################################:#
|
||||
# MQTT:
|
||||
|
||||
Reference in New Issue
Block a user