From bd11c827daef5f6938c5cb89681de3649ebea126 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sat, 27 Dec 2025 20:14:39 +0000
Subject: [PATCH] Split movement time into separate raise/lower times and
remove timing from latched mode
Co-authored-by: erikdred <88980320+erikdred@users.noreply.github.com>
---
.../Displays/ScreenLiftController.cs | 40 ++++++++++---------
.../Displays/ScreenLiftRelaysConfig.cs | 12 ++++--
2 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/src/PepperDash.Essentials.Devices.Common/Displays/ScreenLiftController.cs b/src/PepperDash.Essentials.Devices.Common/Displays/ScreenLiftController.cs
index 5d25a58a..4494fdbf 100644
--- a/src/PepperDash.Essentials.Devices.Common/Displays/ScreenLiftController.cs
+++ b/src/PepperDash.Essentials.Devices.Common/Displays/ScreenLiftController.cs
@@ -196,23 +196,24 @@ namespace PepperDash.Essentials.Devices.Common.Shades
PulseOutput(RaiseRelay, RaiseRelayConfig.PulseTimeInMs);
// Set moving flag and start timer if movement time is configured
- if (RaiseRelayConfig.MovementTimeInMs > 0)
+ if (RaiseRelayConfig.RaiseTimeInMs > 0)
{
_isMoving = true;
- _movementTimer = new CTimer(OnMovementComplete, RaiseRelayConfig.MovementTimeInMs);
+
+ // Dispose previous timer if exists
+ if (_movementTimer != null)
+ {
+ _movementTimer.Stop();
+ _movementTimer.Dispose();
+ }
+
+ _movementTimer = new CTimer(OnMovementComplete, RaiseRelayConfig.RaiseTimeInMs);
}
break;
}
case eScreenLiftControlMode.latched:
{
LatchedRelay.Off();
-
- // Set moving flag and start timer if movement time is configured
- if (LatchedRelayConfig.MovementTimeInMs > 0)
- {
- _isMoving = true;
- _movementTimer = new CTimer(OnMovementComplete, LatchedRelayConfig.MovementTimeInMs);
- }
break;
}
}
@@ -245,23 +246,24 @@ namespace PepperDash.Essentials.Devices.Common.Shades
PulseOutput(LowerRelay, LowerRelayConfig.PulseTimeInMs);
// Set moving flag and start timer if movement time is configured
- if (LowerRelayConfig.MovementTimeInMs > 0)
+ if (LowerRelayConfig.LowerTimeInMs > 0)
{
_isMoving = true;
- _movementTimer = new CTimer(OnMovementComplete, LowerRelayConfig.MovementTimeInMs);
+
+ // Dispose previous timer if exists
+ if (_movementTimer != null)
+ {
+ _movementTimer.Stop();
+ _movementTimer.Dispose();
+ }
+
+ _movementTimer = new CTimer(OnMovementComplete, LowerRelayConfig.LowerTimeInMs);
}
break;
}
case eScreenLiftControlMode.latched:
{
LatchedRelay.On();
-
- // Set moving flag and start timer if movement time is configured
- if (LatchedRelayConfig.MovementTimeInMs > 0)
- {
- _isMoving = true;
- _movementTimer = new CTimer(OnMovementComplete, LatchedRelayConfig.MovementTimeInMs);
- }
break;
}
}
@@ -271,7 +273,7 @@ namespace PepperDash.Essentials.Devices.Common.Shades
///
/// Called when movement timer completes
///
- void OnMovementComplete(object o)
+ private void OnMovementComplete(object o)
{
Debug.LogMessage(LogEventLevel.Debug, this, $"Movement complete");
diff --git a/src/PepperDash.Essentials.Devices.Common/Displays/ScreenLiftRelaysConfig.cs b/src/PepperDash.Essentials.Devices.Common/Displays/ScreenLiftRelaysConfig.cs
index a99f82d3..f39134a4 100644
--- a/src/PepperDash.Essentials.Devices.Common/Displays/ScreenLiftRelaysConfig.cs
+++ b/src/PepperDash.Essentials.Devices.Common/Displays/ScreenLiftRelaysConfig.cs
@@ -20,9 +20,15 @@ namespace PepperDash.Essentials.Devices.Common.Shades
public int PulseTimeInMs { get; set; }
///
- /// Gets or sets the MovementTimeInMs - time in milliseconds for the movement to complete
+ /// Gets or sets the RaiseTimeInMs - time in milliseconds for the raise movement to complete
///
- [JsonProperty("movementTimeInMs")]
- public int MovementTimeInMs { get; set; }
+ [JsonProperty("raiseTimeInMs")]
+ public int RaiseTimeInMs { get; set; }
+
+ ///
+ /// Gets or sets the LowerTimeInMs - time in milliseconds for the lower movement to complete
+ ///
+ [JsonProperty("lowerTimeInMs")]
+ public int LowerTimeInMs { get; set; }
}
}
\ No newline at end of file