Split movement time into separate raise/lower times and remove timing from latched mode

Co-authored-by: erikdred <88980320+erikdred@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-27 20:14:39 +00:00
parent 7ea1efbabf
commit bd11c827da
2 changed files with 30 additions and 22 deletions

View File

@@ -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
/// <summary>
/// Called when movement timer completes
/// </summary>
void OnMovementComplete(object o)
private void OnMovementComplete(object o)
{
Debug.LogMessage(LogEventLevel.Debug, this, $"Movement complete");

View File

@@ -20,9 +20,15 @@ namespace PepperDash.Essentials.Devices.Common.Shades
public int PulseTimeInMs { get; set; }
/// <summary>
/// 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
/// </summary>
[JsonProperty("movementTimeInMs")]
public int MovementTimeInMs { get; set; }
[JsonProperty("raiseTimeInMs")]
public int RaiseTimeInMs { get; set; }
/// <summary>
/// Gets or sets the LowerTimeInMs - time in milliseconds for the lower movement to complete
/// </summary>
[JsonProperty("lowerTimeInMs")]
public int LowerTimeInMs { get; set; }
}
}