mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 19:08:29 +00:00
- Updated RelayControlledShade to utilize Timer for output pulsing. - Refactored MockVC to replace CTimer with Timer for call status simulation. - Modified VideoCodecBase to enhance documentation and improve feedback handling. - Removed obsolete IHasCamerasMessenger and updated related classes to use IHasCamerasWithControls. - Adjusted PressAndHoldHandler to implement Timer for button hold actions. - Enhanced logging throughout MobileControl and RoomBridges for better debugging and information tracking. - Cleaned up unnecessary comments and improved exception handling in various classes.
85 lines
No EOL
1.6 KiB
C#
85 lines
No EOL
1.6 KiB
C#
using System.Timers;
|
|
namespace PepperDash.Essentials.Core
|
|
{
|
|
/// <summary>
|
|
/// Represents a BoolFeedbackPulse
|
|
/// </summary>
|
|
public class BoolFeedbackPulse
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the TimeoutMs
|
|
/// </summary>
|
|
public uint TimeoutMs { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the CanRetrigger
|
|
/// </summary>
|
|
public bool CanRetrigger { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Feedback
|
|
/// </summary>
|
|
public BoolFeedback Feedback { get; private set; }
|
|
Timer Timer;
|
|
|
|
bool _BoolValue;
|
|
|
|
/// <summary>
|
|
/// Creates a non-retriggering one shot
|
|
/// </summary>
|
|
public BoolFeedbackPulse(uint timeoutMs)
|
|
: this(timeoutMs, false)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a retriggerable one shot by setting canRetrigger true
|
|
/// </summary>
|
|
public BoolFeedbackPulse(uint timeoutMs, bool canRetrigger)
|
|
{
|
|
TimeoutMs = timeoutMs;
|
|
CanRetrigger = canRetrigger;
|
|
Feedback = new BoolFeedback(() => _BoolValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Start method
|
|
/// </summary>
|
|
public void Start()
|
|
{
|
|
if (Timer == null)
|
|
{
|
|
_BoolValue = true;
|
|
Feedback.FireUpdate();
|
|
Timer = new Timer(TimeoutMs) { AutoReset = false };
|
|
Timer.Elapsed += (s, e) =>
|
|
{
|
|
_BoolValue = false;
|
|
Feedback.FireUpdate();
|
|
Timer = null;
|
|
};
|
|
Timer.Start();
|
|
}
|
|
// Timer is running, if retrigger is set, reset it.
|
|
else if (CanRetrigger)
|
|
{
|
|
Timer.Stop();
|
|
Timer.Interval = TimeoutMs;
|
|
Timer.Start();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cancel method
|
|
/// </summary>
|
|
public void Cancel()
|
|
{
|
|
if (Timer != null)
|
|
{
|
|
Timer.Stop();
|
|
Timer.Interval = 1;
|
|
Timer.Start();
|
|
}
|
|
}
|
|
}
|
|
} |