mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-11 19:44:52 +00:00
feat: Add mute logic to ScreenLiftController
- adds a config value that mutes the display when the screen is in the up position - screens will now mute/unmute based on their position if the config is set
This commit is contained in:
@@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
{
|
||||
None,
|
||||
Raise,
|
||||
Lower
|
||||
Lower,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -50,7 +50,8 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
get { return _isInUpPosition; }
|
||||
set
|
||||
{
|
||||
if (value == _isInUpPosition) return;
|
||||
if (value == _isInUpPosition)
|
||||
return;
|
||||
_isInUpPosition = value;
|
||||
IsInUpPosition.FireUpdate();
|
||||
PositionChanged?.Invoke(this, new EventArgs());
|
||||
@@ -87,7 +88,11 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
/// <summary>
|
||||
/// Constructor for ScreenLiftController
|
||||
/// </summary>
|
||||
public ScreenLiftController(string key, string name, ScreenLiftControllerConfigProperties config)
|
||||
public ScreenLiftController(
|
||||
string key,
|
||||
string name,
|
||||
ScreenLiftControllerConfigProperties config
|
||||
)
|
||||
: base(key, name)
|
||||
{
|
||||
Config = config;
|
||||
@@ -116,16 +121,49 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IsInUpPosition.OutputChange += (sender, args) =>
|
||||
{
|
||||
this.LogDebug(
|
||||
"ScreenLiftController '{name}' IsInUpPosition changed to {position}",
|
||||
Name,
|
||||
IsInUpPosition.BoolValue ? "Up" : "Down"
|
||||
);
|
||||
|
||||
if (!Config.MuteOnScreenUp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (DisplayDevice is IBasicVideoMuteWithFeedback videoMute)
|
||||
{
|
||||
this.LogInformation("Unmuting video because screen is down");
|
||||
videoMute.VideoMuteOff();
|
||||
}
|
||||
};
|
||||
|
||||
IsInUpPosition.FireUpdate();
|
||||
}
|
||||
|
||||
private void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
if (!DisplayDevice.IsCoolingDownFeedback.BoolValue && Type == eScreenLiftControlType.lift)
|
||||
if (
|
||||
!DisplayDevice.IsCoolingDownFeedback.BoolValue
|
||||
&& Type == eScreenLiftControlType.lift
|
||||
)
|
||||
{
|
||||
Raise();
|
||||
return;
|
||||
}
|
||||
if (DisplayDevice.IsCoolingDownFeedback.BoolValue && Type == eScreenLiftControlType.screen)
|
||||
if (
|
||||
DisplayDevice.IsCoolingDownFeedback.BoolValue
|
||||
&& Type == eScreenLiftControlType.screen
|
||||
)
|
||||
{
|
||||
Raise();
|
||||
return;
|
||||
@@ -172,7 +210,8 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
this.LogDebug("Subscribing to {displayKey} feedbacks", DisplayDeviceKey);
|
||||
|
||||
DisplayDevice.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange;
|
||||
DisplayDevice.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange;
|
||||
DisplayDevice.IsCoolingDownFeedback.OutputChange +=
|
||||
IsCoolingDownFeedback_OutputChange;
|
||||
}
|
||||
|
||||
return base.CustomActivate();
|
||||
@@ -183,10 +222,17 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
/// </summary>
|
||||
public void Raise()
|
||||
{
|
||||
if (RaiseRelay == null && LatchedRelay == null) return;
|
||||
if (RaiseRelay == null && LatchedRelay == null)
|
||||
return;
|
||||
|
||||
this.LogDebug("Raise called for {type}", Type);
|
||||
|
||||
if (Config.MuteOnScreenUp && DisplayDevice is IBasicVideoMuteWithFeedback videoMute)
|
||||
{
|
||||
this.LogInformation("Muting video because screen is going up");
|
||||
videoMute.VideoMuteOn();
|
||||
}
|
||||
|
||||
// If device is moving, bank the command
|
||||
if (_isMoving)
|
||||
{
|
||||
@@ -235,7 +281,8 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
/// </summary>
|
||||
public void Lower()
|
||||
{
|
||||
if (LowerRelay == null && LatchedRelay == null) return;
|
||||
if (LowerRelay == null && LatchedRelay == null)
|
||||
return;
|
||||
|
||||
this.LogDebug("Lower called for {type}", Type);
|
||||
|
||||
@@ -339,10 +386,7 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
{
|
||||
output.On();
|
||||
|
||||
var timer = new Timer(pulseTime)
|
||||
{
|
||||
AutoReset = false
|
||||
};
|
||||
var timer = new Timer(pulseTime) { AutoReset = false };
|
||||
|
||||
timer.Elapsed += (sender, e) =>
|
||||
{
|
||||
@@ -361,7 +405,10 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LogWarning("Error: Unable to get relay device with key '{relayKey}'", relayKey);
|
||||
this.LogWarning(
|
||||
"Error: Unable to get relay device with key '{relayKey}'",
|
||||
relayKey
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -375,11 +422,13 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LogWarning("Error: Unable to get display device with key '{displayKey}'", displayKey);
|
||||
this.LogWarning(
|
||||
"Error: Unable to get display device with key '{displayKey}'",
|
||||
displayKey
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
/// </summary>
|
||||
public class ScreenLiftControllerConfigProperties
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DisplayDeviceKey
|
||||
/// </summary>
|
||||
@@ -37,5 +36,10 @@ namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
[JsonProperty("relays")]
|
||||
public Dictionary<string, ScreenLiftRelaysConfig> Relays { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mutes the display when the screen is in the up position
|
||||
/// </summary>
|
||||
[JsonProperty("muteOnScreenUp")]
|
||||
public bool MuteOnScreenUp { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user