]> www.infradead.org Git - users/dwmw2/esp32-pool.git/commitdiff
Reinstate Home command, adjust speed and stallguard thresholds
authorDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 11 Feb 2025 23:01:06 +0000 (23:01 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 11 Feb 2025 23:01:06 +0000 (23:01 +0000)
This will be better once the reed switches are wired up, but it works for now.

blind.yaml
landing-blind-3.yaml

index ec1010a5e5918ea3c3d1adba06cf3efdf3b1eb39..5a1de7e1a46e13a7ccf1bdaa62ce3550fe237372 100644 (file)
@@ -18,13 +18,13 @@ esphome:
         interpolation: true
         tcool_threshold: 400
     - tmc2209.stallguard:
-        threshold: 45   #set lower if stall gaurd triggering too often
+        threshold: 70   #set lower if stall gaurd triggering too often
     - tmc2209.currents:
         ihold: 0
         tpowerdown: 0
         iholddelay: 0
         # irun: 16
-        run_current: 100m #Set your desired current here (800m = 800mA, 1 = 1A etc.)
+        run_current: 20m #Set your desired current here (800m = 800mA, 1 = 1A etc.)
         standstill_mode: coil_short_ls
 
      # set PD voltage    # 5V  9V  12V  15V  20V
@@ -195,6 +195,14 @@ button:
   - platform: restart
     name: Restart
 
+  - platform: template
+    name: Home
+    id: home
+    on_press:
+      - stepper.set_target:
+          id: motor
+          target: !lambda "return id(motor)->current_position - 2.5 * ${encoder_closed_pos};"
+
   - platform: template
     name: Stop
     on_press:
@@ -232,8 +240,20 @@ binary_sensor:
      inverted: true
    filters:
      - delayed_on: 10ms
-   on_press:
-     - tmc2209.disable: motor
+   on_click:
+      - max_length: 1s
+        then:
+          - stepper.stop: motor
+
+      - min_length: 2s
+        max_length: 5s
+        then:
+          - logger.log:
+              level: INFO
+              format: "Blind rehome"
+          - stepper.set_target:
+              id: motor
+              target: !lambda "return id(motor)->current_position - 2.5 * ${encoder_closed_pos};"
 
  - platform: gpio
    name: Button 3
index 69c69df4c2370e718da33959f7abccf758883f51..ce7ebfc3889bba35d041b84c5489228c9501c7f1 100644 (file)
@@ -1,7 +1,7 @@
 substitutions:
   name: "landing-blind-3"
   encoder_closed_pos: "230000" # full blinds length (in encoder counts) !! CHANGE TO SUIT YOUR SETUP !!
-  microsteps: "1"
+  microsteps: "2"
 
 packages:
   blind: !include blind.yaml